Any suggestion for quick/easy way to detect whether mains voltage is present or not?
Scenario: ESPHome device, with independent power supply (via POE), monitoring an AC mains circuit. I’ve got lots of mains circuits here with GFI (Ground Fault Interrupter). I really need to know when a GFI has popped, to know when freezer & other appliances on that circuit are not receiving power.
Sensing current draw on mains (or appliance) won’t help, because appliance might not be running just then. I don’t care about exact voltage (a la ZMPT101B); just whether the mains circuit is energized or not. Can Hall devices do this? (just sensing potential, not current draw?)
Any thoughts for simple device to provide high/low to a GPIO pin, as binary sensor to indicate if mains circuit is on/off? Preferably as isolated as possible from mains.
Not really interested in ADC conversion (e.g. from ZMPT101B, which would require some programming & calibration re threshold voltages). I’ve considered mini 5V power supply, with its V+ fed to the GPIO.
Am I overcomplicating this? Maybe just an opto-coupler + a couple resistors, plus maybe a little sensor filtering in ESPHome YAML?
Still kinda leery of connecting mains wiring into my stuff. But yeah, what’s the diff if I connect mains to something on my board, whether it’s an opto-isolator or a relay.
Still would probably want to insert a couple series resistors, to limit current if say a short in relay. -More than 1 R, in case 1 of them breaks down; belt & suspenders And maybe some sort of encapsulation (epoxy or whatever) on the relay mains wiring.
Check this video from Ralph Bacon. He designed a no-contact current sensor that I plan to use to detect if my washing machine is running. I designed and made some PC boards (but I haven’t built one yet), so let me know if you want the Gerber files.
Another idea. If you just want to know if the power is present, just use a Wemos D1 Mini (<$5 on Amazon) and a dollar-store USB charger for power. Make the Wemos an ESPHome device. If there is power then the Wemos is “alive” and connected to your WiFi. All you have to do in HomeAssistant is monitor the status entity for the device.
If you don’t have mains power, how are you running Home Assistant?
Hmm, that’s a really interesting idea. I was thinking to have the AC circuit-“live” sensor as one pin of an ESPHome device handling multiple sensors. But yeah, a really cheap power supply plus just an ESP01S (about $1 on AliExpress), with “status” binary sensor configured in ESPHome, could work nicely as a stand-alone mains monitor device. The device is on if outlet power is present, & goes offline if the GPI pops.
I might think strongly about that approach. Even better- I’m not that great at physical assembly stuff, but if I could commission someone to build such a little dedicated-function wall-wart device, it could be worth it. We’ve got SO many GFI interruptible AC circuits around here.
There’s possibly some terminology confusion: I’ve been using “mains” to refer to any individual AC circuit in the building, not necessarily the “main” supply to the building.
Re how I’m powering things: I’ve got Home Assistant server (ODROID) on a UPS (hopefully backed by a generator soon), in case whole property loses power. That also covers network gear, including Wifi access points which are fed by POE (Power Over Ethernet) on Cat-6 cables from central UPS-protected network switches.
But it’s entirely possible for individual AC circuits to drop offline, if their GFI gets popped. That’s what I’m trying to monitor, e.g., if fridge in an outbuilding loses power without us knowing about it. In those areas, I’m doing ESP32 boards for ESPHome, where they receive power on an RJ-45 jack via POE, like the wifi access points. (So those ESP32 boards are communicating to HA via wired Ethernet instead of Wifi.)
Anyway, thanks VERY much for resetting my thinking about a type of device to detect power loss.
I have a board designed that contains the ESP8266-01 and an AMS1117 3V regulator. You are welcome to the Gerber files for it. I currently use it in my vehicles to tell Home Assistant if they are present. If they connect to my WiFi, they are present. Same principle as your mains detector.
I’ve been doing mostly the approach discussed earlier, to simply see if an ESP01 unit is online or offline. But there are still some cases where the optoisolator across the mains load would be good.
Besides the AliExpress unit mentioned above by tom_I, I’ve located a very similar unit on Amazon, and have purchased a couple units for testing: https://www.amazon.com/dp/B09M844SBZ
Like Tom says, no way you can build this stuff cost-wise when you can just buy pre-assembled module.
Now I’m trying to figure out if it’s safe to embed the entire hi-V side of this module in epoxy, to prevent accidental contact with mains voltage. But worried about heat dissipation from that resistor. Does anyone know if that would be an issue?
How? If all you want to know is if the mains are off, then why not monitor an ESP status? The status is either connected or unconnected.
I am amazed sometimes how people want to complicate an otherwise simple solution.
So, here is my suggestion. It can go anywhere you want to monitor the presence of line voltage, you aren’t exposing your fingers to lethal line voltage, and you aren’t introducing uncertified hardware (illegal in some jurisdictions) into your breaker panel box. Best of all, it costs less than $10.
Thanks for the suggestion using the Sonoff in that manner. Do you know if that’s available in a pre-flashed ESPHome version, or any other approach that is local-only and NOT cloud based?
You can put the live wire trough the hole, there is no contact needed with the circuit. If a current is running you will be able to use this to detect.
That’s cheap. I may buy some just to have in my drawer.
But this won’t fix the OP’s situation. It is invasive, and only 5A. The OP wants to know if the mains are off, and he won’t know if the mains are off or the device is off.
These aren’t invasive, there is no contact between bare wires and the board. They are using the same principle you were suggesting that is being used in the Ralph Bacon video you added. It’s true they can only measure untill 5 amps. But I wouldn’t be suprised if above 5amps they still give a signal, probably just maximum.
However, I do understand your point about the difference between mains off or the appliance off. I missed that.
They are invasive in that you have to remove the live wire from the breaker or outlet to pass it through the hole in the transformer. To people not experienced with electrical wiring, this is invasive and over the line. The Bacon device is simply an antenna that picks up the induced electromagnetic energy coming from the power line to the device. You don’t have to unplug, disconnect or otherwise come close to live wires.
Besides, the Bacon device doesn’t answer the OP’s question because if the device is off, there’s no energy to detect. So, is the power off or is the device off?
No reason to over complicate things.
For the freezers, I use the SONOFF s-31 flashed with Tasmota. You can easily write an automation to notify you of a power loss.
You can also use the Shelly EM. It uses a simple clamp around a wire to monitor. I use it for my dryer. You do have to provide it with voltage, so there is some wiring involved.