Answer the question
In order to leave comments, you need to log in
How to collect information from multiple mqtt Node-Red nodes?
The existing scheme in Node-Red:
the db_query function is described as follows and only populates the database with the values of one node:
var newMsg = {payload : msg.payload};
newMsg.topic ="INSERT INTO `m2m`.`sens1` (`TEMP`) VALUES ("+newMsg.payload+")";
return newMsg;
select * from sens1;
+----+------+-------+-------+-----+---------------------+
| id | TEMP | HUMID | PRESS | AIR | date |
+----+------+-------+-------+-----+---------------------+
| 1 | 41.2 | 0 | 0 | 0 | 2016-11-15 22:08:54 |
+----+------+-------+-------+-----+---------------------+
1 row in set (0.00 sec)
Answer the question
In order to leave comments, you need to log in
As an option, use the global node-red space, that is, use either global.get/set or flow.get/set
nodered.org/docs/writing-functions (find the Flow context subheading)
You can put readings from these mqqt into this global variable blocks and do a check for filling them, as soon as they are filled, make an entry in the database and reset this global variable and everything will start over again.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question