Hi guys,
This is a concept question, not so much a specific question yet. I have fiddled around with both a current sensor (SCT-013) and a water flow sensor (https://www.adafruit.com/product/833). Meaning I have successfully set up an arduino to read their data and verified that it was "correct". (within error)
Now Im ready to have that data read periodically (maybe 1x every hour) and sent to a db or something in order to ensure continuity and persistence in case of a power out.
In the current code I do something like this:
So the value is stored in a local variable. Same as in my water meter code. In both cases the variables are written to the serial constantly. I know how to post the data to the web and stuff but if power goes out, the Arduino restarts but the data starts from zero again. So if I wanted to log water or power consumed the final data would be incorrect if power ever went out. How do I solve this issue?
This is a concept question, not so much a specific question yet. I have fiddled around with both a current sensor (SCT-013) and a water flow sensor (https://www.adafruit.com/product/833). Meaning I have successfully set up an arduino to read their data and verified that it was "correct". (within error)
Now Im ready to have that data read periodically (maybe 1x every hour) and sent to a db or something in order to ensure continuity and persistence in case of a power out.
In the current code I do something like this:
#include "EmonLib.h"
EnergyMonitor emon1;
char ssid[] = "myssid"; // your network SSID (name)
char password[] = "mypwd"; // your network key
void setup(){
Serial.begin(9600);
emon1.current(1, 111.1); // Current: input pin, calibration.111.1
}
void loop(){
double Irms = emon1.calcIrms(1480); // Calculate Irms only
Serial.print(Irms*120.0); // Apparent power - from 230 to 120
Serial.print(" ");
Serial.println(Irms); // Irms
}
EnergyMonitor emon1;
char ssid[] = "myssid"; // your network SSID (name)
char password[] = "mypwd"; // your network key
void setup(){
Serial.begin(9600);
emon1.current(1, 111.1); // Current: input pin, calibration.111.1
}
void loop(){
double Irms = emon1.calcIrms(1480); // Calculate Irms only
Serial.print(Irms*120.0); // Apparent power - from 230 to 120
Serial.print(" ");
Serial.println(Irms); // Irms
}
So the value is stored in a local variable. Same as in my water meter code. In both cases the variables are written to the serial constantly. I know how to post the data to the web and stuff but if power goes out, the Arduino restarts but the data starts from zero again. So if I wanted to log water or power consumed the final data would be incorrect if power ever went out. How do I solve this issue?