Jump to content
Ultimaker Community of 3D Printing Experts
Sign in to follow this  

enable output pin when print finished and get an email.

Recommended Posts

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,



Share this post

Link to post
Share on other sites

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.


Share this post

Link to post
Share on other sites

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 )


Share this post

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
Sign in to follow this  

  • Our picks

    • How to 3D print with reinforced engineering materials
      Ultimaker is hosting a webinar where we explain how you can achieve and maintain a high print success rate using these new reinforced engineering materials. Learn from Ultimaker's Product Manager of Materials and top chemical engineer Bart van As how you can take your 3D printing to that next level.
      • 2 replies
    • "Back To The Future" using Generative Design & Investment Casting
      Designing for light-weight parts is becoming more important, and I’m a firm believer in the need to produce lighter weight, less over-engineered parts for the future. This is for sustainability reasons because we need to be using less raw materials and, in things like transportation, it impacts the energy usage of the product during it’s service life.
        • Like
      • 12 replies

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!