Monitoring mains voltages

Hi All -

Sometimes I’d like to detect the presence or absence of mains voltages (240v AC here). Examples include knowing when my traditional hot-water system is opening or closing a heating valve, or when my outdoor motion sensor is switching on or off the outside light. (It’s a mains-powered unit giving a switched live output.)

I understand the underlying electronics and could build a board myself, but that’s probably too much effort, especially considering the safety requirements.

Anyone know of an easy reasonably-prepackaged solution that could become a binary sensor in HA? I’m guessing a Sonoff Pow would work, but it might be overkill - I don’t need to switch the current or measure anything other than presence or absence of a signal.

Thanks in advance,
Quentin

I am looking for almost the same.

I have some outdoor motion triggered lights, and I have connected them to a Sonoff Pow. When the power is above a threshold value, I assume the light must be turned on.

I have an outdoor motion sensor connected to a Shelly 1, but it isn’t working good. I needed to insert a relay between the two to get it working. (Shelly 1: 25VAC on input - Motion Sensor attached gives 100 VAC)
But I think attaching it to your hot-water system should work. (https://shelly.cloud/shelly1-open-source/)

And it should be possible to just use a esp8266 with an optocoupler to detect mains voltage. (https://www.aliexpress.com/item/1-Bit-AC-220V-Optocoupler-Isolation-Module-Voltage-Detect-Board-Adaptive-3-5V-For-PLC-Isolamento/32828199766.html?spm=2114.search0604.3.22.76bc5c1cOaf0nB&ws_ab_test=searchweb0_0,searchweb201602_2_10065_10068_319_317_10696_10084_453_10083_454_10618_10304_10307_10820_10821_10301_537_536_10902_10843_10059_10884_10887_321_322_10103,searchweb201603_51,ppcSwitch_0&algo_expid=698b1ac0-6421-4ab4-a717-c21eef65504c-3&algo_pvid=698b1ac0-6421-4ab4-a717-c21eef65504c&transAbTest=ae803_3)

using an ESP8266 with the above mentioned optocoupler would be the cheapest and very easy to implement using the ESPhomeYAML API in HA

I know, but you still need to get from 220V AC to 5V DC to power the ESP. Do you know of any easy and reliable way to do this?

The shelly can also be flashed with ESPHome, and might even be easier/cheaper.

I use a Quibino Relay module and connect the voltage to be sensed to the I2 switch input, this shows up as a binary sensor in HA

I suppose any Zwave relay with mains rated switch inputs would work, there are some that don’t have mains rated inputs (Everspring) thats why i chose the Qubino

Just use a power supply which is looked in before the device doing the switching. IE: before the thermostat or motion sensor. You can buy very cheap 240vac to 5vdc power supply modules from AliExpress. I have a few on their way now, only about AUD$1 each from memory

Thanks all - some useful suggestions…

I like the look of that optocoupler - it could work nicely in situations where I’m already using a Sonoff switch (which could provide the Vcc) and want to connect one of its GPIO inputs to an existing 220v source. That would work well for my outdoor-light-with-motion-sensor example.

I will be using a micro usb cable splitter to power a 5v relay and a power passthrough power bank which in turn powers the raspberry pi where hass runs. The powerbank acts as a ups for the pi. The relay is connected to hass as a pir sensor through a suitable pin.
The relay and splitter y cable costs 1.5$ total from aliexpress.

Combining a Sonoff switch and the optocoupler is a good idea. I think I am gonna try that too.

If you have a UPS , there is a component to monitor it which will give you a binary sensor

The UPS that already runs the PI is what I used, but use NUT instead.

ups

I wanted to do exact thing to detect when my hot water boiler is running. my hot water system is not that old, It is air to water heating system, but doesn’t have any smart IoT.
I googled around the internet to find a solution, I found your topic. I was about to hack into the honeywell motorized valve to connect it to optocoupler circuit, Then i realised that it will be risky and may avoid my warranty for the system.

Then it came to my mind the idea of using Non-contact voltage detector(NCVD), I never have one before, so I built one to test on a white board, it really can detect AC on live wire.

So what I did, I bought a very cheap non-contact voltage detector, I was lucky that it is without any power button or any sensitivity, you just need to add battery to it. I took off the LED/buzzer from the board, then I connected a resistor and optocoupler instead. Then I connected the output terminal of the optocoupler to Aqara Zigbee contact sensor as described in the following link:

My sensor was ready to be tested, I just need to extend the antenna of the NCVD to be touching the wire that feeds the Honeywell motorized Valve. Whenever my boiler started to heat the water, it will send AC into the wire, NCVD will detect the voltage, then optocoupler output will be almost short circuit to close the Aqara Contact sensor.

1 Like

Nice!

For my simpler, original question, though, these days I would probably just use a Shelly device. Actually, the Shelly i3 looks perfect: i could use one input to monitor my heating valve and another my hot water valve, and still have one left over!

Quentin

1 Like