Electronic – bridge rectifier connected to a raspberry pi gpio

bridgegroundraspberry pirectifier

I'd like to connect a bridge (full wave) rectifier to my Raspberry Pi (RPi), GPIO pin 22 (configured as an input). I have configured the rectifier such that it has a 120VAC input and 3VDC output (I used a voltage divider on the DC output). The circuit works fine. I'm able to power an LED from the 3VDC output. Now my question is, how do I connect this 3VDC output to the RPi? Do I just tie the grounds together (rectifier DC ground to RPi ground) and then connect the bridge rectified 3VDC to the RPi GPIO pin 22? I measured a 68V difference between the RPi ground and the bridge rectifier DC ground. I decided to hold off on connecting anything until I figured out why there is such a large voltage difference between the two grounds. Any help would be appreciated. BTW, the RPi is being powered by the same 120VAC source that is connected to the AC input of the bridge rectifier.

Here's the circuit I ended up implementing: 120VAC Detector Circuit

Best Answer

The Raspberry Pi is generally powered from a 5V wall-wart type of DC power supply. The secondary is galvanically isolated from the mains voltage for reasons of personal safety (a fault will not expose the end user to the mains voltage).

The DC return of your bridge rectifier circuit is most certainly not isolated from the mains. The Raspberry Pi ground is 'floating' with respect to the bridge rectifier ground - there is no galvanic connection between them, hence your voltage measurement.

If you were to connect the DC return of the bridge rectifier circuit to the Raspberry Pi ground, you bypass the galvanic isolation that the DC power supply gives you. This means your Raspberry PI is now mains-referenced, and any fault could potentially expose you you to lethal voltages. I wouldn't do this.

A further complication comes if you also hook up an earth-referenced return to the Raspberry Pi, like a connection to a PC, with the mains-reference return connected. When you mix a mains-referenced return like your rectifier circuit with earth, things are going to explode (you essentially short out your bridge through the earthed return, which is often a flimsy wire that gets really hot and melts/catches fire while blowing up everything connected to it). Another reason not to do this.

You would be much better off with a small line frequency transformer to (1) step down the mains voltage to a lower level ahead of your resistive attenuator, and (2) provide galvanic isolation from the mains. Put your bridge and attenuator in the secondary of the transformer. With this, you can safely connect the low voltage isolated rectifier return to the Raspberry Pi return.

(You also must include a fuse in the line to isolate the rectifier circuit from the mains if there is a severe fault like a transformer fault or a short circuit.)