Introduction: Detect Household Power With Low Voltage Circuit - Arduino AC Voltage Detector
I'm currently working on a sump pump monitoring project using an ESP8266. One of the things I want to monitor is when the sump pump runs, and for how long. If you are familiar with sump pump designs, most are set up with a float switch in the well, that triggers a relay at the plug. The relay at the plug then fires the pump.
Conveniently, this relay/plug system, is usually a set of two plugs:
- Plug One is plugged into the outlet and has the relay, as well as another female outlet end.
- Plug Two plugs into the female end of Plug One.
The easiest way I figured for a low voltage circuit (my ESP) to know if the pump was on, was to put a two-way outlet tap between Plug One and Plug Two:
Outlet <- Plug One <- Two-Way Tap <- Plug Two
Then, on the tap, I can plug in another circuit that will act as a relay back to the ESP: when the "detector" circuit has power, it will close a relay - this relay will close a basic pull-up circuit on an ESP pin telling it the pump is running.
Instead of a mechanical relay, I decided to use an optocoupler. If you aren't familiar with optocouplers, they act like a relay, but use an LED and a photo sensitive transistor embedded in a little mini IC type component. When the LED half gets power, the transistor closes the connection on its side. These are nice because there are no mechanical components to break, and they are low voltage - we don't need a heavy duty relay to do this job.
Step 1: Gather Your Parts
This is a very basic circuit, so you don't need a lot. And there are no logical components (ICs or chips) either, so no programming.
- proto/strip board (example)
- LED of your choice (example)
- 5.5 mm barrel jack (example)
- 560 ohm resistor (or somewhere in that vicinity) (example)
- CP817 optocoupler (example)
- a two contact screw wire terminal (example)
- power supply (example)
- enclosure (example)
- 3 way outlet tap (I couldn't find a cheap 2 way!) (example)
Step 2: Assemble the Board
Assemble your board per either of the two pictures. I always recommend starting with a breadboard before going to a proto-board - but the choice is yours!
As you can see, the layout is very simple. The only thing to keep an eye out is for the dot on the optocoupler. That has to get the + part of the circuit.
Step 3: Plug Everything in and Test It Out.
This is a good time for a disclosure:
Warning: I'm sure your sump pump manufacturer does not want you to separate the two plugs that come from the sump. Use this set up at your own risk. And PLEASE make sure if you do use this, you use a heavy duty tap like in the example. I'm not responsible if you flood your basement!
Blah, blah, blah. Ok, next, we'll hook our circuit in.
Plug everything in as follows:
Outlet <- Plug One From Sump <- Two-Way Tap <- Plug Two From Sump
And then of course, we plug our new circuit into the tap.
Yeah, it IS ugly.
But, now we have a sensor!
Step 4: To Be Concluded...
As I mentioned, this circuit is only a PART of my sump pump monitoring project. I didn't want the Instructable for that to be too big, so I broke it into pieces - and I'll post the rest soon.
However, I will leave you with a quick circuit you can build, and a program you can run to test out your new sensor.
Build out the board above. There's just your ESP, and a 10k ohm resistor - and two wires from your terminal on the power sensor.
Load the attached code to your ESP, pop open serial monitor, and see what happens when you supply and remove power to your power-detector.
Special Note: The wall-wart takes some time to dissipate the residual power when it loses power - so I added a delay in the sketch to account for this.