This is the first tutorial I've made. I've been looking for something like this for about 8 months, I hope this saves someone some time. I could not have done this without the help of bakman2 on this forums group. All the code credit goes to them! Thank you bakman2!
Lastly, this flow was built by a newbie (me), when more a efficient way to do this inevitably noticed, please post suggestions. it would be great to get all of this in one node that just tells you what the temp is and can be downloaded from the pallet manager. Thank You All!!
to use a Max31865 Thermocouple amp in node red-
1- go to https://github.com/steve71/MAX31865
2- from the pi command line type git clone https://github.com/steve71/MAX31865.git
3- from that directory test with sudo python max31865.py
4- should get something like this-
config register byte: 90
RTD ADC Code: 8253
PT100 Resistance: 100.744629 ohms
Straight Line Approx. Temp: 1.906250 degC
-Van Dusen Temp (degC > 0): 1.905787 degC
high fault threshold: 32767
low fault threshold: 0or paste code here
5- If your temps are wrong but relative and working, edit the resistor line of code in the max31865.py file to equal the reference resistor on your board (Adafruit Max31865 is 430 ohms but your model may vary) sudo nano max31865.py
6- R_REF = 400.0 # Reference Resistor
CHANGE TO R_REF = 430.0 # Reference Resistor
7- install the node-red-contrib-pythonshell from the Node red pallet manager
8- Paste the path to max31865.py in the py file box of the python shell node/home/pi/MAX31865/max31865.py
9 - For output only temp in degrees C
10- Drop two function nodes between the python shell and debug
11- in the first paste this-
p = msg.payload
row = p.split(/\r?\n/)
output = {}
for(x=0;x<row.length-1;x++){
input = row[x].split(":")
key = input[0].replace(/[^a-zA-Z0-9 ]/g, '').trim().split(' ').join('_');
output[key] = parseFloat(input[1].trim());
}
return {payload:output};
12- in the second, paste this code
m = msg.payload.CallendarVan_Dusen_Temp_degC__0
return {payload:m}
13- Here is the exported flow. It will not work unless the python script is in the same place as the path in the python shell node.
[{"id":"c1550b64.bed1c","type":"pythonshell in","z":"26d5ce1.1340032","name":"Temp working rev 1","pyfile":"/home/pi/MAX31865/max31865.py","virtualenv":"","continuous":true,"stdInData":false,"x":316,"y":46,"wires":[["aebdb08e.58e3b"]]},{"id":"aebdb08e.58e3b","type":"function","z":"26d5ce1.1340032","name":"bakman2","func":"\np = msg.payload\nrow = p.split(/\\r?\\n/)\n\noutput = {}\n\n\nfor(x=0;x<row.length-1;x++){\n input = row[x].split(\":\")\n key = input[0].replace(/[^a-zA-Z0-9 ]/g, '').trim().split(' ').join('_');\n output[key] = parseFloat(input[1].trim()); \n}\n\nreturn {payload:output};","outputs":1,"noerr":0,"x":491,"y":46,"wires":[["5dd82bec.45771c"]],"info":"This separates the string of info from the MAX31862 pything code into usable objects"},{"id":"5dd82bec.45771c","type":"function","z":"26d5ce1.1340032","name":"stripper","func":"m = msg.payload.CallendarVan_Dusen_Temp_degC__0\nreturn {payload:m}","outputs":1,"noerr":0,"x":635,"y":46,"wires":[["b64f1cba.ae6908"]]},{"id":"b64f1cba.ae6908","type":"debug","z":"26d5ce1.1340032","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":788,"y":46,"wires":[]},{"id":"2765eb81.6494bc","type":"inject","z":"26d5ce1.1340032","name":"","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":107,"y":43,"wires":[["c1550b64.bed1c"]]}]