Alternative means of measuring temperature Part 3

Continuing the discussion from Alternative means of measuring room temperature Part 2:

I’ve done a couple of items on measuring temperature. My final/next part is multiple DS18B20 sensors. I need 8 for my tank & water flow but the EmonTX which is close by, as standard, only takes 6. I did modify the sketch to take 8 but was finding it did not keep up with that and power within the 10s window.

I have sung the praises of ESPHome previously but I have to row some of that back. In the latest incarnation, the WiFi is horribly unreliable, so I went back to Tasmota. Using my favoured ESP8266 WEMOS D1, setting the sensors up was simple.

Because Tasmota sends all the data as a single JSON package, I needed to introduce a bit of node-red to read the data off MQTT, process it, then repost it for emoncms to pick up. In the process, I used the time element to fix the time of measurement (as sent by Tasmota).

However, I was still getting missed readings. On closer inspection, it seems Tasmota could not always send the data immediately, so then tended to send 2 quick fire readings. Because these were time stamped, it should not matter, but although Node-Red picked up the rapid messages off MQTT OK, EmonCMS could not do the same so messages were lost. The simple solution to this was to limit the posting out of Node-Red to EmonCMS.

The upshot of this is 100% reliable data collection @10s intervals for the last 2 weeks. I’m pretty pleased with that!

Node-Red flow (less MQTT sub/pub)

[{"id":"7beeb897.151088","type":"function","z":"c7cc9aa6.5f09f8","name":"Parse for Emoncms input","func":"var newmsg ={};\nvar data1 = msg.payload;\nvar data = {};\nvar dataout = {};\n//Remember to add timezone to date-time string\nvar newDateObj = new Date(msg.payload.Time);\n\ntimeObject = new Date(newDateObj.getTime());\n\ntimeObject = timeObject.getTime()/1000;\n\nnewmsg.time = timeObject;\n\ndata[data1['DS18B20-1']['Id']] = data1['DS18B20-1']['Temperature'];\ndata[data1['DS18B20-2']['Id']] = data1['DS18B20-2']['Temperature'];\ndata[data1['DS18B20-3']['Id']] = data1['DS18B20-3']['Temperature'];\ndata[data1['DS18B20-4']['Id']] = data1['DS18B20-4']['Temperature'];\ndata[data1['DS18B20-5']['Id']] = data1['DS18B20-5']['Temperature'];\ndata[data1['DS18B20-6']['Id']] = data1['DS18B20-6']['Temperature'];\ndata[data1['DS18B20-7']['Id']] = data1['DS18B20-7']['Temperature'];\n\ndataout['time'] = timeObject;\ndataout[`tank1`] = data['00000543A198'];\ndataout[`tank2`] = data['0000054462EC'];\ndataout[`tank3`] = data['00000543D4CA'];\ndataout[`tank4`] = data['000005442A16'];\ndataout[`tank5`] = data['00000543AF45'];\ndataout[`tank6`] = data['00000544489D'];\ndataout[`tank8`] = data['00000543D16F'];\n\nnewmsg.payload = dataout;\n\nreturn newmsg;","outputs":1,"noerr":0,"x":337,"y":398,"wires":[["80fef6e1.4051e8"]]},{"id":"b1487c0e.45848","type":"json","z":"c7cc9aa6.5f09f8","name":"","property":"payload","action":"","pretty":false,"x":232,"y":468,"wires":[["7beeb897.151088"]]},{"id":"80fef6e1.4051e8","type":"delay","z":"c7cc9aa6.5f09f8","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":476.5,"y":459,"wires":[["b3a6c19d.b34ec"]]}]

JSON data

	"Time": "2019-12-02T20:31:37",
	"DS18B20-1": {
		"Id": "00000543A198",
		"Temperature": 67.6
	"DS18B20-2": {
		"Id": "00000543AF45",
		"Temperature": 28.4
	"DS18B20-3": {
		"Id": "00000543D16F",
		"Temperature": 21.5
	"DS18B20-4": {
		"Id": "00000543D4CA",
		"Temperature": 39.6
	"DS18B20-5": {
		"Id": "000005442A16",
		"Temperature": 52.2
	"DS18B20-6": {
		"Id": "00000544489D",
		"Temperature": 38.1
	"DS18B20-7": {
		"Id": "0000054462EC",
		"Temperature": 59.8
	"DS18B20-8": {
		"Id": "000005446E5D",
		"Temperature": 85.0
	"TempUnit": "C"
1 Like