Jump to content

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

      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
      • Ultimaker Cura 5.6 stable released
        Cura now supports Method series printers!
        A year after the merger of Ultimaker and MakerBotQQ, we have unlocked the ability for users of our Method series printers to slice files using UltiMaker Cura. As of this release, users can find profiles for our Method and Method XL printers, as well as material profiles for ABS-R, ABS-CF, and RapidRinse. Meaning it’s now possible to use either Cura or the existing cloud-slicing software CloudPrint when printing with these printers or materials
        • 48 replies
    • Create New...