IoT Power Monitor

Introduction

I’ve got a pre-paid electricity meter installed at my new place in Cape Town. It outputs a 1/1kWh pulse via a LED on the front panel. I thought it would be pretty cool to read and log the power consumption of my house. It’s also an excuse to play with WiFi and other fun stuff.

Functional Specification

  1. Microcontroller, PIC24FJ64GB004
    • Low pin count
    • Low power
    • Built in RTCC (needs 32.678 khz crystal)
    • TCP/IP Stack
  1. Power supply
    • LiPo – 2000mAh
    • 500mA Charger
    • 3.3 switch mode buck/boost voltage regulator
    • Battery state of charge
  1. Micro SD card
    • FAT32/16
    • Log data, very simple txt format
  1. User Interface
    • LED, 1Wh pulse, Low battery signal, WiFi status
    • User button, log the time new coupon was loaded
    • Reset
  1. Wireless connection
    • WiFi, MRF24WB0MA, 802.11b/g/n
    • Microchip PIC24 TCP/IP stack
  1. External Interface
    • RJ11 connector
    • On PCB header
  1. Meter Interface
    • Reverse biased photo diode
  1. USB Device.
    • Micro USB B
    • Mounts SD card as a mass storage device
    • Generic serial endpoint
    • Charge battery
  1. i2c Temperature sensor

Design and Schematics

The initial design started on the white board in the lab.

I used kicad for the first time to do the Schematics capture and PCB layout. It’s really not a bad package, there are a few rough edges but all in all it’s really good and usable for hobby or startup work.

(Click for PDF)

The Optic coupler uses a reverse bias IR photo diode, I used a Osram SFH 213 it’s reasonably sensitive to red light even though it’s peak sensitivity is in the IR range.

The design of the optic coupler is very simple, Photo Diode into a NPN transistor amplifier and the a Comparator to act as a threshold detector and output buffer. I used the very cool LTC1540 NanoPower comparator, it includes a 1.182V reference and only draws 300nA. The 1.182V reference is a a perfect match for the level that the photo diode produces.

(Click for PDF)

The boards where manufactured by IteadStudio.  I got the optical coupler routed out into a disk that fits inside a film canister that forms the housing for the coupler.

Power Monitor top
Optical Coupler top

Building and Testing

There are some really small parts on the board that can be quite a challenge to hand solder, but with a bit of hot air and lots of liquid flux it’s quite doable. The MAX17040 Battery Fuel Gauge is a 8-pin, 2mm x 3mm TDFN, TMP102 Temperature sensor is a 1.7mm x 1.7mm and lastly the Boost converter is a 3 mm x 3 mm QFN-10 Package.

Testing the SPI and I2C buses using my Buspirate and Logic Sniffer. The battery gas gauge and the temperature sensor uses I2C while the SD-Card and WiFi radio uses SPI

Completed board running off the Lithium Polymer battery.

Software

I tried some new technologies for the software stack. I’m using MongoDB as the data store and Scala and the Play framework for the application layers.

The charts are drawn with highcharts and the website page layout uses Bootstrap.

2 Responses to “IoT Power Monitor”

  1. 320Volt says:

    Thank you for sharing a useful article WiFi enabled Power Monitor

    Which program are you using for drawing pcb

    thanks

Leave a Reply