LED Stripe showing heater temperature



  • Hello everybody,

    I want to add an LED stripe to my printer which is showing the temperature of the active nozzle.
    For example if the nozzle is cold it should be blue if the nozzle has reached the temp it should be red.

    Can I send M42 P13 S220 to send the PWM value 220 (220°C) to heater4 pin and read it out on an arduino which is controlling my LED stripe? Would this work?

    If this works I need to do this automatically every second, and the parameter Sxxx should be the actual temperature how can I do this???

    I hope anybody could help me to do this.

    kind regards

    danny_v1



  • @danny_v1

    If you only need to know the whether it has reached that temperature, couldn’t you set yourself up a spdt relay and use a thermostatically driven fan output to drive it with the state change being the set temperature. When it is below say 220 degrees the relay coil is not energised and it is lighting the blue leds and when it is energised it switches and the blue led’s go out and the red ones are lit.

    Sam



  • You will need to crate a custom controller that can interface with the Duet to get this control - it is not natively supported.

    How you would go about doing it, depends on what you have, that is already connected. The Duet can only send and receive this type of data via a UART serial connection, of which 2 are available (USB and the PanelDue connector).

    If you do not have a PanelDue connected, you can use a standard Arduino (preferably a 3.3V one, otherwise you will need to step it down to 3.3V) which sends a Gcode command over the Serial UART connection. The easiest one you can use is M105 (https://duet3d.dozuki.com/Wiki/Gcode#Section_M105_Get_Extruder_Temperature; returning something like "T:240.0 /240.0 T0:240.0 /240.0 B:50.2 /50.0") or M408 (https://duet3d.dozuki.com/Wiki/Gcode#Section_M408_Report_JSON_style_response) if you want even more details in JSON format.

    If you do have the PanelDue connected, you will need to use it over USB, but this is where it gets more difficult. Standard Arduino boards is not USB Host, they are USB Client. The Duet is also a USB Client and thus you need somethings with USB Host. Possibly the easiest would be to use a RaspberryPi, connect it via USB to the Duet and write a small program that connects to the Duet and send the above mentioned commands at regular intervals, interpret the result and drive transistors for the different colours in your strip.



  • Thanks for your answers.

    I have connected a PanelDue so the first possibility is not a solution for me.

    Is there no way to put out the actual temperature to a not used pwm output on the expansion connector, cause the duet knows this value and then I could read out this pwm signal with an arduino, which controls the LED stripe.



  • You can also do it via the network. Query the rr_status of your Duet and update the LEDs accordingly.



  • The problem would be how would you send the correct temperature for the PWM. The only way to get the temperature with stock firmware, is via the UART ports or injected in Gcode. Making it occur regularly with injected code (for example in the printed file), is very difficult.

    Regarding the PanelDue, if I remember correctly there is a separate firmware that is being developed that would use different background colors for the different temperatures - it is mentioned somewhere in this forum.



  • @tomasf said in LED Stripe showing heater temperature:

    You can also do it via the network. Query the rr_status of your Duet and update the LEDs accordingly.

    I second this, it's quite easy to poll status type 1 and extract temperature with an ESP8266 and it can be done very fast.



  • @tomasf This sounds like a good solution, can you explain how to do this???



  • @danny_v1 said in LED Stripe showing heater temperature:

    @tomasf This sounds like a good solution, can you explain how to do this???

    @danny_v1 you can go to my page here and use the code to dump either status 1 or 2, both include temperature. If you use my code you may need to change the temperature to float in the JSON parsing area since it was created as an int due to the value I gave the JSON assistant otherwise you aren't getting anything after the decimal.



  • @tjb1 Thank you this looks like everything I needed. I so will order an ESP and test your code.
    If this works for me then I can also use an APA102 stripe to show something more like the position of the extruder and so on. This looks really great.

    Thank you very much!



  • I'd put my vote in for an ESP8266 as well. I have some pushbuttons with RGB led's in them and I use an ESP8266 to control the color of the buttons by polling the Duet for status. Works great.



  • Using an arduino to control a couple of LEDs is overkill, don't you think?

    Maybe if you had a bunch of other functions that the Arduino was doing, that would be another matter, but for a simple red/blue LED switch, it's a little...

    I'll usually watch the LED on-board, because that tells a story. If the heater LED is on, then I assume that the Duet wants the heater to be hotter than it is. When it turns off, it has reached temperature. Of course it will cycle on and off while it maintains temperature.

    Personally, I'd probably be tempted to insert the Arduino between the Duet and the PanelDue, have it intercept the serial communication between the two (Panel Due sends M408 S4, Duet responds with a JSON dataset, which includes things like the bed and heater temperature, then just pass on the information. you internally parse the JSON dataset, and do what you want with the information. your Arduino will need two UARTS to do this, one to talk to the Duet and another to talk to the PanelDue. It should appear invisible to both units, taking all data from the one and passing it to the other. Maybe you can use a single UART to tie it in in parallel, only monitoring the duet's output. you'll need to do some creative guessing to try figuring out what the PanelDue is asking for, but you can probably look for the JSON pattern that signifies the M408 response from the PanelDue and ignore other input.

    This will give your Arduino a lot of information, like temperature, tool coordinates, homed status. (An example of an M408 S4 response:

    {"status":"O","coords":{"axesHomed":[0,0,0],"xyz":[0.000,0.000,0.000],"machine":[0.000,0.000,0.000],"extr":[0.0]},"speeds":{"requested":0.0,"top":0.0},"currentTool":-1,"params":{"atxPower":0,"fanPercent":[30,100,100,0,0,0,0,0,0],"speedFactor":100.0,"extrFactors":[100.0],"babystep":0.000},"sensors":{"probeValue":0,"fanRPM":0},"temps":{"bed":{"current":2000.0,"active":0.0,"state":0,"heater":0},"current":[2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0],"state":[0,0,0,0,0,0,0,0],"tools":{"active":[[0.0]],"standby":[[0.0]]},"extra":[{"name":"MCU","temp":37.3}]},"time":313.0,"currentLayer":0,"currentLayerTime":0.0,"extrRaw":[0.0],"fractionPrinted":0.0,"filePosition":0,"firstLayerDuration":0.0,"firstLayerHeight":0.00,"printDuration":0.0,"warmUpDuration":0.0,"timesLeft":{"file":0.0,"filament":0.0,"layer":0.0}}

    So some other things that you can grab from this are things like the CPU temperature (Mine is apparently about 37 deg C right now), which you can use to control a cooling fan. This Duet is reporting 2000 deg for all heaters because there are no sensors actually connected to it. I'm actually using it developing/testing an interface using the PanelDue port to talk to a Raspberry Pi which will do most of the things that the PanelDue can do, plus some additional things that I want it to do (Like control a cooling fan.)

    Note that this will not only give you the current temperature, but also the active and standby temperatures, the current selected tool, plus the state which tells you what the Duet is supposedly aiming for. You can then have 3 lights (Blue for current tool temperature + 3 < active/standby temperature, green for current tool temperature within 3 degrees of target, red for current tool temperature > target temperature + 3) Or whatever else you can imagine.

    I think that this is probably the best solution to get the information that you want. You'll need to be sure to be constantly passing the information between the two boards back and forth to each other, and your Arduino may need level shifting (Depending on which Arduino you use) to get 3.3V on the UART instead of 5V, but the end result will get you the information that you want. (You won't even have to ask for the information, since the PanelDue will do it for you.)



  • @supraguy Yes just switching leds would be an overkill.

    But when I want to control an APA102 it would be ok with an arduino nano.
    The temperature would just be something to start with.

    Are there no problems when I grab the UART from the DuetWifi to the PanelDue with an Y-Connector for the URXD0 and UTXD0?



  • @danny_v1 There should be nop problems whatsoever grabbing those with the Arduino, though I would ONLY take the signal ground and the UTXD0. I would not connect the UTXD0 pin to your Arduino, unless you're going to try to inject code into the Duet that you can't accomplish with data pins.

    The Arduino nano is a 5V UART. It may work receiving data from the 3.3V UTXD0, but if you connect the Nano's 5V TXD0 to the Duet's URXD0 pin, you may damage the Duet. you can try reading data, but i it's garbled, use of a level shifter may be required.



  • @tjb1 said in LED Stripe showing heater temperature:

    @danny_v1 said in LED Stripe showing heater temperature:

    @tomasf This sounds like a good solution, can you explain how to do this???

    @danny_v1 you can go to my page here and use the code to dump either status 1 or 2, both include temperature. If you use my code you may need to change the temperature to float in the JSON parsing area since it was created as an int due to the value I gave the JSON assistant otherwise you aren't getting anything after the decimal.

    I tried your code but I could not translate it in arduino IDE.
    It says:

    47: error: 'DynamicJsonBuffer' was not declared in this scope



  • @danny_v1 said in LED Stripe showing heater temperature:

    @tjb1 said in LED Stripe showing heater temperature:

    @danny_v1 said in LED Stripe showing heater temperature:

    @tomasf This sounds like a good solution, can you explain how to do this???

    @danny_v1 you can go to my page here and use the code to dump either status 1 or 2, both include temperature. If you use my code you may need to change the temperature to float in the JSON parsing area since it was created as an int due to the value I gave the JSON assistant otherwise you aren't getting anything after the decimal.

    I tried your code but I could not translate it in arduino IDE.
    It says:

    47: error: 'DynamicJsonBuffer' was not declared in this scope

    You need to use version 5 of ArduinoJSON, not the 6 beta.


 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.