Where to begin...
First, why are you using Flask for this? Flask is a web server.
Second, that's not all your code, so all people can do is speculate.
If you are going to let the sensor send data to your Pi, this will happen. They can't all talk to the Pi at the same time. Which leads to maybe you can poll each sensor to to get their data?
Better yet, unless you need as close to real time as possible, why don't you just have your sensors send data via MQTT and lat insert into the DB?
Also, if you sensors send their readings with a time stamp, It does not matter if you get a reading from sensor 1, then 2 readings from sensor 2 then another from sensor one. The data was taking at the time the sensor includes with the reading. You then order the data by that time stamp when you read it from the DB to use it and the result will be ordered by that.
And obviously, for any of this to even begin to make a difference as far as timing is concerned, all the sensors would need to have their clocks properly set so they have the right time, otherwise the time stamp reported by them will be off and it all goes out the window for that.
Lastly, why does it matter if you miss a reading or two here and there? Your data in the database can be interpreted over time, so missing 1 reading should not be an issue.
First, why are you using Flask for this? Flask is a web server.
Second, that's not all your code, so all people can do is speculate.
If you are going to let the sensor send data to your Pi, this will happen. They can't all talk to the Pi at the same time. Which leads to maybe you can poll each sensor to to get their data?
Better yet, unless you need as close to real time as possible, why don't you just have your sensors send data via MQTT and lat insert into the DB?
Also, if you sensors send their readings with a time stamp, It does not matter if you get a reading from sensor 1, then 2 readings from sensor 2 then another from sensor one. The data was taking at the time the sensor includes with the reading. You then order the data by that time stamp when you read it from the DB to use it and the result will be ordered by that.
And obviously, for any of this to even begin to make a difference as far as timing is concerned, all the sensors would need to have their clocks properly set so they have the right time, otherwise the time stamp reported by them will be off and it all goes out the window for that.
Lastly, why does it matter if you miss a reading or two here and there? Your data in the database can be interpreted over time, so missing 1 reading should not be an issue.
Statistics: Posted by memjr — Mon Jul 22, 2024 5:15 pm