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

      • 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
        • 11 replies
    • Create New...