NodeRED MQTT Multitopics send to Single Bucket of InfluxDB

@Colin Usually the DHT is connected via a data input pin on the ESP and serial data showing the Temp. and Hum. is sent via that input. The ESP will have a library installed in the software to interpret that signal. One pin, one device, so as many devices as there are pins available. ESP should then send data to MQTT vie whatever firmware is being used..

Or at least, that is the way I have done it in the past.

HTH

I have just realised my mistake. I was thinking of the Sonoff TH devices, which are quite different. Now it makes more sense.
With the DHT devices would the temperature and humidity normally come across together?

In most cases/software, I think so.

It is a simple device, but without seeing the format of the MQTT message from the ESP, or indeed, more information about the Sensor hardware/software/firmware we are just speculating. That is why I suggested MQTT Explorer to get a better idea of what is going on.

Thanks for help.
Your method of separating the Influx Out Nodes worked.
Yes I use ESP32 combined with DHT22.
And 2 mqtt topics are there.
Meaning 2 different MQTT IN nodes for 2 variables
(Temperature and Humidity).
Temp and Humidity are read separately. It is the norm.
Nezt we will try, 2 ESP32 machines on same infra.

How do you suggest we should address this mqtt topic issue?
2 InfluxDB nodes for 2 MQTT topics worked.
But is there any way to use 1 node for 2 MQTT topics. We intend to use multiole MQTT topics (2-4).
Across 80 ESP32 devices. Pointing to same InfluxDB instance.

Here is what I use to log values to various DBs. These various DBs store different parameters for different reasons. The Link In brings a formatted message with the data.

[{"id":"cf4a0627.2b0918","type":"link in","z":"215f1be9ab83682d","name":"","links":["57806943.2ec6f8"],"x":75,"y":200,"wires":[["3e7bcafb.7ec11e"]]},{"id":"42a1a605.960d58","type":"function","z":"215f1be9ab83682d","name":"String Object to InfluxDB Single","func":"let str1 = msg.payload.measurement;\ndelete msg.payload.measurement;\nlet str2 = msg.payload.timestamp;\ndelete msg.payload.timestamp;\nstr = msg.payload;\n\nvar str = JSON.stringify(str);\nstr = str.replace(/[\\\"]+/g, '');\nstr = str.replace(/[\\:]+/g, '=');\nstr = str.slice(1,-1);\n\nif ((str1 == \"temperature\") || (str1 == \"humidity\") || (str1 == \"Other\") || (str1 == \"bme680\")) {\n    msg.url = \"http://localhost:8086/write?db=logs&precision=s\";\n}\nif (str1 == \"slots\") {\n    msg.url = \"http://localhost:8086/write?db=energy&precision=ms\";\n}\nif ((str1 == \"power\")) {\n    msg.url = \"http://localhost:8086/write?db=pzem&precision=ms\";\n}\nif ((str1 == \"usageKWH\") || (str1 == \"costs\")) {\n    msg.url = \"http://localhost:8086/write?db=consumption&precision=ms\";\n}\nif (str1 == \"epexspot\") {\n    msg.url = \"http://localhost:8086/write?db=epexspot&precision=ms\";\n}\nif (str1 == \"meterConsumption\") {\n    msg.url = \"http://localhost:8086/write?db=meters&precision=s\";\n}\n\nmsg.payload = str1 + \" \" + str + \" \" + str2;\nmsg.str1 = str1;\n\nreturn {url:msg.url, payload:msg.payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":200,"wires":[["85962925.6e2ec8"]]},{"id":"85962925.6e2ec8","type":"http request","z":"215f1be9ab83682d","name":"POST logs.","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":650,"y":200,"wires":[["06dba7aa85161e05"]]},{"id":"3e7bcafb.7ec11e","type":"delay","z":"215f1be9ab83682d","name":"Rate limit","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":180,"y":200,"wires":[["42a1a605.960d58"]]},{"id":"b52ea062.b6cae","type":"debug","z":"215f1be9ab83682d","name":"OK","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":140,"wires":[]},{"id":"1c12dfdf.441648","type":"debug","z":"215f1be9ab83682d","name":"FAIL","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":260,"wires":[]},{"id":"ab225df.7ef652","type":"catch","z":"215f1be9ab83682d","name":"","scope":["85962925.6e2ec8"],"uncaught":false,"x":710,"y":240,"wires":[["1c12dfdf.441648","23b7dcf6.bf27f4"]]},{"id":"2977655d.e4260a","type":"complete","z":"215f1be9ab83682d","name":"","scope":["85962925.6e2ec8"],"uncaught":false,"x":730,"y":160,"wires":[["b52ea062.b6cae","694eba36.bb7d54"]]},{"id":"6e0a51de.4c33a","type":"comment","z":"215f1be9ab83682d","name":"Success","info":"","x":1000,"y":180,"wires":[]},{"id":"c3e38c1d.ef6fe8","type":"comment","z":"215f1be9ab83682d","name":"Fail","info":"","x":990,"y":220,"wires":[]},{"id":"06dba7aa85161e05","type":"debug","z":"215f1be9ab83682d","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":140,"wires":[]}]

You could also assemble all of the sensor readings into a single string and pass to a single database.
e.g.
return { payload: { measurement: "usageKWH", usekWh: usekWh, cost: cost, gfCost: gfCost, gfSave: gfSave, saving: saving, avIncPeak: avIncPeak, avExPeak: avExPeak, avPeak: avPeak, timestamp: plotTime } }; }

(I know the labels will not match up with yours.)

You need to show us the format of the messages you are getting, put some debug nodes in a semi working flow and show us some results. Until this is done, we are just guessing at what is going on. With our limited time resources, we can only guess for so long.

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