# Rpi GPIO Push Button Circuit Grounding Problem

I have a little project where I power my Raspberry Pi Zero using a 12v Battery, via a small 12v to 5v regulator I bought from eBay. I am going to connect a push button to the Pi as in the following link. (pin 18 goes to push button and to ground; pin 18 is pulled up via software) http://razzpisampler.oreilly.com/ch07.html

My question is can I connect the ground wire coming out from the push button directly to the ground of the 12v Battery? instead of the ground out from the regulator. My guess is the -ve out from the regulator is the same as the battery -ve of the battery

• Surely the output of the regulator is connected to a Pi 5V pin as well as a Pi ground pin. Why not just connect the button ground to a Pi ground pin? A diagram or photo of your proposal may help.
– joan
Oct 22, 2019 at 17:18
• Thank you for the reply. My project turns on a motor bike via bluetooth. Now I want to know the status of the side stand of the bike. Actually I am trying to connect wire from GPIO pin to the side stand so that it connects to the ground when the side stand is lifted. (I will not be using a push button). so I am thinking to make it so that the wire from the GPIO touches the body of the bike when I lift the side stand. As you know the body of the bike is connected to the -ve of the battery, this way I can use just one wire. Oct 22, 2019 at 17:53
• @Mohamed Rilwan, I am making an answer. Please look at my schematic and confirm if I understand your setup correctly. Oct 24, 2019 at 3:00

Question

The Setup

1. Power to RpiZero = 12V Battery > 12V to 5V volgage regulator

2. Push button with one end connected to Rpi GPIO.

The Question

Is it OK to connect the other end of the button to the 12V battery ground?

Yes, no problem.

Let us first look at Oreilly tutorial's push button circuit.

Then compare Oreilly circuit (green part) with the above circuit (pink part). The OP's question now boils down to

Should Button Ground 5 connected Rpi Ground 3 or Voltage Regulator Ground 1?

/ to continue, ...

References

/ to continue, ...

Appendices

Appendix A - Ground Loop Reading Notes

Electrial Circuit and Audio Equipment Ground Loop Problems And Howq to Get Rid of Them - Tomi Engdahl 2013

What is "Ground Loop"?

Ground loop is a condition where an unintended connection to ground is made through an interfering electrical conductor.

Generally ground loop connection exists when an electrical system is connected through more than one way to the electrical ground. When two or more devices are connected to a common ground through different paths, a ground loop occurs.

Currents flow through these multiple paths and develop voltages which can cause damage, noise or 50Hz/60Hz hum in audio or video equipment.

To prevent ground loops, all signal grounds need to go to one common point and when two grounding points cannot be avoided, one side must isolate the signal and grounds from the other.

What is "Ground"?

The NEC, National Electrical Code defines a ground as: "a conducting connection, whether intentional or accidental between an electrical circuit or equipment and the earth, or to some conducting body that serves in place of the earth."

What is the difference between Equipment Grounding and Earth Grounding?

When talking about grounding it is actually two different subjects, earth grounding and equipment grounding.

Earth grounding is an intentional connection from a circuit conductor usually the neutral to a ground electrode placed in the earth.

Equipment grounding is to ensure that operating equipment within a structure is properly grounded.

These two grounding systems are required to be kept separate except for a connection between the two systems to prevent differences in potential from a possible flashover from a lightning strike.

The purpose of a ground besides the protection of people plants and equipment is to provide a safe path for the dissipation of Fault Currents, Lightning Strikes, Static Discharges, EMI and RFI signals and Interference.

Improper grounding can create a lethal hazard. Correct grounding is essential for correct operation and safety of electrical equipments. Grounding can solve many problems, but it can also cause new ones. One of the most common problem is called "ground loop".

What is the difference between "Ground" and "Common"?

Audio and video systems need a reference point for their voltages. Generally referred to as common or ground, although it may not be actually connected with the earth, this reference remains at "zero volts" while other signal voltages "swing" positive (above) and negative (below) it.

Physically, the common may be a wire, a trace on a printed-circuit board, a metal chassis, virtually anything that conducts electricity.

Ideally it should be a perfect conductor, but in any practical system it is not. As the complexity and size of the system is increased, the imperfect conductivity of the common (ground) conductor inevitably causes problems.

Why ground loop is a problem ?

Ground loops are a mystery to many people. Even college-trained electronic engineers may not know what ground loops actually are.

Engineers have either concentrated on power distribution (for the electric company) or on equipment that happens to plug in to the power distribution system.

Not much thought has been given to power distribution and equipment as a single entity where ground loops arise. Ground loops are the most common cause of AC line frequency hum in sound systems.

Ground loops can be generally identified by a low hum (60Hz in the US, 50Hz in Europe) through the sound system. A ground loop in the power or video signal occurs when some components in the same system are receiving its power from a different ground than other components, or the ground potential between two pieces of equipment is not identical.

Ground loop is a common problem when connecting multiple audio-visual system components together, there is a good change of making a nasty ground loops.

Ground loops commonly cause humming noise to audio signals and interference bars to picture. Ground loop makes the system sensitive to pick up interference from mains wiring which can lead to erratic operation of the equipments or even damages to the equipments. Some articles claim that wiring and grounding problems account for up to 80 percent of all power quality related problems related with sensitive electronic equipments like audio/video systems.