Power outages and data recording

I guess this is a feature or preference request. I have my iotawatt plugged into a UPS. (for the USB power supply, not the reference) If the power goes out, I get a single odd power sample as the power comes back online. (This was covered in “Odd power sampling on power- ?

After the one odd sample the rest is fine.

Not sure I’ve got any real justification for this, other than zero is a number and should be sampled as such. Makes for a cleaner graph during power outages and when switching to local generator power.

BTW, somewhat new to the system, but finding it to be awesome.

The post that you referenced is very old, and that user probably didn’t have a UPS power supply. The low measure on restart has been fixed for that case. Your case is different because of the UPS. It will continue to log throughout the outage.

While it may seem that simply removing the voltage reference should just make everything zero, it’s a lot more complicated than that. IoTaWatt does everything with a single processor. At the lowest level, it does this:

  • Sample an AC cycle (16.67ms for 60Hz)
  • Check for a webserver request
  • Run any dispatchable Service (log data, update history, run uploaders, timer check, update check, etc.)
  • Go back and sample another AC cycle.

It tries to do all of the ancillary work in half of an AC cycle (8.33 ms at 60 Hz). This basic rhythm is how IoTaWatt manages to accurately monitor 15 channels and do all of the other things that it does.

What may not be entirely clear is that the AC cycle is fundamental to the architecture of the device. It is the IoTaWatt’s heartbeat. When you take that away, things don’t work very well. I’ve tried to make it a non-fatal event, but providing for continued operation without an AC reference is not a priority at all. After all, the IoTaWatt measures AC power, which cannot exist without voltage.

The emphasis is more on restarting in a timely way when power is resumed. To that end various strategies have been put in place:

  • The datalog has been continually developed to withstand power failures. Corrupted datal;og due to power failure is almost nonexistent.

  • Restart takes less than two seconds and the first datalog entry will occur no more than five seconds after restart.

  • IoTaWatt has a battery backup real-time-clock so that when it wakes up, it knows immediately what time it is.

So the strategy for handling power failures is to go with it, not against it. With a UPS, while the AC reference is out, the sampling routines continually time-out because there is no AC signal. There is no good way to know that AC power is out, and to monitor for resumption. The algorithms assume that when when AC power is removed, the device will power-fail.