One hot summer afternoon I opened my electric bill and the number of digits made my head spin. I knew my air conditioner used a lot of juice but I couldn't just plug it into my Kill-a-watt meter, so I needed another solution to see just how fast the meter was spinning. Preferably something simple.
Over the last decade, the old "spinny disk" style electric meters have almost all been replaced by smart meters. There are a few ways to read these new meters but by far the simplest way is to count the infrared pulses emitted by an IR LED on the meter's face. It's not a new idea but I wrote this instructable because it is a fun project, easy to build, and mine is a tiny bit more robust since it can be queried using a REST api. I call it the SmartmeterSpy.
There's really only three main bits to this thing: 1. the pulse sensor, 2. the microcontroller, and 3. the optional display, and I've broken down the steps for each bit.
- IR phototransistor
- 470 - 2k resistor
- scrap of pc board
- suitable cap
- suitable hookup wire and/or connector to microcontroller
- old rubber bike tire
- 2 neodymium magnets
- esp8266 based controller board (i used an Adafruit Huzzah)
- FTDI (or similar) programmer for esp8266 board if required
- Optional LCD display (i used a nokia 3310)
Ok let's get started on the pulse sensor...
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: A Housing for the Pulse Sensor
I used an old soap bottle cap for a housing and a 3-conductor stereo cable to make the connection to the microcontroller. The phototransistor is affected by ambient light so I used a black cap to keep everything as dark as possible.
My cap had an outside diameter of 1 3/16", a height of 3/4", and fit nicely over a little molded ring on the meter face. You may need to look around for the right size. I also cut a small notch in the edge of the cap for a wire guide.
Step 2: Building the Pulse Sensor
The pulse sensor is just a phototransistor with an in-line current limiting resistor. The phototransistor and resistor are soldered onto a small piece of pcboard that got sticky-taped into the soap bottle cap, thereby creating the pulse sensor.
The sensor will have a power, ground and signal connection so you'll need a 3 conductor wire to connect it to the microcontroller. Mine was scrounged from my parts bin and has a 1/8" plug at the end. I wired the plug so that the tip = signal, ring = power, and sleeve = ground.
I had a pile of 470 ohm resistors laying around so that's what I put it in series with the phototransistor's emitter. A larger value (say 1 or 2k ohms) should make the transistor more sensitive to light, so feel free to experiment.
The collector was tied to the 5 volt supply, and Gnd was connected to the other side of the resistor. The signal comes off where the resistor connects to the phototransistor, shown as VA3 on the schematic.
The schematic shown here was taken from a parallax tutorial: http://learn.parallax.com/tutorials/robot/shield-...
Step 3: Attach Pulse Sensor to Meter
The pulse sensor is held over the emitter using a magnetic strap, made from a bit of an old bike tire, some staples and two neodymium magnets. I did it this way because the power company doesn't like it when you go permanently attaching stuff to their equipment (don't forget that even though the meter is on your house, they own it and can make you remove anything you put on it). **Technically you're not supposed to put anything on their equipment, so do it at your own risk.
Cut the bike tire a few inches longer than you need it so you can fold the ends into pockets for the magnets. Then after placing the pulse sensor over the meter I used the strap to hold it on. I also tried to route my cable through it so there wasn't much tension on the board's solder connections.
Step 4: Tuning the Pulse Sensor
After affixing the pulse sensor to the meter face, I "tuned" the phototransistor using a small, cheap and portable-ish DSO-138 oscilloscope. I set the scope for a 5 volt scale and applied power to the phototransistor. Every 5-10 seconds or so I got a pulse from the meter, and I simply adjusted the pulse sensor's position until I got what I thought was the largest amplitude pulse. Tuning Complete.
Step 5: Connect Pulse Sensor to Microcontroller
My initial version was built with a Microchip PIC and I also had a version running on an Arduino with a character LCD shield, but these were limited. I switched to an Adafruit Huzzah (esp8266) because it has wifi and I wanted to check my usage using a REST api call from a simple phone app or a web browser.
The Huzzah is a 3.3 volt device whereas an Arduino is a 5 volt device... but the pulse sensor works with either one.
The pulse sensor has 3 wires for power, ground and signal. It needs to be connected to +3.3v, GND, and pin 16 on the Huzzah respectively. I used a 1/8" stereo input jack and some prototyping wires to connect my pulse sensor to the microcontroller. If you use a stereo jack, just make sure the tip/ring/sleeve on the sensor match the way you wire the jack.
Step 6: Download the Code to the Huzzah
I started with Adafruit's webserver example and using the Arduino IDE, I added a little code to count the pulses, display power consumption on an lcd (if connected), and respond to REST requests for power consumption data.
Adafruit has great information on how to download code to the Huzzah using the Arduino IDE so I won't repeat it here. You can find their instructions at this url:
Once you're able to download code to the Huzzah, you need to do so with the attached SmartmeterESP8266 sketch.
Step 7: Power Up and Request Some Data
The Huzzah has a built-in 3.3 volt regulator, so I run the device from a 5 volt supply. If you're not using an esp8266 board with a regulator, be sure to use 3.3 volts for the supply. The LCD runs at 3.3 volts so I powered it using the 3.3 volt output from the Huzzah - which I also used to power the pulse sensor.
Assuming everything is connected correctly, once you apply power you should see the Adafruit logo on the LCD (we are using their library afterall), and then you'll see a status message telling you it's trying to connect to your wifi network. Once a connection is established it will display your IP address.
Now that it's up and running, getting data from this thing is stupid simple. Open up your favorite web browser and type in the following request:
Go turn on something that uses a lot of juice (air conditioner/hair dryer/particle accelerator) and send the request again. Sit back and let the awesomeness wash over you.
Step 8: OPTIONAL - Add an LCD Display
I dug around in my parts bin and found an old Nokia burner phone with a monochrome LCD that's commonly used by hobbyists. I tore the LCD out and soldered some leads onto it so I could use it for this project.
Adafruit put together a great PCD_8544 Arduino library to run these displays, so you'll want to download that.
I did not use an Adafruit display but their library worked just fine.
My display has the following pins:
- pin 8 - LED backlight
- pin 7 - SCLK, serial clock
- pin 6 - DIN/MOSI, data input
- pin 5 - D/C, data/command
- pin 4 - RST, reset
- pin 3 - SCE, chip select (aka CS)
- pin 2 - GND
- pin 1 - Vcc (3.3 volts)
I made the following connections from the Huzzah to the LCD:
- pin 15 to the LCD backlight LED pin 8 (be sure to use a current limiting resistor!)
- pin 14 to the LCD serial clock (SCLK) pin 7
- pin 13 to the LCD Data In (MOSI) pin 6
- pin 12 to the LCD Data/Command select (D/C) pin 5
- pin 5 to the LCD chip select (CS) pin 3
- pin 4 to the LCD reset (RST) pin 4
- the 3V pin to the LCD Vcc pin 1
- the GND pin to the LCD GND pin 2
Participated in the
Sensors Contest 2017