Does anyone have a good idea for monitoring if a wire is live 240v or not.

I'm wiring a PI relay in parallel with the room stats (8 stats in total) so that either the room stat or the relevant pi relay can call for heat.

That's all working nicely, but next I would like to monitor the status of the room stats (i.e are they calling for heat with the return wire at 240v)

Essentially a relay board where the control is 240v and it's switching a GPIO friendly 3.3v on/off

I'm struggling to google this as every result is for "normal" relays with LV controlling the mains.

  • 1
    Before I answer, is it 240VAC? is it continuous load? are you looking to sense the 240V? how much variation on the 240V line is there? and would you accept answers that involve analog input or A2D conversion?
    – j0h
    Commented Sep 27, 2016 at 1:32
  • 1
    Could you be a bit more specific wrt the question, "are they calling for heat with the return wire at 240v". A schematic drawing would help us understand your overall question better & improve the quality of any answers you might get.
    – Seamus
    Commented Jan 9, 2020 at 23:25

4 Answers 4


If I understood your question correctly, you want to verify wether a wire/phase has 240V or not. In this case you could use a contactor: it goes to ON when supplied 240V.

You can then use a N.O (normally open) contact of it connected to the Pi to identify absence/presence of voltage.


I have the same sort of issue with my future home automation plans for a Raspberry Pi to control/override some of my Domestic (MAINS!) Lights. As well as some suitably rated relays, correctly designed to safely operate across a "Mains Barrier" with Mains Voltages on the contacts and low-voltage on the coils I also need to monitor the Mains Input and the three switched outputs (which, as they will be parallel to the conventional light switches in the circuit would still be "live" when the RPi is NOT trying to turn them on if the relevant light switches are!)

At this point in time I am trying to track down a circuit that I saw somewhere here that uses an opto-isolator, a X2 capacitor and a series resistor to detect the Mains - importantly it is the capacitor that is used to drop the voltage/current passing through the LED in the opto-isolator. As virtually all the impedance in the circuit comes from the capacitor the current and voltage are nearly 90 degrees out of phase and so the power dissipation is very much smaller (though the current is largely the same) than the few Watts that would be lost in the series resistor if that was the right size to put 10 to 30 mA through the opto-isolator LED in a purely resistive circuit.

I hope to update this with more information when I have it...


How about a traditional step down transformer and rectifier? Well, not so smart maybe..

But an opto-isolator with few passives should also help. You will need to build it as there doesn't seem to be a breakout board. See this link: https://electronics.stackexchange.com/questions/150588/sensing-ac-high-voltage-to-microcontroller

Another option may be to use hall effect sensor but that will measure current rather than voltage. So useful if you have load connected and is drawing power. See here - https://www.sparkfun.com/products/8882

You can google for "AC mains sensing circuit" or similar.

Hope it helps.


I did this a lot, my first home automation system I used it on, it has been working for over 20 years. Response time is not critical. I purchased a bunch of 5V wall warts with a DC out. The output was not regulated and with a LED indicator when the power went off the voltage collapse in a few seconds. I connected the minus to ground, put a voltage divider on it and feed that into the micro. The voltage divider values depend on the wall wart voltage and the micro input voltage. I go directly into a digital input as I only want on and off. They were less then $2.00 on a close out. I had to purchase 12 of them and used them all. This is a very clean implementation. I put duplex receptacle where they were needed, on one I took it out of the case and placed it into a plastic box.

  • Whats a wall wart ? Commented Jun 24, 2023 at 4:02
  • Definition of wall wart PC Magazine pcmag.com › Encyclopedia › W wall wart from www.pcmag.com A power adapter that contains the plug for the wall outlet. The "wart" is a derogatory reference to the device because it covers up the adjacent socket and ... That is the first thing google returned.
    – Gil
    Commented Jun 24, 2023 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.