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