Public Domain

GPIO 230V 120V
Recommend Projects


4 years ago 812
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments



This is a simple circuit which allows a micro controller or Raspberry Pi to monitor a 230V AC signal. The 230V power from the mains is applied to the upper terminal. On the lower terminal one has to provide the supply voltage and ground reference. The circuit will output a clock-like signal, which is high by default, but goes low every time the 230V AC goes high. So when your Raspberry Pi or micro-controller sees a low signal, you know the 230V AC line is powered. On the other hand, when the signal remains high for a period of say 100ms, you can safely assume the 230V AC line is switched off.

The circuit will most likely not work for 120V AC by default, because the resistors R1-R5 will be too big and thus the current through the optocoupler too low. But you could use 4.7k resistors (also at least 0.25W). Keep R6 as 10k Ohms, as it is mostly unrelated to the AC input voltage.

The diode should be a 1N4004 or better (that is for example a 1N4007). I exclusively used 0.25W-rated 10k resistors, because they are commonly available, cheap, and in case you need to buy them, you only have to buy one kind of resistor and not several different.

The terminals are 2-pole RM 5mm and 3-pole RM 3.5mm. I use these ones: But it should be easy to fit the PCB to any connector/terminal, also you could just solder some wires directly to the PCB without terminal.

I marked the project as "IN PROGRESS" as I hadn't had a chance to test this version. The previous version -which is quite similar to this one- works like a charm though. So I guess that this one also works.






ID Name Designator Footprint Quantity
1 10k/0.25W R1,R2,R3,R4,R5,R6 R3 6
2 SIP2 P1 HDR1X2_RM5 1
3 SIP3 P2 HDR1X3_RM35 1
4 1N4004 D1 Seeed-DO-41 1
5 SFH618A U1 DIP4 1




The owner does not allow comments in this project now

Comments (0)

如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.