I have a problem in the code, that is, when the data sensor is sent, the database is not given the data of the other two sensors, the idea was when one sensor stops and the other two continue to send the data but what stopped you should send a null to the database so that we can see that the sensor is in trouble
my command to the database is as follows:
var newmsg=new Date().toString();
msg.topic="INSERT INTO sensores VALUES ('"+ new Date().toString() +"','"+ msg.payload["ns=2;s=SensorIndutivo"].toFixed(1) +"','"+ msg.payload["ns=2;s=LM335"].toFixed(2) +"','"+ msg.payload["ns=2;s=LM35"].toFixed(2) +"')";
return msg;
my question is if there is a command in mysql that places the value of each sensor in a particular column
Please don't lose data when you are saving it by using toFixed(), it doesn't make any difference to the amount of space it takes in the database and you are losing information that might become useful at some point in the future. If you don't want to see the extra digits when it is displayed then the time to round it is when you display it.
For example, suppose at some time you wanted to do some statistical analysis of the data, the lost precision could well become important then.
To answer your question look up the mysql insert statement and you will quickly find the answer.
MySQL statement put all values of sensors in database, but if one sensor stops and does not send the data, the database does not receive the data of the other sensors in this case have more 2 sensors
i do not have a error, only the database not receive data if one sensor stops send data, the others sensors don't send the data to database, is necessary the 3 sensors works all the same time, and what i want is if one of them stops working the others 2 sensors should be send the data to database
So where in the flow does the problem arise? Are you sending a query to the database at all? If not why not? Put debug nodes in the flow to find where it stops.
The problem is the Join node that is expecting 3 messages to arrive before sending on the combined single message. If one of your sensors stops sending data, the Join node will sit waiting for it to arrive before sending anything on - so you don't get anything in the database.
Hopefully that clears up the root issue here.
I don't immediately have a suggestion for fixing that, other than changing the whole approach of your flow
Thanks for your response, is that my problem because the join expects 3 messages , if one of them stops, the Join waits until get the 3 messages, if i coud separate the array throught a function and them sending each value, but i think is not possible do that.
I used the tip of the timeout and when I turn off the sensor count meters, it in the database is so undefined, which is more or less what I wanted as shown in the figure as well as I took the toFixed following the advice, however I would like ask if there is a way to send eg a way to show that it is stopped, via text eg STOP?