So I’ve got an Ultrasonic sensor that reads a water level and i’d like to have that data displayed on a graph on a webserver (it’s on http://185.96.166.200 (/, /time, /chart)).
Currently I’ve managed to make the webserver take the sensor data and use the Google Charts API to display the data (currently uses placeholder data).
The next thing that i have to figure out is storing that data for the chart to display. My board is a NodeMCU 1.0(ESP-12E) 4M and currently I’ve looked at the following solutions:
- Using a file on the SPIFFS file system on the NodeMCU board
- Using an array
- Using a LIFO stack to store the data
My problem is i can’t fully understand any of these solutions and I searched a lot, but I can’t really understand how to implement it.
So I could use a file and store the data in a text file, but the thing that I don’t understand is how I can make it delete the oldest data after it reaches (228 lines(every 5 minutes in 24 hours)) while still adding the newest number to the bottom. And the other thing is how I’ll be able to add all that data to the html that I store as a string in my program.
The next thing that I could use is an array, but the only thing i’d like to know is is there any way to move the start of an array, so that the program will start reading from the 2nd value there(and have that 2nd value indexed as 0, because I don’t want the array to be huge). At least with the array the adding to the html string will be easier.
The last solution I read about would be the stack, but I don’t have any experience with a stack, so I don’t understand much of it. LIFO would be really good, but the thing is the libraries I found StackArray and StackList, at least from what I understand there isn’t a way to read all the data without having to use the .pop method, but that’d erase that data and I don’t want that. Is there anywhere where I could read more about stacks and how to implement them for something like this?
So which of these 3 solutions would be the best suited for my case and also can you please explain how I could do what I mentioned I don’t know how to do using each of the 3 solutions?
I’ve attached my whole program. There I’ve currently been experimenting with the StackArray library, but I’m not really sure what to do
HelloServer.ino (6.33 KB)