I’m looking for a plug in sensor that can allow an arduino or raspberry pin to monitor when ac line voltage is applied to a socket. Generally I want to respond when a line circuit is energized and I want the response to be as quick as possible, so I’m ruling out plug in wall warts unless they are very quick to power up and down.
I seem to have a vague recollection of a short power cord with a simple opto isolator output, but I’m not finding anything like that with google.
Thanks in advance.
Off the shelf sensor for line voltage
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Off the shelf sensor for line voltage
We'd suggest a wall wart for its isolation.
Wall power is a potentially lethal energy source and a potential ignition source. Working with it safely requires specific training, and designing circuits for it requires specific techniques and components. The most reliable way to get a safely isolated output is to use a wall adapter.
What kind of timing do you need?
Wall power is a potentially lethal energy source and a potential ignition source. Working with it safely requires specific training, and designing circuits for it requires specific techniques and components. The most reliable way to get a safely isolated output is to use a wall adapter.
What kind of timing do you need?
- sj_remington
- Posts: 1021
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Off the shelf sensor for line voltage
The transformer-type AC to AC step down wall warts are essentially instantaneous and perfectly linear in their response, so they are the method of choice to monitor AC line voltage. Do not use regulated or unregulated AC to DC wall warts, for obvious reasons.so I’m ruling out plug in wall warts unless they are very quick to power up and down.
This tutorial goes over the details of safe voltage and current monitoring of house-hold* AC power, and offers clever code to boot: https://docs.openenergymonitor.org/elec ... nitor.html
(*) the dash gets around the very quirky forum censor.
- ll7
- Posts: 3
- Joined: Wed Feb 29, 2012 9:53 am
Re: Off the shelf sensor for line voltage
I think the ac/ac transformer will work nicely. It will be fast and I can safely rectify the low voltage and detect it. My desire for off the shelf was to safely deal with line voltage by never having it in a circuit I have created. I think a simple transformer will safely achieve that goal.
I would like to know if the product I’m remembering actually exists, but that’s a separate issue.
My purpose is for creating a photo enlarging light source. I need a sensor that can plug into an existing timer, while leaving the light controller externally powered. If the timer energizes the circuit for 0.1 seconds I want the lights to be on for as close to that as I can get. I’ve solved this in the past with creating my own timer as part of the controller, but sometimes people wish to use a favorite timer. Note in this case no current will flow, only that the circuit will be energized.
I would like to know if the product I’m remembering actually exists, but that’s a separate issue.
My purpose is for creating a photo enlarging light source. I need a sensor that can plug into an existing timer, while leaving the light controller externally powered. If the timer energizes the circuit for 0.1 seconds I want the lights to be on for as close to that as I can get. I’ve solved this in the past with creating my own timer as part of the controller, but sometimes people wish to use a favorite timer. Note in this case no current will flow, only that the circuit will be energized.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Off the shelf sensor for line voltage
Old wall warts were basically step-down transformers, so you might have something floating around in an old junk drawer. Modern ones use switching converters. They're more efficient and better regulated, but will have slightly more delay between plugging in and the output voltage reaching the nominal value.
In that context, a phototransistor would have the fastest response:
https://www.adafruit.com/product/2831
The transition time is 2us, or about 0.2% of a 1ms pulse in absolute terms. The response time is highly repeatable under uniform conditions though, so you can identify the exact timing and treat it as a constant offset.
In that case, tracking line voltage will be an indirect measure. The direct measure would be the light levels.ll7 wrote: ↑Mon Feb 06, 2023 7:01 am My purpose is for creating a photo enlarging light source. I need a sensor that can plug into an existing timer, while leaving the light controller externally powered. If the timer energizes the circuit for 0.1 seconds I want the lights to be on for as close to that as I can get.
In that context, a phototransistor would have the fastest response:
https://www.adafruit.com/product/2831
The transition time is 2us, or about 0.2% of a 1ms pulse in absolute terms. The response time is highly repeatable under uniform conditions though, so you can identify the exact timing and treat it as a constant offset.
- ll7
- Posts: 3
- Joined: Wed Feb 29, 2012 9:53 am
Re: Off the shelf sensor for line voltage
I wasn’t clear enough. This is just for a sensor to see if the NEMA 5-15 type outlet on the back of an existing photo timer is energized. Normally this would directly light an incandescent bulb, but I want to use it to trigger lighting LEDs that are on a remote controller. The timer will trigger its relay for times in the range of .1 to 60s and I need the LEDs to be on for as close to that exact time. I’ve already built a version that integrates a timer into my controller, but I have use for one that allows for use of an existing timer.adafruit_support_mike wrote: ↑Mon Feb 06, 2023 10:45 pm In that case, tracking line voltage will be an indirect measure. The direct measure would be the light levels.
In that context, a phototransistor would have the fastest response:
https://www.adafruit.com/product/2831
The transition time is 2us, or about 0.2% of a 1ms pulse in absolute terms. The response time is highly repeatable under uniform conditions though, so you can identify the exact timing and treat it as a constant offset.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Off the shelf sensor for line voltage
Ah.. it's a signal capture application.
That general category of problems tends to be easiest to solve with time-travel: drive at full speed until the car's front bumper touches the wall, then go back in time far enough to apply the brakes so the car stops just as the bumper meets the wall.
Obviously causality has some things to say about that, but in many cases you can get the same effect by building in a delay. Old oscilloscopes had a coil with a few meters of coax that would make the dot-control signal reach the CRT a few nanoseconds after the trigger signal (derived from the dot-control signal).
In this case, if you're able to accept 50ms of latency between the arrival of the external timer signal and the LEDs turning on, you'll get 3 cycles of 60Hz input to decide exactly when the external signal ends.
If you're using an input transformer, I'd suggest one with a center-tapped output so you can use a full-bridge rectifier. That will convert negative peaks in the AC input to positive peaks at the output, and will ensure you capture the moment of activation no matter which half-cycle it occurs.
Don't filter the rectified ouput.. that will only make it harder to decide when the input signal ended.
To detect the rectified pulses, take a look at the LM311 comparator. It's an old device, but holds an important point on the price/performance curve: a single chip costs about 50c, and the LM311's response time is officially 115ns. Comparators faster than 100ns cost about $7, the ones faster than 10ns cost about $15, and sub-1ns comparators go for $30 to $60.
An LM311 comparing its input to a 650mV reference (the voltage across a silicon diode) should give you noise-free detection of rectified pulses, with a blip for every zero crossing at the input.
That general category of problems tends to be easiest to solve with time-travel: drive at full speed until the car's front bumper touches the wall, then go back in time far enough to apply the brakes so the car stops just as the bumper meets the wall.
Obviously causality has some things to say about that, but in many cases you can get the same effect by building in a delay. Old oscilloscopes had a coil with a few meters of coax that would make the dot-control signal reach the CRT a few nanoseconds after the trigger signal (derived from the dot-control signal).
In this case, if you're able to accept 50ms of latency between the arrival of the external timer signal and the LEDs turning on, you'll get 3 cycles of 60Hz input to decide exactly when the external signal ends.
If you're using an input transformer, I'd suggest one with a center-tapped output so you can use a full-bridge rectifier. That will convert negative peaks in the AC input to positive peaks at the output, and will ensure you capture the moment of activation no matter which half-cycle it occurs.
Don't filter the rectified ouput.. that will only make it harder to decide when the input signal ended.
To detect the rectified pulses, take a look at the LM311 comparator. It's an old device, but holds an important point on the price/performance curve: a single chip costs about 50c, and the LM311's response time is officially 115ns. Comparators faster than 100ns cost about $7, the ones faster than 10ns cost about $15, and sub-1ns comparators go for $30 to $60.
An LM311 comparing its input to a 650mV reference (the voltage across a silicon diode) should give you noise-free detection of rectified pulses, with a blip for every zero crossing at the input.
Please be positive and constructive with your questions and comments.