I have 4 flows
serial flow for my Arduino
JSON flow to format my data in JSON format
function flow to extract the data from my dht11 sensor
and finally debug flow
first i will show you the configuration of my flows
my sql database
the error message
my JSON flow
the output
help me please I thought that I will have had something like this in my database
"INSERT INTO sensordata (temperature,humidite) VALUES(20, 30);";
but i have
mysql> select *from sensordata ;
+--------+-----------+-------------+---------------------+
| idData | humidite | temperature | dateSensor |
+--------+-----------+-------------+---------------------+
| 2471 | undefined | undefined | 2021-01-01 16:24:23 |
| 2472 | undefined | undefined | 2021-01-01 16:24:24 |
+--------+-----------+-------------+---------------------+
Without knowing exactly what the input to the function node is I will have to guess.
It looks like you are trying to access fields which don't exist on the msg
object but can probably be found a level deeper in the msg.payload
object.
You can change the function node to:
msg.topic = "insert into sensordata(temperature,humidite) values('" + msg.payload.temperature + "','" + msg.payload.humidite + "')"
There is no need to attach the values to the msg
object as extra payload#
.