Node-Red to InfluxDB

Hello all, I'm relatively new in programming and microcontrollers. I hope to find her some help for my project.
I want to read out a BME280 sensor (Temperature, humidity, pressure) with an ESP32. The ESP32 is serial connected with a Raspberry Pi 3B.
The sensor values should then be transfereved via Node-Red to InfluxDB. The values should also be displayed with Grafana.

I was able to configurate the InfluxDB server, it also gets data but shows errors. It would be nice to transform the string from the serial connection into separated Integer values (Temperature, humidity, pressure) that are readable by InfluxDB. Hope you have some advices or even a runnable code. I'm really struggling here.

Here the Flow:

Function 2 Code:

var data = msg.payload;

var patterns = {
    O1H: /O1H([0-9.]+)/,
    O1T: /O1T([0-9.]+)/,
    O1P: /O1P([0-9.]+)/,
    OCT: /OCT([0-9.]+)/,
    OCH: /OCH([0-9.]+)/,
    OCP: /OCP([0-9.]+)/,

var influxMsgs = [];

for (var key in patterns) {
    var match = data.match(patterns[key]);
    if (match) {
        var value = parseFloat(match[1]);
        var influxData = key + " value=" + value;
        var influxMsg = {
            topic: key, // Verwende den Key als Thema für InfluxDB
            payload: influxData

return influxMsgs; 

Here the InfluxDBout node:


The payload should be an object or array (not a string)

there are quite a few examples in the readme

and a lot of examples on the forum.

I appreciate you are new to programming, but you have already managed to convert the string to an object in function 1. I would branch out of function 1 and format the object(s) to the format you need for influx.

in fact, you may simply need to do this:

        var influxMsg = {
            topic: key, // Verwende den Key als Thema für InfluxDB
            payload: { [key]: value }

but I am far from an expert on influx.

Since you are receiving all the values at the same time you should send them all together to influx as named fields in a measurement. To do that you should build a msg.payload containing something similar to that seen in debug 3. You should be able to send that directly to influx, assuming those are the key names that you want.