Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | CRPS Treatment | | About Us
 

Forward Logo (image)      

IoTaWatt Real Time Electricity Cost and
how to reprogram and remove WiFi settings with the Arduino IDE

by Matthew Ford 13th January 2024 (originally posted 7th July 2023)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

IoTaWatt Real Time Electricity Cost and
Reprogramming with Arduino IDE

Update 13th January 2024 – IoTaWatt does not recover from transient power failures. Remove its USB power cable for 10 sec to reboot it.
Update 5th September 2023 – Added manual update to latest version

Introduction

IoTaWatt is an open source electricity monitoring system. This page covers reprogramming IoTaWatt using the Arduino IDE. You can use this to remove the configured WiFi settings. This page also describes a sample installation and how to display in real time the cost of your electricity usage/export. There are also some general comments on the device and its documentation.

The source code for IoTaWatt and pcb designs are available on https://github.com/boblemaire/IoTaWatt or you can purchase the pre-built hardware although supplies are variable. The system uses a NodeMCU 1.0 ESP-12E Esp8266 module. See https://github.com/boblemaire/IoTaWatt/tree/master/Hardware for the Eagle cad files. Here is a V5 parts list and some comments on replacement parts. V5 has inputs for 3 phase Voltage references. CT (current transformer) Inputs 13 and 14 are not available for use when using the 3phase Ref 13 and 14. A snapshot of the github files is here (as at 1st May 2023).

The source code is available from https://github.com/boblemaire/IoTaWatt/tree/master/Firmware and uses platformIO for the build. This page shows how to use the Arduino IDE instead. If you are not already using platformIO, the Arduino IDE is simpler to install and run and has the added advantage that you can select to clear WiFi settings when reprogramming. That should also be possible with PlatformIO but the platformio.ini is not setup to do that.

IoTaWatt Documentation

Use this documentation link for the latest docs (local copy of 02_03_20 here). The pre-compiled html and pdf downloadable versions are out of date. They are missing the section in Integrators (local copy of that section here)

Reprogramming using the Arduino IDE

The IoTaWatt unit used here was purchased from SmartGuys, as were the VT and CTs. The USB supply was purchased from Jaycar (MP3536). The IoTaWatt unit supplied needed to be programmed (see below).

The code from https://github.com/boblemaire/IoTaWatt/tree/master/Firmware needs a number of supporting libraries. PlatformIO automatically downloads these support libraries (to ...\Firmware\.pio\libdeps\iotawatt) as part of the build process. For the Arduino IDE build used here those libraries were copied to the Arduino libraries directory. The main source code was downloaded from https://github.com/boblemaire/IoTaWatt/tree/master/Firmware (Version 02_08_02) and the #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. A zip files of the Arduino code is here and its supporting libraries are here.

Step for Reprogramming IoTaWatt using the Arduino IDE

1) Install Arduino IDE V1.8.19 or later.
2) Install ESP8266 board support. Follow these instructions and install V2.6.3. Use the drop down “select version” list in the Arduino Board Manager to select it.
3) Unzip this libraries.zip to the Arduino sketches directory (C:\Users\....\Documents\Arduino on Windows) to get the
libraries directory with the support libraries.
4) Unzip this IotaWatt_02_08_02.zip to the Arduino sketches directory to get the IoTaWatt sketch directory.
5) Plug in the IoTaWatt with a USB cable and open the Arduino IDE
6) Select the NodeMCU 1.0 (ESP-12E Module)



7) Set the lwIP Variant to “v2 Higher Bandwidth”


8) Set Erase Flash: “All Flash Settings”

9) Set Flash Size “4M (FS:1MB OTA~1019KB)”

10) Select the Port: the IoTaWatt is connected to and select Sketch → Upload to reprogram the IoTaWatt

To complete the software installation, open the IoTaWatt case (4 screws) and remove and format the SD card using the SD card formatter. Then copy the contents of https://github.com/boblemaire/IoTaWatt/tree/master/SD directory (also in the snapshot of the github files) to the SD card. You may also want to replace the RTC battery CR1220 with a fresh one.

This will result in an installation that is close to the latest release.

Installing the latest PlatformIO complied version manually.

Once IoTaWatt has powered up and been connected to your WiFi network (See Connecting to WiFi in the docs), you can upload the latest PlatformIO compiled version using this manual process. (local pfd copy here)
The latest IoTaWatt bin is https://iotawatt.com/firmware/bin/02_08_02.bin (local copy here)

Installation

For the 240V 3Phase system here, a double power point was installed on each phase and a VT (voltage transformer) was plugged in to each to measure the voltage phase angle relative to that phase's current reading. You can set IoTaWatt to just use one VT for a 3Phase system and to artificially generate the other two phases, but this does not accurately determine the phase angle and power factor. If you have an air-conditioner or some other motor on one or more phases, you should use 3 VT's. Three CT's (current transformers) were installed on the incoming 3 phases from the smart meter and an additional CT (shown below) was installed on the Controlled Load (Off-Peak Hot Water) which is metered separately.

Watts versus VA versus VAR

Watts is the “real power”, VA is just the Volts x Amps, and VAR is the “reactive power”. The are related by the following triangle

from this NREL publication (local copy here)

Usually Watts is what you are interested in keeping track of.
“VAR is calculated by the Pythagorean theorem using Watts and VA. It should be accurate. VARh on the other hand is not very accurate when measured over long periods.” from IoTaWatt forum
Heaters / stoves hotplates etc have a Power Factor (PF) of ~1.0 and a VAR of ~0.0. Motors have a negative power factor and capacitive loads (long extension cables, TV's) have a positive power factor.

Notes About Output Units and Graphing

The documentation on Outputs does not explain about the choice of Units: for the Output being configured.

The choices are Watts, Volts, Amps, Hz, PF, VA, VAR, VARh.

For Ref Voltage Inputs, Input 0 (and 13, 14 for 3-phase installations), the only choices the make sense are Volts and Hz.

All the other inputs are Current transformers (CTs).
Note: Always plug the CT into the IoTaWatt module BEFORE clamping it around a power cable. Un-terminated CTs can generate high voltages.
Each of these CT inputs are associated with a Ref Voltage Input, which defaults to Input 0 for single Phase but can be specified for 3-phase installations.

For CT inputs:-
Watts uses the associated Ref Voltage to calculate the Watts for this current (including the power factor). This is what you usually want to see. See the Power Triangle above.
Volts just outputs the associated Ref Voltage RMS value
Amps output the RMS amps read by the CT
Hz just outputs the associated Ref Voltage frequency reading in cycles per second, Hz.
PF outputs the power factor for this current / ref Volts pair. See the Power Triangle above
VA outputs the RMS Current times the RMS Ref Volts, ignoring power factor. See the Power Triangle above
VAR outputs the Reactive Power. See the Power Triangle above.
VARh is VAR integrated over time. The reactive power version of Wh.

Note: For simple monitoring of an appliance/phase you can just plot the Input CT that is attached to the appliance/phase, see below. No Outputs are needed to be defined.

Inputs

If you don't have solar cells / batteries, then leave Allow Negative Power Value unticked for the CT inputs and IoTaWatt will automatically reverse the input if needed to get positive readings.
If you send power back to the mains then you need to tick
Allow Negative Power Value and check that the current/watts reads positive when you are drawing power from the mains.

Integrators

Integrators are used to separate exports from imports when you have solar cells/batteries. The mains CT should be set to Allow Negative Power Value.

Integrators take some time to calculated from past values once you add one. Once they are up to date you can create Outputs for the Imports (mains.pos) and Exports (mains.neg). If the results look incorrect versus the plain mains CT Watt hrs, just wait until the next day and then delete and recreate the Import / Export Outputs.

Data Exports

IoTaWatt can export the plot values as a CSV file. It also supports uploading the data to a number of services. See the docs.

How to get Wh (Watt Hrs)

Electricity if usually charged by the kWh. 1000 Watt hrs. 1 kWh equals 1000W used for 1hr or 100W used for 10hrs. IoTaWatt does not have Wh output unit. You have to use the graphs to show this value, see below.

kWh in the Original Graph

In the Original Graph open the Energy section and select the input (or output) you want to plot. The plot will show accumulated kWhrs.. The various sections, Voltage (Volts), Power (Watts) and Energy (Whrs) only show those inputs/outputs that make sense for that type of display. The Outputs section displays any other outputs you have defined whose units are not Volts or Watts

kWh in Graph+

In the Graph+ select Wh units and then select the input (or output) you want to plot. The plot will show the instantaneous Watt hrs.
As you select different units, only the available inputs / outputs that make sense for that unit choice, will be displayed.
Then at the bottom of the plot tick Accrue to get the accumulated Whrs.

IoTaWatt Page Errors

It is not un-common for IoTaWatt to return an error message when opening/updating a graph. Usually it self corrects in 10secs or so. If not try the Refresh button or reload the page or go back and reselect Graph+.
Sometimes after leaving the plot open for a 24hrs the IoTaWatt will stop responding to page refreshes or to navigation back to the main page, even though the plot was being updated. In that case just close the page and leave it for some time (30mins??) and try again. It recovered for me. If you cannot get a response after 1hr of closing the web browser, you can reboot the IoTaWatt by removing/switching off the USB supply for 10sec.

How to get Electricity Cost

You can use the calculator available for specifying Outputs to calculated the cumulative Electricity Cost for a day (or some other time period).

The trick is to create an Output of the total Watts and multiply that by the cost in cents per Watt hr. Then using the Graph+ plots, tick the accumulated option to get the approximate rising cost of Electricity over the day where the Wh's are actually the cents cost.

The above graph has the total Electricity (blue) as well as it components, Imported power (green), the Solar Export (yellow) and the Hot Water on a separate meter (red). An Integrator was added to the main supply measurement to separate out the positive (incoming/imported) Main power from the negative (outgoing/exported) Solar power.

Each of these components are charged at a different rate. The imported Mains power (30cents/kWh) is charged at more then 4 times the money received for the exported Solar power (7cents/kWh) and the Hot Water has another concessional charge rate (15cents/kWh). Note: The rates for these components are constant over the 24hrs. If your price of electricity varies with the time of day or the amount of power you are consuming then this approach to plotting the costs will not work.

For a single phase system and example Output calculation of the total Electricity cost is TotalCost_cents = (mains.pos * 0.03) + (mains.neg * 0.07) + (hotWater * 0.15)
Note: The price multiplier is cents per Watt hr, i.e. cents / kWh divided by 1000. Also note the brackets in the equation. IoTaWatt does not understand the * should happen before +, so you need to add ( ) around each part to force it to be calculated first before add them together.

The individual component plots each need their own Output calculation e.g. HotWater_cents = hotWater * 0.15

Conclusion

This page covered programming the IoTaWatt device using Arduino and removing any pre-existing WiFi settings. It also showed how to plot the real time Electricity Cost and included some general comments about installation and plotting the measurements.



AndroidTM is a trademark of Google Inc. For use of the Arduino name see http://arduino.cc/en/Main/FAQ


The General Purpose Android/Arduino Control App.
pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2024 Forward Computing and Control Pty. Ltd. ACN 003 669 994