Setup ds18b20 temp sensor to webpage

#1

Is there an easy way to show temperature from a ds18b20 sensor? Would eventually like to evolve into a general status page to check if things are on or off remotely, temperature, etc.

#2

do a search on the flows page using ds18b20. ther are at least 2 nodes.

#3

I’ve found the easiest and lowest-cost solution is to use ESP8266 devices like the Wemos D1 Mini coupled with ESP Easy firmware.
The firmware includes routines for the ds18b20 and MQTT, so you can publish readings to Node-Red very easily.
I have a number of these set-ups monitoring temperatures around my house, loft and garage.
The benefit is you can distribute these nodes around your house, rather than using a Raspberry Pi to operate the temp sensor.
Hope this helps.

#4

I can read the sensor easily but I can’t seem to find a way to show the data in a dashboard or web page.

#5

What have you tried so far?

#6

Found the below example but it’s not quite there. I don’t understand what has to be kept in tact for the http nodes to work correctly.

[{"id":"a9cb1a07.5634e8","type":"http in","name":"http in","url":"/random","method":"get","x":119,"y":322,"z":"4eb61250.b149ec","wires":[["e3dad59d.1c2528"]]},{"id":"1bb5a0d7.e44a5f","type":"template","name":"","template":"Hello Random - {{ payload }}","x":464.00006103515625,"y":316,"z":"4eb61250.b149ec","wires":[["88b41af8.774be8"]]},{"id":"88b41af8.774be8","type":"http response","name":"http response","x":617,"y":319.0000305175781,"z":"4eb61250.b149ec","wires":[]},{"id":"a664658.f599b98","type":"inject","name":"Inject1","topic":"Topic1","payload":"1,100","payloadType":"string","repeat":"","crontab":"","once":true,"x":129.00003051757812,"y":269,"z":"4eb61250.b149ec","wires":[["e3dad59d.1c2528"]]},{"id":"e3dad59d.1c2528","type":"function","name":"Random Fn","func":"if (msg.topic == \"Topic1\") {\n var words = msg.payload.split(\" \");\n var range = words[0];\n var minmax = range.split(\",\");\n var min = minmax[0];\n var max = minmax[1];\n var d = Math.round(min + (Math.random() * (max - min)));\n context.myValue = d+\"\";\n msg.payload = context.myValue;\n return [msg,null];\n} else {\n msg.payload = context.myValue||\"\";\n return [null,msg];\n}","outputs":"2","x":327,"y":272,"z":"4eb61250.b149ec","wires":[["fca8f92e.035708"],["1bb5a0d7.e44a5f"]]},{"id":"fca8f92e.035708","type":"debug","name":"Debug1","active":true,"console":"false","complete":"true","x":588.0000610351562,"y":256,"z":"4eb61250.b149ec","wires":[]}]

Thanks,
Adam

#7

When posting code, first start with three backtic’s - then paste your code, then use three more backtic’s. This will prevent the editor from changing the double quotes to smart quotes and inserting newline characters. If you don’t do that, no one can import your flow.

You can go back and edit your post to do that.

#8

What do you mean by

I don’t understand what has to be kept in tact for the http nodes to work correctly.

Does the example work?
What are you expecting it to do?
Are you expecting this to show up on the dashboard? (note: there is a ‘template’ node and a dashboard ‘template’ node)

#9

The easiest way to get started is probably to install the dashboard (node-red-dashboard) which will give you, for example, the text node that you can just send the value to and it will be displayed. In addition there are gauge nodes, chart nodes etc.

1 Like