I noticed at some point the ATM90 started returning 0’s for the results.  The datasheet notes – in 4.1.3 TIMEOUT AND PROTECTION – : A read access to an invalid address returns all zero.  Hmmm…

Thanks To Those That Went Before

 Tisham Dhar quickly answered a question I had after debugging that pointed directly to what the problem was.  I want Tisham to be successful and believe he does quality work.  I highly recommend the ATM89e26 energy monitor kits.

Debug

Things I did to debug/fix:

  • Change the Energy DB model to have two tables, one for the readings, one for log information.  The log information will give a way for the firmware to let me know about events going on in the code that are worth looking at.  I added two events to the Arduino firmware: 1) Reset. 2) Boot.  I like having a way of informing me about events in the firmware.  I think sending simple mqtt messages is an easy-peezy way to do this.
  • Modified the Arduino code in EnergyMonitorStuff.h to check a reading and reset if all the values are 0.  If they are, reinitialize the ATM89.  I like having this in the code regardless.  
  if (sysStatus == 0 && voltage == 0.0 && current == 0.0 && pf == 0.0 && power == 0) {
    myEnergyMonitor_init();
    strcpy(energyReadingJSON,"{\"m\": \"Reset.\"}");
    return (energyReadingJSON);
  }

it also sets up a “Reset.” mqtt message for insertion into the EnergyMonitor.db database.  The other Info I currently collect is when the firmware boots:

void setup() {

  BlinkInSetupStart
  initStuff();
  BlinkInSetupEnd
  myMQTT_publish("{\"m\": \"Boot.\"}");
}
/********************************************************
   LOOP
 ********************************************************/
void loop() {
  BlinkInLoop
  char *json = myEnergyMonitor_getReadings();
  DEBUG_PRINT(F("JSON: ")); DEBUG_PRINTLN(json);
  DEBUG_PRINTLN(strlen(json));
  myMQTT_publish(json);
  delay(10000);  // take a reading every 10 seconds.
}

Restarts

The image is rather small.  It is a plot showing power readings (measuring our microwave).  The dots represent resets (upper) and reboots (lower).  For an ~ 15 hour time period, there were 56 resets and 6 reboots.

pi@raspberrypi:~/EnergyDB $ python infoquery.py

Readings: 2724 Resets: 0, Reboots: 0

 Shoot…I did not take a reading prior to “fixing” the challenge so there are no resets or reboots in the infoquery results.

Fix

The cause of the 56 resets and 6 reboots was noise from the power supply.

NewImage       NewImage

Instead of using a separate power source for the FeatherWing, I was using the 9V AC-AC transformer.  No resets/reboots happened when the FeatherWing was powered through the USB port.

Thoughts

Ideally, only one power supply is needed to handle both the FeatherWing as well as the 9V AC-AC power measurement requirements.  I want to explore the characteristics of the DC power being provided to the FeatherWing.  Is there something in the power circuit that could be fixed in order for the 9VAC in to 3.5VDC out to be smoother?  My first step here would be to check this out using a scope.

 

Well, there it is.  Challenge: a lot of reboots and resets.  Originally, I thought this might be because of that darn ATM90.  Nope.  Power supply.  Of course, after the debugging this makes TONS of sense.  I have enjoyed the results of testing for myself with convincing results.