Hey there,
i have a esp32 with a DHT22 Sensor on it and let it send via mosquito in my node-red installation. Everything works fine so far.
Now I try to keep that data to visualise it via Grafana. I want to store it in an influx database/ bucket but I don't have any luck to find out how to do that.
Can someone help me here please, im pretty new to all that stuff and a bit lost right now.

Thanks in advance

Have a look at node-red-contrib- influxdb

thanks, I didn't tell clearly I have a connecting to influx (through the influx out node) and I also can see my topics there, but my values are not there, so something must be wrong with my data format.

Without knowing what structure you've set in your InfluxDB data, we cannot know the answer.

Have a search through the forum for an old post by me that recommends some settings and structures for storing sensor data (for home automation but it could be for anything). It shows some recommended ways of using tags and values.

True, sorry for the inconvenience.

msg.payload : Object
Time: "2023-11-16T18:04:41"
AM2301: object
Temperature: 19.8
Humidity: 59.9
DewPoint: 11.8
TempUnit: "C"

That's what I get as "pure" Data from my ESP / Sensor.
I googled couple hours now and couldn't find anything that`d help me how to format / handle my data.

I plugged the "influx-out" node directly to the Tasmota node and also tried to ask chat-gpt (with not really helpful results). Both attempts gave me just the keys in my bucket in influx but no value in it.
So im looking for someone to tell me how its usually done or where I can read it.

That would be the post I told you about.

How to effectively use InfluxDB - FAQs - Node-RED Forum (

1 Like

Thank you, but sorry I can’t see there either the syntax and/or the nodes I need to use.

In your post it’s necessary to know how sql databases work, what I neither know :face_with_peeking_eye:

Please, could you give me a closer hint

Click on the influx out node and then the little book tab in the right hand pane. That will tell you the valid formats for writing with that node. In addition the node's readme has a number of examples which should help. node-red-contrib-influxdb (node) - Node-RED

1 Like

And for those who have the same problem in the future, here’s the oh so simple solution.
Get a function node, put this in:

msg.payload = Number(msg.payload);
return msg;

In my case


Plug it to the influx out node and there you go!

I thought you wanted to save all the fields, not just temperature.

In fact, the temperature is already a number, so you don't the call to Number(). Which means you could just use a Change node to Move msg.payload.AM2301.Temperature To msg.payload.

I wanted first to understand how to save any value. If I could save them all together it’d be better I guess. But now I have something to start with.
I’d really appreciate if you could tell me how to do that.

When I gave influx the value without the number conversion, I get the error that it’s a string and no visualisation is possible.

Well in the debug you posted it is a number

Note how TempUnit has quotes around it identifying that it is a string. Connect a debug node showing what is going into your function and show us what it says.

For adding multiple values to a measurement, from the help text:
If msg.payload is an object containing multiple properties, the fields will be written to the measurement.
So if you want to write temperature, humidity and pressure you want the payload to contain

msg.payload : Object
Temperature: 19.8
Humidity: 59.9
DewPoint: 11.8

You can do that with a Change node configured like this


I suggest that whenever you are preparing data for influx (or any db) that, before connecting the influxdb out node, you first feed the data into a debug node and make sure it looks correct. As you have probably discovered it can be a pain getting rid of incorrectly formatted data in the db (string instead of number for example).

1 Like

I'd go further than that. I have a single output for my sensor data to InfluxDB and right before it, I have a function node that validates the inputs and refuses to post it unless it is correct (values are numbers and tags are strings).

Tasmota does have a InfluxDB driver that can dump your data directly into a bucket. Very handy, and cuts down the steps you have to take in node-red.

1 Like

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