jywarren / p5js-webjack-sensor

A demo of using Webjack with p5js to visualize sensor data
GNU General Public License v3.0
4 stars 0 forks source link

Store data in rotating log in EEPROM memory, and on startup, transmit it out #1

Open jywarren opened 5 years ago

jywarren commented 5 years ago

It could save a measurement every hour, to save space.

https://www.arduino.cc/en/Tutorial/EEPROMWrite

It could also output all the data quickly on startup (over serial) so that when it's plugged into a computer, you can press the reset button and get all the data out.

https://www.arduino.cc/en/Reference/EEPROM says:

The supported micro-controllers on the various Arduino and Genuino boards have different amounts of EEPROM: 1024 bytes on the ATmega328P, 512 bytes on the ATmega168 and ATmega8, 4 KB (4096 bytes) on the ATmega1280 and ATmega2560. The Arduino and Genuino 101 boards have an emulated EEPROM space of 1024 bytes.

jywarren commented 5 years ago

Eventually we could output over WebJack too! https://webjack.io

jywarren commented 5 years ago

We should:

  1. Use the first location to store the index of the last place we wrote data
  2. Use this example to write data into rotating positions: https://www.arduino.cc/en/Tutorial/EEPROMIteration
  3. Play out all the data, starting with the oldest, upon startup
jywarren commented 5 years ago

Notes on triggering every hour:

Here's a demo too:

#define TWELVE_HRS 43200000UL
unsigned long startTime;

setup()
{
  startTime = millis();
}

loop()
{
  if (millis() - startTime > TWELVE_HRS)
  {
    // Put your code that runs every 12 hours here

    startTime = millis();
  }
}

We should also maybe delay startup of the sensor by 5 seconds, so if it's solar powered, it doesn't turn on and off a lot when power is low (this needs breaking out as its own issue).