Temperature with MAX31855

Hi Everyone,

I currently have a problem that seems to have been addressed here more often in the forum.

I would like to read the temperature of a type-K thermocouple using a MAX31855 and a Raspberry.

Unfortunately there is only one node for the MAX31865.

Is there a simple solution for this?

Thank you

Does that one not work then?

Unfortunately no,
I have tested it but it is only for the pt100/1000 thermometer.
As i want to use a Typ-K thermocouple this doesnt work

Oh, I see what you mean, that is for 31865 and you want 31855.
How are you proposing to connect to the chip?

hope it is ok to post this link.

Iam trying now to use the described way in the document.
As soon as it comes to the software it is difficult for me because I have little knowledge of programming. Therefore, I had the hope that it is somehow possible with nodered.

If the board has a python library then it may well be that the best way to access it from node-red is via the python library, so get that going first then ask again and someone will help you get it from there into node-red, probably via MQTT.

Thank you so far,
I have now made it so that it works using the python library. So with the help of the python function, the temperature is raised.

Unfortunately I do not know how to work with MQTT. Is this the only way to transfer the information to Node Red?

What does your python s/w do? If you run it in a terminal does it display the temperature and exit?

How often do you need to read the temperature?

import time
import board
import digitalio
import adafruit_max31855

spi = board.SPI()
cs = digitalio.DigitalInOut(board.D5)

max31855 = adafruit_max31855.MAX31855(spi, cs)
while True:
    tempC = max31855.temperature
    tempF = tempC * 9 / 5 + 32
    print("Temperature: {} C {} F ".format(tempC, tempF))
    time.sleep(2.0)

as you see i get the temperature in °C and F. At the moment i get it every 2 seconds

You could run that in an Exec node, set to Output while the command is running and you should get the values appearing in messages on the output. I suggest amending the python so it only sends the number though, otherwise you will have to strip off the extra bits in node-red. In the command use the full path to python (probably /usr/bin/python) and also the full path to your script. I think you also need to tell python to use unbuffered mode, which means including -u in the command.

Unfortunately, I have not been able to do much lately, but I am not getting anywhere. Could you describe your execution in more detail? Because the Python programming does not work in Node Red. Means I send the data via MQTT and take it back up in Node Red and work with the exec Node?
Thank you

Why not?

You have two options (probably more).

  1. Get the python program running in node-red. You have not said what the problem is.
  2. Run it as a separate process, outside of node-red, communicating with node-red via MQTT. Then you do not need an exec node at all. See this for an excellent introduction to MQTT MQTT Essentials - All Core Concepts Explained

I tried it first simply with the python function node. I suspect that this do not has access to the pyhton library i installed?

To be honest i dont knoe how to handle the exec node. It would be great if it could work without MQTT. Could you give me a short example with the exec node?

Does your python program run from the CLI on your pi?
If so, have you modified it to work with MQTT?

If the answer to both of those is YES, then you can use an mqtt-in node in your flow to subscribe to the topic the python program is publishing to.

If you don't know how to use MQTT with python, there are lots of tutorials out there (google 'python mqtt tutorial) and here is one of them:

Initially all you should have to do is to put the command you run from the command line into an exec node, but specify the full path the the python command and also the full path to the python file. Add debug nodes on all outputs of the exec node, give them names so you can tell which output is which, and set them Output Complete Message and see what happens. Maybe a good idea to initially modify the python to just run once rather than looping.

However, it really would be better to use MQTT, you will not regret the few hours needed to understand and use MQTT. Particularly if you intend to keep using node-red.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.