'Grafana has a problem with "string", needs "float" DHT22-ESP32-Mosquitto-NodeRED-InfluxDB-Grafana

I started setting up the above stack on my Pi 4B running Bullseye64. I mainly used this tutorial: https://randomnerdtutorials.com/esp32-mqtt-publish-dht11-dht22-arduino/ However, the instructions stop short of explaining how to display the data in Grafana. When I try a data query in Grafana v8.3.6 the Grafana query editor returns:

“InfluxDB Error: unsupported mean iterator type: query.stringInterruptIterator”

Here is the code from the ESP32 that publishes to Mosquitto V2.0.11:

uint16_t packetIdPub1 = mqttClient.publish(MQTT_PUB_TEMP, 1, true, String(temp).c_str());
uint16_t packetIdPub2 = mqttClient.publish(MQTT_PUB_HUM, 1, true, String(hum).c_str());

That appears in the Arduino serial monitor as:

Connected to MQTT.
Session present: 0
Publishing on topic esp32/dht/temperature at QoS 1, packetId: 1Message: 68.36
Publishing on topic esp32/dht/humidity at QoS 1, packetId 2: Message: 62.90
Publish acknowledged. packetId: 1
Publish acknowledged. packetId: 2*

Mosquito passes it on to Node-RED V2.2.1 via the MQTT input node and the IfluxDB output node,(InfluxDb V1.8.10) which debugs as:

2/17/2022, 10:03:50 AM node: ebfbf6e2aea5407d
esp32/dht/temperature : msg.payload : string[5]  "68.36"*

When I try a data query in Grafana it returns:

“InfluxDB Error: unsupported mean iterator type: strong textquery.stringInterruptIterator”

which, to my understanding means that Grafana is not able to graph the format “string” and instead requires format “float”

If I change the Grafana query in the SELECT field drop down, submenu AGGREGATORS from "median" to "count" I can see the DB entries in a table, so I know data is being written.

My question is,(assuming my understanding is correct...) How do I go about changing the data format from string to float before it is written to InfluxDB? Perhaps I need to add Telegraf between Node-red and InfluxDB?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source