Iotawatt how to build the code

Congratulations for your hard work on IotaWatt, it is a very interesting tool.
I am going to use your project as a base, to measure the electric energy consumption in my home. I’ve been trying to compile the code, which is in Github, “Bump version to 02_02_27”, but I have not been successful. I’ve tried with PlatformIO and some errors come out. Do you have some written procedure?.

Sorry, I don’t have anything. I use VScode on Windows with the integrated platformio. Beyond that, it’s kind of a black box to me as well.

Thanks Bob for your soon answer. I have been creating some testing projects in VSCode with platformIO, and the tool creates several folders, between them “.vscode” folder. This folder is not in firmware folder that you are sharing. That´s why I was thinking that you were using Atom + platformio.

I’m compiling it with the arduino IDE.
You’ll have to install the esp8266 board (guide here) and install the required libs (it will give you an error pointing to the correct one).
Maybe you can try it that way?

I just tried compiling using VSCode + PIO in Linux, this combo also produces errors. The error I get is

Compiling .pioenvs/iotawatt/src/IotaWatt.ino.o
In file included from /home/slippy/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39:0,
from IotaWatt/IotaWatt.h:30,
from IotaWatt/GetFeedData.cpp:1:
/home/slippy/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T= char*; size_t = unsigned int]':
IotaWatt/GetFeedData.cpp:288:40:   required from here
/home/slippy/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClient.h:123:36: error: request for member 'available' in 'source', which is of non-class type 'char*'
size_t left = source.available();
/home/slippy/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClient.h:127:5: error: request for member 'read' in 'source', which is of non-class type 'char*', will_send);

Seems this is an error related to GetFeedData.cpp:288:

server.client().write(bufr, bufrPos+2);

I suspect there has been a change in recent espressif platform calls causing this issue. @overeasy, could you do a pio platform list to see which version od espressif8266 you have installed? If it is <1.4.0 , a ‘pio platform update’ will likely break your build also. :slight_smile:

See our guide to compiling using PlatfromIO, just change emonTx for IoTaWatt:

Well, there goes my theory. Now I have no idea what is going on. The instructions posted by Glyn are the standard pattern for platformio, git clone and pio run which is exactly as I have run.

The project has a .travis.yml defined, but i cant find where the output on is. Anyone have a link?

The current code will not compile with 1.4.0. It requires the -staged core. It compiles with one deprecation warning (fixed in one of my local branches). I muddled through installing the staged version a few months ago and don’t have a reliable procedure for you, but I believe it’s explained in the pio documentation.

I had to make some changes to the 1.4.0 version in order to work on the staged version, so it’s a one way trip. Right now I’m planning on switching to 2.4.0-rc2 which may involve more changes. It’s a big complicated source so there is some overhead in working with it.

Thats an important piece of information that would have been handy at the start of this thread.

The current platformio.ini is setup for doing this, but I had to modify it slightly, changing the platform= bit.

platform =
board = esp12e
framework = arduino
lib_deps = ${common.lib_deps}
upload_speed = 921600
monitor_baud = 115200

This now downloads everything and compiles for me by running:
pio run -e iotawatt_staging

Temporary situation. I’ve just changed to using feature/2.4.0-rc2 so the statement will change to:

platform =

You may want to sync up.

Thanks guys for the interest.
I am working on Windows 10. I am using VScode and PIO, platformio.ini file was updated with

platform = GitHub - platformio/platform-espressif8266: Espressif 8266: development platform for PlatformIO

it was executed:
$platformio platform install GitHub - platformio/platform-espressif8266: Espressif 8266: development platform for PlatformIO

$pio run -e iotawatt_staging

The above command shows the next error:

IotaWatt\eMonService.cpp:96:49: error: ‘max’ was not declared in this scope

I tried the procedure suggested by glyn “Firmware modification”, Atom+Platformio, but it showed the same error.

That’s an incompatibility. I’ll be merging a fix for that, but in the meantime just change the max to MAX (use the MAX macro defined in the Iotawatt.h file instead of the c++ max function)

Code was compiled, it only shows a warning:
IotaWatt\webServer.cpp:519:33: warning: ‘size_t WiFiClient::write(Stream&, size_t)’ is deprecated (declared at C:\users\admin.platformio\packages\[email protected]f7b\libraries\ESP8266WiFi\src/WiFiClient.h:55) [-Wdeprecated-declarations]
_client.write(dataFile, 1460);

That’s necessary on 1.4.0, but deprecated in 2.4.0 (and the staged). No harm at this point. Thefix will be to simply remove the 1440 buffer size parameter:


It is changed in one of my branches so it will be making it’s way into the master branch eventually.

Thank you for your help Bob, Philip, Glyn, promy, you are the best.

1 Like

Nice work @AG19

I’ve submitted a PR for the two fixes mentioned in this thread to make the current master branch compile:

I am trying to compile the code in the Arduino IDE but have hit the following errors and can’t find a solution (probably because I am learning as I go and not an expert). Any help appreciated.


"In file included from C:\Users\paulb\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39:0,
                 from sketch\IotaWatt.h:30,
                 from sketch\GetFeedData.cpp:1:
C:\Users\paulb\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = char*; size_t = unsigned int]':
sketch\GetFeedData.cpp:288:40:   required from here
C:\Users\paulb\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.h:123:36: error: request for member 'available' in 'source', which is of non-class type 'char*'
     size_t left = source.available();
C:\Users\paulb\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.h:127:5: error: request for member 'read' in 'source', which is of non-class type 'char*', will_send);
Multiple libraries were found for "SD.h"
 Used: C:\Users\paulb\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module)."

Haven’t tried to compile with Arduino IDE for some time now. Would have to go though the libraries and update the core used, which is tedious.
If you look at the platformio.ini file in the git, the required versions of several libraries are listed. Check that you have those in your Arduino library.

Also, the current source uses core 2.4.0-rc2, and your Arduino IDE would need to be using that as it also contains more libraries that may be different.

I would encourage you to just switch to platformio as these dependencies are automatically included as they change.

The ESP8266/ARDUINO core is a work in progress, and with a source as large as IoTaWatt, incompatabilities do occur with new releases. I am committed to fixing those as we move forward, but do not try to maintain backward compatibility with older libraries and cores.

Most of what you posted looks familiar from problems I have encountered during core upgrades.

Update. Changed typo on core to 2.4.0-rc2