It’s almost alive!
Okey, so it’s been several months since I first started playing around with PIC microcontrollers, I’ve got a couple of projects in mind but my first one is a home energy monitor. Our house is full of tech that drinks a significant amount of electricity, so I wanted to start monitoring it. We could have got an OWL monitor but they are relatively expensive and there’s no real learning experience. Besides I want to be able to record the statistics, not just have them on a LCD display somewhere (which is plugged into the mains…).
So what’s the solution? A PIC16F7X7 with 14 ADC channels (of which I will need three in the end), supports I2C for talking to a Phillips RTC (keeps the date/time and also provides a regular interrupt), a Microchip I2C 1Mbit EEPROM for temporary data storage and UART for talking to a serial device. So far so good, however deviating from what is out there at the moment I wanted to be different on several levels.
First I needed to put this project outside in the electricity cabinet, it’s not my house so I can’t route wires or drill holes. This presents two obvious issues first of all there is no usable power out there (although that’s what it’s monitoring) and I can’t easily get a data connection outside. The first solution is to use a 12V battery and a solar panel which even at 25% efficiency can charge up the nights power usage, although not arrived yet a grand total of £16 from eBay. The second problem is easily solved although at a price. There were two options to use a 433Mhz TX/RX pair which provides a one way feed from the project, the problem with this is that a significant number of other applications use the same technology.
The other option, although more expensive, is to use a serial driven Bluetooth module with the SIP profile. This can be paired with any Bluetooth device and supports encryption and authentication and also bidirectional communication, allowing us to query the device as well as simply receive data. I highly recommend looking at SparkFun for any electronics geek, it’s heaven. The module I want to use is around £35 with P&P.
My biggest issue by far has been finding a cheap current transformer to actually clamp around the main incomer to the house. I can find numerous places in the US who will sell a CR Magnetics CR 3110, however any company shipping to the UK charges a fortune for postage making the units between £15-20 each. A co-worker of mine pointed out that you could get an entire unit (sold under OWL Energy Meter in the UK) for doing what I want (ex-PC integration) for £35 including a current transformer. After some digging we discovered that you could order the transformers separately for just over £5 each direct from the company.
For those who haven’t seen them, they look like this:
![]()
And are clamped on like this, (Warning: I have removed the mechanical shielding to get to the live wire, this was done for testing only and would be dangerous for regular use. The 4-gang in question is not used for anything else.):
![]()
Once I received the transformer I set about trying to identify how I would be able to use it in my project, looking for model numbers and other identifying marks which might enable me to find a datasheet:
![]()
![]()
Sadly there where none, on the underside of the transformer (last picture above) I discovered a 100Ohm resistor which after looking at the implementation notes for the CR 3110 I believed to be a burden resistor. I tried putting several amps of current through the live wire and found minor voltages appearing (on the scale of 0-100mV). I took several readings and found that all but one (in the middle) lined up relatively well. Taking the equation from the CR 3110 data sheet of R = (T x V) / I it was possible to get a rough figure of the number of turns on the transformer, this all came out to around near 3200 turns.
Using the same equation I worked out what resistance I would need in order to generate near 5V for 13A, it came to ~1230 Ohms, knocking this down to a on hand value of 1kOhm gave me 5V for 16A. I proceeded to remove the burden resistor from the transformers mount, due to the layout of the PCB I could leave the resistor to the other end of the lead and close the transformer back up. Allowing me to experiment if need be. After further testing I found all these values to be very closely in tune with those that I had worked out. Only having a Kill-a-watt to help test my calibrations I can only assume it’s “accurate-enough”.
I had previously done a lot of reading at http://board.homeseer.com/showthread.php?p=627341 with reference to wiring up a CT. After wiring up the CT to my PIC development board and implementing a full wave rectifier I was left with an odd cycling of reasonable readings to wrong readings. It appeared that the timing of the ADC conversations was drifting in time with the 0V cycles of the rectifier. I had included a 1nF capacitor as the HomeSeer site had suggested, it turned out after talking to a co-worker it simply wasn’t big enough so instead this was replaced with a 47uF electrolytic. Bingo it started behaving as I expected, there was a three bit wobble in the least significant bits from the ADC but this may well just have been changes in current usage in my test object (read: girlfriends hairdryer).
I additionally had a test meter also wired in so that I could confirm the ADC readings:
![]()
I have noted a 0.2V drop on the DC side which I suspect is due to my diode rectifier, I need to explore this issue further and identify how to work around it or if I can just straight discount it. Finally an overview of my dev board:
![]()
If you have any questions to do with the project let me know, I’m a little way off of it being completely finished but it can certainly begin it’s testing now.
Gerard Gallagher said,
September 23, 2008 @ 1:40 am
Hi,
Read with great interest your post on the mains monitoring project.
I am in the process of building a similar device, and as it happens I also have an owl CT, two of which I bought. I actually took the time to open one and count the turns, which amounted to 3200, and removed the burden resistor.
However, I’m having great difficulty in getting a proper ac-dc conversion process running. I live in the Rep. Of Ireland and similar to the UK, we are running 230V AC. I have a 12KVA supply, so therefore I can have a maximum current of 52amps, and I was trying to design the device to therefore give a DC output proportional to 0-50A, with a voltage output of 0-5V DC suitable for a ‘877 ADC. Using a bridge rectifier seems not an option, as the DC voltage produced does not seem to correspond to the ampere reading I am also taking off the live wire with a clamp meter. I’m guessing this is too also due to the voltage drop across the diodes.
I’m wondering if you have any schematic or other info on how your project is progressing, as I’d be greatly interested in seeing any ideas on how to solve my current impasse, and considering your schematic is for similar voltages, and using a similar CT, our schematics should be roughly the same.
Thanks for your time, and nice blog.
Regards,
Gerard Gallagher