Integrator output off by 1hr

I am using Integrator of the sum of the 3phases to record Export versus Import
IotaWatt version is 02_08_02
I compare Mains1 + Mains2+ Mains3 to
and the integ.neg (and .pos) are delayed by 1hr

I have also tried Export = (Mains1 + Mains2+ Mains3) max 0
but that results in an error in the config.txt file.

I’ve never seen it before, but looking at the code, I can see a way something like this could happen. I don’t know what could knock it out of sync, but I can see how it can stay that way once it happens. I think if you delete the integrator and recreate it will resolve the problem, but I’m interested in how this happened and if it is exactly one hour.

Can you post your recent message log, and also the CSV from the plot above?

This could possibly be an SDcard issue, how old is the unit?

iotamsgs.txt (13.0 KB)
I replaced the SD card about 2 months ago with a new one and replaced the RTC battery a few days ago when I noticed the problem.
At that time I deleted the integrator and re-created it, but it occured again two days later.

Here is the output from
Import_Export_Watts3Ph.csv (31.8 KB)

p.s. the log shows a lot of RTC adjusts. I saw these previously and so replaced the RTC battery a few days ago.

Can you upload your /IoTaWatt/iotamsgs.txt file to me in a PM please. Those RTC resets are of interest. Do you have a local time server in your network and/or any override of the time server?

Ok, I missed the message log link. Took a look and I hve no idea what is going on. Several things are off:

The RTC intermittently shows as not running. That would explain the adjustments every hour, and looks suspiciously like the reason for your integrator lag.

Also, your WiFi link is very weak. It should be around -70 or better.

What can you tell me about this unit’s history? Did it ever run properly? When and where did you buy it and what was the order number if from the stuff store? Is it by any chance a homemade unit?

Yes saw problems with the RTC and replaced the battery two days ago, before the latest problems.

The unit is mounted inside the metal meter box and connects to a wifi extender 2 meters away. I have another uC in the house that connects to the IoTaWatt to monitor the instaneous import/export. I also can look at the IoTaWatts webpage and graphs so while the connection may be a bit flaky it does work most of the time.

The unit was purchase from SmartGuys in Australia.
The SD card supplied would not format so I replaced it with a new one.

The unit did not seem to be programmed so I reprogrammed it via Arduino
using the code .zip on this page
The main difference is that V3.0.2 of ESP8266 was used, where as your build uses V2.4.0. The libraries were picked up from the IOPlatform build enviroment.

Other than that some #include <…h> references changed to #include “…h“ where the compiler complained the file could not be found. A dummy IoTaWatt.ino file was added to satisfy Arduino.
p.s. I there any reason the RTC should be so far out of sync after a disconnect/reconnect of the WiFi. Shouldn’t the battery keep the previous settings?

The problem with the SDcard is known. There was a bad batch of SDcards from the supplier. About 300 were shipped and most have been replaced. It was difficult to track down the units sold through SmartGuys. In any event, replacing the card is straightforward and I don’t believe has anything to do with your problem.

Reflashing with firmware compiled using the Arduino IDE on the other hand has a lot of potential to cause problems. Your firmware does not seem to be able to communicate effectively with the RTC.

I can’t really support that firmware as it’s out of my control. Assuming the version that you flashed still has the ability to upgrade itself, I would recommend that you install the official distribution of 02_08_02 using this manual procedure.

Then delete both datalogs and the integrator and recreate the integrator.

Ok did that update.
I could not delete the itoalog.log nor the histlog.log as got msg ERROR[403] Restricted File.

Tried deleting the Integrators by edit delete
and get msg
“Deleting the integration will delete the integration log. Clicked OK”
but it just comes back on refresh.

but msg log shows

9/04/23 14:24:16 Phase3int: Integration log Phase3int deleted.
9/04/23 14:24:16 Script: integration Phase3int not defined in script Export.
9/04/23 14:24:16 Script: integration Phase3int not defined in script Import.
9/04/23 14:27:44 Script: integration Phase3int not defined in script Export.
9/04/23 14:27:44 Script: integration Phase3int not defined in script Import.
9/04/23 14:33:03 Script: integration Phase3int not defined in script Export.
9/04/23 14:33:03 Script: integration Phase3int not defined in script Import.
9/04/23 14:33:31 Phase3int: Started
9/04/23 14:33:31 Phase3int: New log starting 09/03/23 14:33:30

And graphs are now zero for integ.pos and integ.neg for today and yesterday so I assume the log got deleted and recreated.
Will let you know in a couple of days how it goes.

Have been running for a few days now and the integrator output is now about 4.5 hrs delayed.
Here is the latest msg log
msgLogFile.txt (9.8 KB)

It appears that your RTC battery needs replacing. Also, the frequent restarts are probably caused by the very weak WiFi signal. I’d suggest replacing the battery again with a fresh one and improving the WiFi signal. You are using WiFi channel 10. Channels 1, 6 and 11 do not overlap bandwidth with other channels and are usually better. Physican placement of the AP and IoTaWatt may also be contributing.

According to the RTC data sheet the battery is only used when the RTC is not powered.
IoTaWatt is always powered in my case so the battery is not the problem (and was replaced with a new one a month ago)

So I am giving up on using the integator function as it is not reliable. Keeps loosing time.

While the WiFi is weak it works well enough for http requests from my external monitoring devices that are trying to use the integrator outputs. Also there are multiple RTC adjustment log messages without any interleaved loss of WiFi connection messages.

Let me know if you manage to resolve this issue.

Otherwise a great device, easy to configure and I am very please I installed it.

I am using it to detect excess solar production to use to heat my hot water tank and to keep track of the hot water kWhrs pre day. See my HotWater from Excess Solar project.
Low kWhrs means I need to manually turn on the hot water tank heater or switch back to OffPeak (Controlled Load) heating.

Thanks again for your great work.