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
};
influxMsgs.push(influxMsg);
}
}
return influxMsgs;
Here the InfluxDBout node: