Apologies for the complexity of this topic, but I need specific help and, perhaps, guidance as to the overall strategy. The general trajectory of this project is to collect sensor data from:
- ESP32 linked to sensors
- Zigbee sensors
and display the values eventually in Grafana. A Raspberry Pi 5 is being used to run Mosquitto, Node-Red and Influxdb, eventually Grafana further down the line.
The ESP32 Units are standalone and work well. I can publish data from controller ESP32’s to an on-board web server using AsyncWebServer.h library in Adrduino IDE / Platformio (depends on the size of the unit test project). The data is displayed in “Cards” and also charts using “Highcharts”. I’m very happy with that deployment.
Zigbee to MQTT is a separate unit for now and can be put into touch.
The data pathway vexing me for quite some days, okay, weeks, is the route in the title. I want to store more permanent data looking back over months rather than the time-limited window coded into the Async Webserver (about 30 mins, refreshed from t=0 with each new browser instance). Highcharts is a delight to use.
ESP32 → MQTT (solved) - I can prepare any format for the data including JSON should that be required. The data from a single sensor is published to MQTT at any frequency I choose.
I can use a public broker (EMQX) as well as a MQTT broker (Eclipse-Mosquitto) running on the Raspberry Pi. Currently Portainer, MQTT, Node-Red, Influxdb all installed in docker containers.
I can intercept data using MQTTX client with either server confirming data is getting through to that point.
Node-Red on the Raspberry Pi was an easy install and easy to get working. MQTT input nodes intercept topics correctly and a debug node displays the values correctly.
Currently the sensor data is sent from the ESP 32 to the MQTT as a comma-delimited packet:
- topic (string), value (string)
I’m pretty new to all of this (just a few weeks exposure to MQTT/Node-Red, etc., but the format isn’t a million miles away from what I understand to be JSON format. (Still much to learn there).
Node-Red MQTT-In node shows:
- 04/02/2024, 14:38:14node: debug 40
some_prefix/tempDHW_Flow : msg.payload : string[5]
“78.75”
An intermediate function node (change/replace) strips out the topic prefix to yield:
- 04/02/2024, 14:57:10node: debug 41
tempDHW_Flow : msg.payload : string[5]
“78.75”
An intermediate Change node transforms the value (as string) to a number:
- 04/02/2024, 15:02:19node: debug 42
tempDHW_Flow : msg.payload : number
78.75
I am happy that data gets through to Node-Red and that the Function and Change nodes work as anticipated. (those interventions seem logical to me, but…)
I have installed Influxdb and have followed various recipes/gists and can enter data manually and display the results in a graph. I’m happy that influxdb is working (I’ve tried to install Influxdb 1.8 as a precursor to upgrading to influx db 3 so I can use InfluxQL rather than Flux, but I seem always to get v2.7.5, but that’s a separate issue to be solved some other time).
Here’s the stumbling block. I cannot get data out of Node-Red and into Influxdb. This topic is either for the Node-red Community or Influxdb, but I am reluctant to duplicate the posts on both fora. So trying here first…
The final node is an Influx Out node. No data appears in the InfluxDb database. And beyond that I am quite lost as to what to try/resolve next.
This topic is already lengthy so I am happy to post more specific data about the nodes and/or Influxdb configuration upon request to help isolate the issue(s).
Thanks, Ric