Hello, I am working on a project and I have to be using ESP8266-01(first time to use it) to read data from an Xbee S2C module. I want to know how can I keep reading the data received by ESP8266 and save assign them to display them later on a webpage. Also, can I set a certain time for receiving data?
Thank you in advance,
You can save datas to variables, or to SPIFFS or you can emulate 512 bits of EEPROM from it.
EEPROM and SPIFFS is ROM type of memory. That means, datas in that memory will be available after you plug off and plug in power (power-on-cycle).
SPIFFS and EEPROM can be rewrited like 10 000 to 100 000 times. Global variables are running in RAM memory. About timing actions (like read datas from xbee each 10 seconds), you can use millis() function that will do that timing. For instance: https://www.arduino.cc/en/Tutorial/BuiltInExamples/BlinkWithoutDelay
So, now u know how to save datas. Now you can read them and display them on HTTP webpage in webserver mode of your ESP8266
The question is how much data and how long do you want to be able to display them?
For short amount of times you can just store the data in RAM.
For small amounts of data for medium term you can store the data locally. Using internal flash is possible but should only be done when you are sure you will not exceed the write cycle of the internal flash. Otherwise you can use external memory via SPI interface for instance EEPROM, FRAM ... or SD cards.
If you want to collect the data for a long time and do analysis on them, you can use a database to store the data. I have the following test system running for more than a year and many different nodes.
Raspberry Pi
- Mosquitto MQTT broker (all sensors send messages to the MQTT broker with data)
- Node-RED a programming tool to wire the nodes together (graphical programming with Javascript, already part of Raspberry Pi OS/Raspbian)
- Node-RED dashboard to display the data
- influxdb a time-series database (automatically assigns time to data received, very flexible, easy to use, Node-RED support, easy filtering and query of the data)
For all of this you can find many examples and tutorials online. It is fairly easy, you can learn a lot and have fun.