Jump to content
UltiMaker Community of 3D Printing Experts

enable output pin when print finished and get an email.


Recommended Posts

Posted · enable output pin when print finished and get an email.

I want to enable an output pin, when print has finished.. I have tried to use the second heater o/p. but cant get this to work.

M42 P4 S255;

G4 P5;

M42 P4 S0;

Do i need to do something in the firmware for this to work? I heater 2 enabled by default?

If i want to use another available pin, do I need to "define"it, if so where.


Basically once I can get an o/p to do something when finished,, I'm going to link it to an arduino with ethernet sheild... using this I can get an email, when print has finished using "pushing box"... I'm using 10 printers, and this would be an awesome feature.


I would really appreciate some help with this,



  • Link to post
    Share on other sites

    Posted · enable output pin when print finished and get an email.

    Someone wanted to do a layer-by-layer timelapse using a similar command. Someone else suggested the m42 command in the layer comment.

    You can probably leverage the same solution for your use. However, it requires you to tap into the board expansion points and I think you will need to solder a header on to do so.




    Actually, you don't need to touch Arduino code. You can change pins with the M42 code. Combine this with G4 (delay) and you can code your camera trigger in pure GCode.

    For example:

    M42 P23 S255 ; Set the trigger camera pin high

    G4 P100 ; Wait 100ms

    M42 P23 S0 ; Set the trigger camera pin low



    do you also know how that corresponds to the 1.5.4 ultimaker pcb? because from the wiki it's not clear to me where I would connect the opto-coupler,



    The pin numbers correspond to the numbers shown here:


    I recommend you use one of the PWM or ANALOGUE pins, because the EXP1 and EXP2 are used by the Ultipanel later on, if you get one.

    (The analogue pins can also be used as digital outputs, something you might not guess from the name)


    OK, suppose I would use PWM 8 and 9, what would then be the corresponding M42 pin assignment? just P8 and P9?


    Yes, P8 and P9 would do the trick then. Small note about the PWM outputs, those can be PWM driven, not sure if the Arduino will do that or not, just be sure to use S0 and S255, no values in between to enable/disable the output.


  • Link to post
    Share on other sites

    Posted · enable output pin when print finished and get an email.

    It may be worth pointing out that Marlin defines some pins as sensitive and won't allow you to change their value with M42. The default list of sensitive pins is something like this:

    0, 1,






    analogInputToDigitalPin( TEMP_0_PIN),

    analogInputToDigitalPin( TEMP_1_PIN),

    analogInputToDigitalPin( TEMP2_PIN),

    analogInputToDigitalPin( TEMP_BED_PIN),

    (E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN; if dual extrusion enabled )

    which for me translates to

    0, 1,

    25, 23, 27, 22, 24,

    31, 33, 29, 26, 28,

    37, 39, 35, 30, 32,

    12, 4, 7,

    43, 45, 41, 2,

    ((8 < 16) ? (8) + 54 : -1), ((9 < 16) ? (9) + 54 : -1), ((-1 < 16) ? (-1) + 54 : -1), ((10 < 16) ? (10) + 54 : -1)

    (49, 47, 48, 3, if dual extrusion enabled)

    The reason your code wont work is P4 is by default the HEATER_BED_PIN which is sensitive.


    @Daid: TEMP2_PIN defined to -1 doesn't play well with analogInputToDigitalPin(). Pin 53 is protected unintentionally. Perhaps use,

    #define alt_analogInputToDigitalPin(p) ( ((p) < 16) ? ( ((p) >= 0 ) ? (p) + 54 : -1 ) : -1 )


  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    • Our picks

      • Here it is. The new UltiMaker S7
        The UltiMaker S7 is built on the success of the UltiMaker S5 and its design decisions were heavily based on feedback from customers.
        So what’s new?
        The obvious change is the S7’s height. It now includes an integrated Air Manager. This filters the exhaust air of every print and also improves build temperature stability. To further enclose the build chamber the S7 only has one magnetically latched door.
        The build stack has also been completely redesigned. A PEI-coated flexible steel build plate makes a big difference to productivity. Not only do you not need tools to pop a printed part off. But we also don’t recommend using or adhesion structures for UltiMaker materials (except PC, because...it’s PC). Along with that, 4 pins and 25 magnets make it easy to replace the flex plate perfectly – even with one hand.
        The re-engineered print head has an inductive sensor which reduces noise when probing the build plate. This effectively makes it much harder to not achieve a perfect first layer, improving overall print success. We also reversed the front fan direction (fewer plastic hairs, less maintenance), made the print core door magnets stronger, and add a sensor that helps avoid flooding.

        The UltiMaker S7 also includes quality of life improvements:
        Reliable bed tilt compensation (no more thumbscrews) 2.4 and 5 GHz Wi-Fi A 1080p camera (mounted higher for a better view) Compatibility with 280+ Marketplace materials Compatibility with S5 project files (no reslicing needed) And a whole lot more  
        Curious to see the S7 in action?
        We’re hosting a free tech demo on February 7.
        It will be live and you can ask any questions to our CTO, Miguel Calvo.
        Register here for the Webinar
          • Like
        • 10 replies
      • UltiMaker Cura 5.3.0-Alpha 🎄 Tree Support Spotlight 🎄
        Are you a fan of tree support, but dislike the removal process and the amount of filament it uses? Then we would like to invite you to try this special release of UltiMaker Cura. Brought to you by our special community contributor @thomasrahm
        We generated a special version of Cura 5.2 called 5.3.0 Alpha + Xmas. The only changes we introduced compared to UltiMaker Cura 5.2.1 are those which are needed for the new supports. So keep in mind, this is not a sneak peek for Cura 5.3 (there are some really cool new features coming up) but a spotlight release highlighting this new version of tree supports.  
          • Like
        • 16 replies
      • New here? Get ahead with a free onboarding course
        Often getting started is the most difficult part of any process. A good start sets you up for success and saves you time and energy that could be spent elsewhere. That is why we have a onboarding course ready for
        Ultimaker S5 Pro Bundle, Ultimaker S5, Ultimaker S3 Ultimaker 2+ Connect.   
        They're ready for you on the Ultimaker Academy platform. All you need to do to gain access is to register your product to gain free access. 
        Ready? Register your product here in just 60 seconds.
          • Like
        • 14 replies
    • Create New...