A power meter - using the Pyboard as a measuring instrument

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
User avatar
pythoncoder
Posts: 2163
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

A power meter - using the Pyboard as a measuring instrument

Post by pythoncoder » Mon Oct 30, 2017 10:05 am

This project is for measuring power consumption of mains operated devices in the range 0-3KW. It performs true vector/phasor measurements and can integrate to determine the mean power consumption of switched devices such as freezers and pumps. It can handle devices with arbitrary power factors including those which both use and generate power. It uses the official lcd160cr display to provide a touch interface with uasyncio.
Image

Image

Here are illustrations of the display. It looks much better in real life than in my photography ;)
Image
The base screen. Measuring the power of my soldering iron.

Image
Our microwave oven has a small leading power factor. Note the phasor display; conventionally this should be rotated 90 degrees clockwise. To do.

Image
A plot of the current waveform, with the mains voltage as a phase reference.

Image
The integration screen. The mean and watt-hour total update continuously for as long as the screen is kept open. The mean display can be toggled by the button on the right to show the maximum power input to the grid (for generating devices).

The green PCB houses a transconductance amplifier for the current transformer, matched anti-aliasing filters for voltage and current signals and a programmable gain amplifier to extend the dynamic range of the ADC (for the current measurement only). However the device is remarkably accurate even when measuring my soldering iron on the 3KW range which says something for the Pyboard ADC's. Compare and contrast
Image

Image

Note that the plot screen provides a snapshot of the current sample set: it shows a single shot and is not a continuously updating oscilloscope display. The device takes 400 sample pairs of voltage and current as fast as MicroPython can do it. This is sufficient to capture two full cycles at 50Hz. It then processes and displays the result, before repeating the cycle. The result is an update rate of about 1Hz. The algorithm prioritises accuracy in the presence of noise over performance and I have made no attempt to improve the latter. I doubt that doing so would offer any benefit in terms of its utility as a measuring instrument.

I've now replaced the dodgy tie-wrap strain relief in the pictures above with proper cable glands. ;)

GUI code https://github.com/peterhinch/micropyth ... cr-gui.git.
I haven't posted details of the design as I doubt anyone else would want to build one, but if there's any interest I could do so.
Peter Hinch

inakto
Posts: 11
Joined: Mon May 15, 2017 7:14 pm

Re: A power meter - using the Pyboard as a measuring instrument

Post by inakto » Wed Nov 01, 2017 6:19 am

Cool project.
I really like the I, V graph display, gives you more detail than just a power factor number.

For making cutouts in plastic project boxes, I have a small chinese CNC mill that does a great job.
In my experience it's almost impossible to make a good looking box cutout by hand.

Does that toroidal transformer need to be that large? Or can it be done with something smaller.

I might be interested in building one actually, if you would share the details

User avatar
pythoncoder
Posts: 2163
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: A power meter - using the Pyboard as a measuring instrument

Post by pythoncoder » Wed Nov 01, 2017 8:29 am

The toroidal transformer is rated at 6VA - it was the smallest stocked at my usual supplier (CPC/Farnell). It fitted in the box so I used it. A smaller one would undoubtedly suffice if you can find one.

As for hand tools I was trained in metalwork where we were required to produce work in mild steel to +-0.005 inch tolerance using hand tools alone. Alas age has stolen the steadiness of hand required to achieve decent precision. A mill would be good.

I'll post code and schematics in due course but unless there's wider interest documentation will be rudimentary.
Peter Hinch

rcolistete
Posts: 101
Joined: Thu Dec 31, 2015 3:12 pm

Re: A power meter - using the Pyboard as a measuring instrument

Post by rcolistete » Wed Nov 01, 2017 9:42 am

Great device and interface !

I'm also interested, in the MicroPython code using the excellent Pyboard ADC, as well as the hardware schematics.

torwag
Posts: 197
Joined: Fri Dec 13, 2013 9:25 am

Re: A power meter - using the Pyboard as a measuring instrument

Post by torwag » Fri Nov 03, 2017 8:30 am

pythoncoder wrote:
Wed Nov 01, 2017 8:29 am
The toroidal transformer is rated at 6VA - it was the smallest stocked at my usual supplier (CPC/Farnell). It fitted in the box so I used it. A smaller one would undoubtedly suffice if you can find one.

As for hand tools I was trained in metalwork where we were required to produce work in mild steel to +-0.005 inch tolerance using hand tools alone. Alas age has stolen the steadiness of hand required to achieve decent precision. A mill would be good.

I'll post code and schematics in due course but unless there's wider interest documentation will be rudimentary.
Hey Peter,

nice project! This looks like an super-version of a power-meter to me. Now, if there would be wifi and you could access those infos from a website generated on the device too, that would be great. My main concern with conventional power-meters always was the place where I would like to add them is often so hidden, that reading the values from a display is an artistic act. I noticed you used some wires already to be able to place the unit in a better "reading" position.

As for the power supply, I found those a while ago:
http://www.hlktech.net/product_detail.php?ProId=54
They are as small as a middle sized relay. Kind of handy. However, I never used them in a measurement set-up and never checked about the DC signal quality. Just thought that might help to create a even smaller version.

User avatar
pythoncoder
Posts: 2163
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: A power meter - using the Pyboard as a measuring instrument

Post by pythoncoder » Fri Nov 03, 2017 12:24 pm

I've posted some rather minimal documentation here https://github.com/peterhinch/micropython-samples.git - follow the link near the end of the README.

@torwag The transformer is used to safety-isolate and reduce the line voltage for measurement. Given that requirement, I felt it might as well power the unit too. In other circumstances I would have bought a switchmode module or wall-wart.

As for a WiFi version, the ESP8266 wouldn't work as it has only one (rather poor) ADC. We need two for phase measurement. An option would be to use my method of bringing MQTT to the Pyboard using an ESP8266 - I think that would be easily implemented.
Peter Hinch

Post Reply