I'm working on a small project to monitor my electricity consumption at home. First the happy news: my electricity meter has serial port providing live data such as current power, then the sad news: the device isn't in my flat but in the basement, where there's neither an AC plug nor WLAN signal.
My approach so far is to power my Arduino UNO (a pretty old one) with a battery and store data in an SD card. Then I'd go to the basement once in a while (hopefully no more often than once a week) and get the data, charge the battery, etc.
Because of this constraints, I really want to pay attention to the power usage. I think I'll be using a 6xAAA battery holder, providing around 6V, which is something the Arduino should be happy with. The main doubt I have is how to fetch the data from the serial. The electricity meter sends data around once per second, which is way more often than reasonable for this pet project... I think one a minute is more than enough for my purposes.
I see two approaches here:
Read serial data, go to sleep for a minute and then read data again. The problem with this approach is that, after reading, the buffer will get full of data (irrelevant in a minute) until it starts overflowing, so I guess I'll have to clear the buffer before fetching fresh data.
Open serial, read data, close serial and go to sleep. Rinse and repeat. I'm not sure if this incurs in some extra power drain, or if this will clear the buffer between calls.
Thanks a lot in advance!
PS: I'm all ears to other suggestions regarding saving energy.
A couple of questions : is it just ouputting instantaneous demand (i.e. kW) or is it putting out consumption in the last time period (i.e kWh) ?
Either of those have some interesting issues - if it's power you'll need to capture all the values and then average them (but the less frequently you sample the more dodgy your data will be). If it is consumption then you have to capture the data for every time period and you'll need to interpolate any data you miss.
I suspect you can only address a certain size of SD, but if you only need data/time and value then that shouldnt suck up much space. If it was giving you all sorts of other data you wanted then It might be possible to do some form of compression on the data perhaps ? (I've not ever looked into that, tbh. )
It gives me both the "instant power" (W) and consumed energy (Wh)... plus a lot of other stuff.
Yes, it's true that instant power once a minute isn't ideal and should be averaged over some time but for sake of simplicity, I left it out in the question.
I'm not that versed in programming for constrained devices and I assumed the buffer gets filled independently from what happens in the microchip (I dunno, the UART thing runs on its own...or just magic).
So if I understand you well, when sleeping, the serial buffer doesn't receive any data, right? In that case I could just dump what's inside and then wait for fresh data.
Be sure to include a switch or other device to tell your program to close the SD file so you will have the WHOLE file to access when you want to look at the data.