# esp32-Tasmota-nodered-influx

**URL:** <https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932>\
**Category:** General\
**Created:** [16 November 2023 14:53 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932 "2023-11-16T14:53:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [16 November 2023 14:53 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/1 "2023-11-16T14:53:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 November 2023 15:35 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/2 "2023-11-16T15:35:40Z")

</div>

Have a look at node-red-contrib- influxdb

---

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [16 November 2023 15:38 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/3 "2023-11-16T15:38:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 November 2023 16:57 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/4 "2023-11-16T16:57:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [16 November 2023 17:11 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/5 "2023-11-16T17:11:43Z")

</div>

True, sorry for the inconvenience.

```auto
msg.payload : Object
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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 November 2023 17:20 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/6 "2023-11-16T17:20:02Z")

</div>

> [@eli5](#):
>
> where I can read it.

That would be the post I told you about.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 November 2023 17:21 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/7 "2023-11-16T17:21:42Z")

</div>

[How to effectively use InfluxDB - FAQs - Node-RED Forum (nodered.org)](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885/5)

---

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [16 November 2023 17:27 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/8 "2023-11-16T17:27:39Z")

</div>

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 🫣

Please, could you give me a closer hint

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 November 2023 09:40 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/9 "2023-11-17T09:40:52Z")

</div>

> [@eli5](#):
>
> I plugged the "influx-out" node directly to the Tasmota node

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](https://flows.nodered.org/node/node-red-contrib-influxdb)

---

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [17 November 2023 14:01 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/10 "2023-11-17T14:01:17Z")

</div>

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

> Number(msg.payload.AM2301.Temperature);

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 November 2023 14:38 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/11 "2023-11-17T14:38:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eli5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eli5/32/84913_2.png) [@eli5](https://discourse.nodered.org/u/eli5)\
**Post date:** [17 November 2023 14:55 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/12 "2023-11-17T14:55:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 November 2023 16:19 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/13 "2023-11-17T16:19:51Z")

</div>

> [@eli5](#):
>
> When I gave influx the value without the number conversion, I get the error that it’s a string

Well in the debug you posted it is a number

> [@eli5](#):
>
> ```auto
> Temperature: 19.8
> Humidity: 59.9
> DewPoint: 11.8
> TempUnit: "C"
> 
> ```

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

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

```

You can do that with a Change node configured like this

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/cea04a2805af1a61c211c55202e993e73266ba47.png)

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).

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 November 2023 20:51 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/14 "2023-11-17T20:51:31Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![pkkrusty](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@pkkrusty](https://discourse.nodered.org/u/pkkrusty)\
**Post date:** [18 November 2023 21:05 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/15 "2023-11-18T21:05:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 December 2023 21:06 UTC](https://discourse.nodered.org/t/esp32-tasmota-nodered-influx/82932/16 "2023-12-02T21:06:40Z")

</div>

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