Posting to emoncms: IotaWatt keeps re-uploading whole history [Solved]

Dear all,

First of all, I want to mention that I’m a very enthousiastic owner of an IotaWatt energy monitor, which I use to monitor my electricity consumption and solar production at home (Belgium). It’s a first step in my commitment to reduce my carbon footprint and contribute to a sustainable world.

Recently I came upon an issue which can’t seem to solve on my own, and which has not yet been covered in the IotaWatt/Emoncms community.

During the night, my Wifi network is scheduled to shut down automatically and reappear in the morning. By consequence, Iotawatt cannot post data to Emoncms during the night. This is not a problem, as IotaWatt can upload the captured data during the day.

However, as soon as the IotaWatt reconnects to the Wifi network in the morning, it starts re-uploading the whole logging history (in my case, since August 2018).
As I understand from the IotaWatt firmware code on Github, IotaWatt should start posting from the last timeframe which was posted to EmonCMS before (HTTP response from EmonCMS contains the timestamp of the last posted datapoint). But this doesn’t happen.

As a temporary measure, to avoid re-uploading the whole history every day, I specified in the “webserver” settings of IotaWatt that history should be uploaded from 01-01-2019, but this doesn’t fundamentally solve the issue.

Extract from IotaWatt log:

** Restart **

SD initialized.
1/25/19 05:30:33z Real Time Clock is running. Unix time 1548394233
1/25/19 05:30:33z Version 02_03_20
1/25/19 05:30:33z Reset reason: Software/System restart
1/25/19 05:30:33z Trace: 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:3, 1:4, 1:1[5], 1:2[8], 9:0[8], 9:0, 9:1, 8:4, 8:6, 8:8, 8:9, 9:3, 9:5, 9:9, 1:2, 1:3, 1:4, 1:5[21]
1/25/19 05:30:33z ESP8266 ChipID: 6910673
1/25/19 05:30:33z SPIFFS mounted.
1/25/19 06:30:34 Local time zone: +1:00
1/25/19 06:30:34 device name: IotaWatt
1/25/19 06:30:34 MDNS responder started for hostname IotaWatt
1/25/19 06:30:34 LLMNR responder started for hostname IotaWatt
1/25/19 06:30:35 HTTP server started
1/25/19 06:30:35 timeSync: service started.
1/25/19 06:30:35 statService: started.
1/25/19 06:30:35 dataLog: service started.
1/25/19 06:30:36 dataLog: Last log entry 01/25/19 06:30:30
1/25/19 06:30:36 historyLog: service started.
1/25/19 06:30:37 historyLog: Last log entry 01/25/19 06:30:00
1/25/19 06:30:40 EmonService: started. url=(URL to my emoncms server), node=IotaWatt, interval=10
1/25/19 07:00:21 WiFi connected. SSID=(Wifi network SSID), IP=, channel=6, RSSI -62db
1/25/19 07:00:21 Updater: service started. Auto-update class is MAJOR
1/25/19 07:00:22 Updater: Invalid response from server. HTTPcode: 200
1/25/19 07:00:24 EmonService: Start posting at 01/01/19 00:00:10`

Can someone look into the problem together with me, as I don’t find the answer?
Thank you very much in advance.

It looks like you have a local instance of emoncms, could you describe that (Rpi or other platform).

First impression is that the query to read the time of last update isn’t working properly. Could you issue one from your browser and post the result?


Hi @overeasy,
thanks for your help.
I run emonCMS on my external webhosting space (at

I also looked a bit deeper into the issue with the API call. When I call this URL I get an error message, indicating that there would be an issue when evaluating “preg_replace” function in the emonCMS Input module (inputcontroller.php).

I found out that the issue is related to the PHP version I’m running on my webhosting space. I recently upgraded from PHP7.2 to PHP7.3. To verify, I downgraded to 7.2 now, and everything seems to be working again. After a restart of IotaWatt, the upload of data to emonCMS continues where it ended before the restart.

Conclusion: the issue was not at all related to IotaWatt firmware.
I posted an issue at the emoncms Github, to ensure that the emonCMS code will be made compatible with new PHP versions. (I’m not a PHP expert myself)

So, this issue can be closed. Thanks for your help!

1 Like

Thanks, but I’d like to know, what does that error look like? Does it come in with code 200?