PROTO power meter

Measuring AC power with the Industruino PROTO

Tom

This project shows how to build an Arduino based electricity consumption monitor using the Industruino PROTO platform. We can use it to measure the power consumption of an AC appliance such as a water cooker, a TV, a laptop charger, anything you plug into a wall socket. Alternatively you can also use it in your electricity cabinet to measure the power consumption in your entire house (at least one phase).

The challenge is to measure an alternating current (AC) of a relatively high voltage (220-240V) with our direct current 5V Arduino microcontroller. This may seem dangerous, but we will use a non-invasive Current Transformer (CT), so our Arduino remains galvanically isolated from the high voltage AC.

This prototype is based on the excellent open source project OpenEnergyMonitor. It uses parts of the its standard emonTx hardware and software to report the AC apparent power consumption, based on measurements of a Current Transformer as in the picture on the left. The original project also allows to measure 3 phase and/or real power, but for our prototype here we are only measuring the current of one phase, not its voltage which would require an AC/AC adaptor.

The CT, as shown in the picture above, is clamped around 1 wire of the mains (live or neutral, not both!), and it has 2000 windings and a max current of 50mA so it can read up to 100A. More info here.

We want to capture the small alternating current that is proportional (1:2000) to the AC that goes through the main wire. We convert this current into a voltage by putting through a burden resistor, as in the picture on the right.

I used a burden resistor of 30 ohm, and a voltage divider 10K/10K for the DC bias. This creates a voltage around 2.5V proportional to the current flowing through the CT, as explained in above link. The circuit is complete with one 10uF capacitor. The output goes to the PROTO's A6 (=D4).

The CT has a 3.5mm (mono) jack and i put a socket on the Industruino PROTO's baseboard, enlarging the soldering holes to fit the pins.

What you see in the picture on the left is actually all you need to measure the AC power!

The sketch is quite simple, as all calculations are done in the emon library.

The RMS voltage is considered a constant, to be calibrated with a multimeter.

The maximum current of this setup is 100A, so it can measure up to 20kW. This can be adjusted by changing the burden resistor.

The LCD shows the AC power (in Watt) as a product of the calibrated AC voltage (in Volt) and the measured current (in Ampere). The final version also shows the average power consumption since startup (in Watt), and the accumulated energy consumption (in kWh). This kWh number is probably not very accurate as the sketch does not use precise timing.

Although the 32u4 topboard that we used for this prototype only has 28K available, i could use the U8G display library with no problem: the code is quite small and i used subsets of the 3 fonts to reduce the file size.

Below is the full setup:

the white cable plugged into the electricity wall socket (out of view)

the CT on the blue power line

the kettle's black cable plugged into the white socket

the CT plugged into the PROTO (without its case)

the PROTO powered by a USB power bank

LOGGING YOUR DATA INTO THE CLOUD

There are 2 options:

using the Industruino Ethernet module

installing an ESP8266 WiFi module inside the PROTO

The Ethernet option is straightforward: just connect your Ethernet module to the PROTO using the supplied cable, and plug in an ethernet cable connected to your LAN, as in the picture on the left (PROTO and Ethernet modules shown without casings).

See ETHERNET sketch below.

Installing the ESP9266 WiFi module requires a bit of soldering, as in the picture on the right, details below.

Our favourite cloud solution is the open source http://emoncms.org/ where you can create nice visualisations and dashboards.

This is a graph on emoncms.org with 3 hours of data for my laptop charger, which consumes around 40W when the laptop screen is on, and less than 10W when off.

I have also added a counter in the code to keep track of kiloWatt-hours (kWh) since startup of the Industruino, and average power consumption. The timing is not exact; as far as i can tell it's accurate to about 3%.

As the WiFi module has to restart completely, each data transmission takes around 9 seconds. During that period there are no power measurements so i use the last reading for that entire period.

Below is the sketch; it is easy to remove the Ethernet/WiFi part if needed.

PROTO baseboard implementation with ESP8266 WiFi module (ESP-01)

The diagram on the right shows you how to wire the sensor conditioning circuit and ESP8266 module onto the prototyping area of the Industruino.

I used the minimal ESP-01 package in a 4x2 female header on the PROTO board. I used the onboard 3.3V with a large capacitor (1500uF) to deal with the high current requirements during transmission. And i used the Serial1 hardware serial port on D0/D1 at baud rate 115200, with the standard AT firmware on the ESP8266.

When the WiFi connection is active, there is a lot of interference with the analog measurement, so i shutdown the WiFi module during the sampling (by pulling the CH_PD pin to GND), and restart it after a fixed interval, e.g. 1 min, to send the power data.