I am creating a react app to graph real time data from sensors

Viewed 17

So what I am trying to do is create a react app that graphs real time data coming from IoT sensors giving me temperature, humidity and pressure. I would like the data to persist so you can log into the app and check a specific time/day/month etc.

So far I have created a web sockets server and connected to the receiver that is sending the data. I am receiving data and displaying it on three separate graphs. When I switch graphs or close the app I lose the previous data. What is the best way to persist and hold the data? Will setting up a redux store be enough to hold months of data? Or will I need to set up a database to hold all of it?

1 Answers

Setting up a Redux store will persist the data until the store is unmounted (eg, until you restart the app). You almost certainly want to set up a database in order to hold the information coming from your sensors. An example setup might be:

               read
    (Sensors) <----- [Logger]
                        | write
                        v        read            req
                     {Database} <----- [Server] <----- (Client)


Key:
(IO)
{DB}
[Your code]

Where you have a logging process that reads data from your sensors and writes it to the database, and a separate web server that reads from the database and returns it in a format appropriate for the client. Seperating them in this way allows you to make changes to the web server (or even move it) without interrupting the collection of data from your sensors.

Related