Control 5VDC with 120VAC


What is the best way to receive a 5VDC control signal on the Photon from a 120VAC line?

I am looking for a quick and easy yet ‘up to code’ solution for use in an industrial environment. Essentially, what the problem boils down to, is being able to detect when a float switch is triggered. Essentially this float switch connects and disconnects a 120VAC line. I need to be able to tell from the Photon, the current status of this 120VAC line.

The easiest solution I can think of is to use a cheap USB ‘wall-wort’ that one typically uses to charge cell phones and the like. This would convert the 120VAC into a 5VDC which can then be monitored via the photon. I don’t really like this idea though as it doesn’t seem like the proper / professional way of doing things and I am concerned that the Photon may not be truly isolated from the 120VAC signal.

The alternative that I thought of was to use a relay that is controlled via a 120VAC signal. This seems like a proper solution. So all that to say, can someone help me out in verifying that this 120 VAC, 10 AMP, AC Control Solid State Relay will actually do what I want?

Or even if someone can suggest a better method (with links to actual products), I am here to learn!


The wall wart sounds like a great idea. Someone else has taken care of all the isolation etc.

Don’t overthink this :smile:, sure there’s going to be lots of ways to do this, but ask yourself does this work for you and let you move on to the next problem ?


I was going to suggest an opto-isolator but @AndyW is completely right in suggesting to follow KISS principles. :smile:

Also, put a resistor across the 5V output, so that when the power goes off, the output caps on the wall wart don’t hold the 5V line up for too long. It doesn’t have to dissipate a lot of power, it just needs to make sure the cap drains in whatever you deem a reasonable time.

Is it also worth putting a 10K resistor in series with the input pin, I wonder?

I really do like following KISS, but in this case I’m trying to think ahead to 10 years down the line. If I used the ‘wall-wart’ idea, I’m just thinking someone 10 years down the line is gonna look at it to try to upgrade it / fix it / change it and say ‘What the F— was this guy thinking?’; whereas if I use a solution that is fairly industry standard, that would not be the case…

1 Like

In my own research I’ve come across people suggesting to use an opto-isolator, but I’ve never found any actual opto-isolator ‘devices’, instead only people suggesting opto-isolator circuits I could make…
Have you ever come across an opto-isolator ‘device’ that would do what I suggest. I would like to stay away from designing my own circuitry if at all possible - hence the desire for a stand alone ‘device’.

Ignore the previous relay I suggested, it only works with AC loads. The G3NA-D210B version of this relay seems like it would do what I want.

I’m not extremely experienced with electronics (I only get to deal with electronics as a hobby unfortunately), so I would greatly appreciate if someone could verify that this relay actually would do what I want.

@dcrawford, what is the load? If I understand correctly, you intend to read the float switch directly (at logic levels, not 120VAC) and control the load via the SSR, correct?

The load on the relay would be the Photon. I essentially need to detect when the float switch activates. The float switch itself, when activated will turn on a 120VAC outlet. I was thinking of using the G3NA relay to activate a 5VDC line (connected to the Photon) when the 120VAC line was activated by the float switch. The photon will then be used to send a text-message (via a web service) to notify someone to take action based on the activation of the float switch (I.E. the building is flooding about to cause thousands of dollars of damage… do something now!) along with activating other things like physical alarm sirens.


Is this an existing piece of equipment or are you just setting up. I would suggest you run the float switch on the lower voltage, mostly for safety reasons of not having 120 volt near to the vessel. Then use this low voltage to switch an SSR relay or similar to turn on your outlet. This then makes it easy for the photon to detect the switching.

Best regards,

I’ve also been looking for a simple AC line monitor, i.e. a 120 V AC to 5 V DC transducer “device”, but haven’t been able to find one. The wall wart has a weird form factor to do this.

I plan to make my own simple inline device using this AC transducer. I haven’t yet done so, but I wanted to share this link here.

1 Like

If this is an application on an important system like a sump pump, consider a ‘non-invasive current sensor’. It would let you detect the item controlled by the float switch (pump?) without affecting the circuit. Wouldn’t want a short-circuit failure of a cheap wall wart to trip the pump circuit breaker and cause the flooding that the float switch is preventing.

Opto22 makes industry standard AC to 5v opto isolated input modules. I’ve used these for decades and they are very reliable.

@Bitbored, i removed your post as like you mentioned Please don’t use this solution and this is indeed a dangerous thing for anyone who read to try out.



I was looking at this from Opto22, but when I contact the company they said they don’t have anything that supports 120VAC control and 5VDC load.

As I understood your application, you wanted to sense a 120VAC signal with your Particle device. Opto22 makes the IAC5 product that will allow you to do that.

Your 120VAC signal connects to the field side of the IAC5 and the Particle device connects to the logic side. Note that one downside is the over sized pins on the IAC5 that require larger holes than a standard breadboard can handle.

@Muskie, great link! Another DIY approach is based on contact-less AC voltage probes and is very easy to implement:

The “detector” could be coiled around the “live” AC wire from the float switch. The software could be interrupt driven when a 60Hz pulse appears from the detector. :smile:

1 Like

Well, imo my suggestion is not necessarily that dangerous. The “line” could be a “clean” 120 VAC source. The only reason why my suggestion could be dangerous is because @dcrawford is probably talking about the mains net, which often suffers from voltage spikes.

There is no reason why the line could not be some other kind of ground referenced 120VAC that does not suffer from voltage spikes. In this case the series resistor should offer enough of a voltage drop to make sure the Photon won’t be destroyed. In this case my solution should work just fine.

I think I included enough warnings in my post, and it could have been an interesting resource for people willing to step out of there comfort zone and learn. I respect your decision to take it down, but I can’t help the feeling that it’s a bit patronizing towards the particle community.

There are a lot of cheapo wall warts that I consider way more dangerous than hooking up to the net using a properly big resistor. I personally prefer experimenting (in a responsible way) and learning about electronics and the dangers involved over depending on cheapo stuff that could be just as dangerous, without people realizing it.

I would still not recommend non-technically trained people to attempt it. The stakes are too high and not worth the risk and who knows who will actually be reading it?

Definitely not taking the risk of high school students or self tinkerer to read, try and get injured.

1 Like