Can earth be used as a common ground for Arduino?

My Arduino Mega 2560 based circuit is very simple. All it has to do is to detect is if a door has been opened and, if detected, save this information to on-board memory.

I plan to use a 9V battery to drive the board. I also will connect the anode of the battery to the interrupt pin on Arduino by using a wire that runs through the door.

Anytime the door is opened, the wire will get disconnected. This will generate a high-to-low-voltage interrupt that my program will be watching for.

The door is about 10 feet away from the board.

To make this work, I would need to run two 10-feet wires - one from the anode to the door and the other from the door to the interrupt pin.

I am thinking if I use Earth as my ground, I could simply place another battery at the door and just run one wire from the door to the interrupt pin.

The cathode of both the batteries and the GND pin of the board can all be earthed.

I am wondering if you see any problem with this logic.

Thank you in advance for your help.

Regards,
Peter

You should not connect 9 volts to an Arduino pin.
Define "earth". What are you planning to connect to?

The battery won't last long. Couple days at best. If this is truly all this circuit has to do, a Mega is massively overkill for it. Downsize to something smaller that you can get in a DIP package, that way you can remove the extra power wasting crap on the board and use a more proper set of batteries.

Second, rather than trusting a wire running across the door to be opened and closed reliably, a magnetic reed switch will be so much better.

What 'information' is being saved? Time and date? Count?

I second the reed switch. More reliable and your only real option considering whatever your idea about earth is unusable.

Anytime the door is opened, the wire will get disconnected. This will generate a high-to-low-voltage interrupt that my program will be watching for.

Nope that will not happen. That is not how inputs work.

INTP:
...your idea about earth is unusable.

I wouldn't go that far. As stated, it would not work, it would need a different design. But it's too tricky for a beginner to handle.

aarg:
I wouldn't go that far. As stated, it would not work, it would need a different design. But it's too tricky for a beginner to handle.

I imagined he was envisioning treating the house as you would a car chassis.

Regarding the question on earth ground:

If you mean the "safety ground" we have in the USA, then conceptually it would work (the other issues aside). And I don't believe it would violate electrical code. It would however have a lot of electrical noise that would have to be filtered out at the receiving end.

If you mean the actual "earth" as ground then it would not work or might work for a while. For instance, if your door was on an outbuilding and the mega was in you home. You would find the potential of the two "grounds" to be slightly different and could change over time. In addition at the first lightning storm near by, you would likely toast your mega due to ground currents caused by lightning.

Another reason to run two wires: You can twist them together and they will partly cancel the electrical noise that gets picked up by any wire run any distance.

Hope this helps.

John

You can't guarantee a non metalic ground or earth is at the same potential everywhere.

Signal grounds are far far better run alongside the signal, otherwise you've got a large
loop-antenna in your circuit and noise pickup will be rife (and perhaps destructive when
thunderstorms or big mains transients are flying about).

In general every signal and every power wire should be running alongside its return wire (usually
ground).

Grumpy_Mike:
Nope that will not happen. That is not how inputs work.

Thank you for your help. I don't understand what you mean. Currently, in my test setup, I have +5V pin connected to pin 2 (Interrupt 0). Within my program, I have the following line in my setup() routine:

attachInterrupt(interruptNo, onLowVoltage, LOW);

Each time I remove the wire from +5V pin, my onLowVoltage routine does get called.

Can you please explain what exactly is "not gonna happen?"

Regards,
Peter

aarg:
You should not connect 9 volts to an Arduino pin.
Define "earth". What are you planning to connect to?

By earth, I mean the floor and the walls. Can I not use them as a conductor?

Regards,
Peter

Jiggy-Ninja:
The battery won't last long. Couple days at best. If this is truly all this circuit has to do, a Mega is massively overkill for it. Downsize to something smaller that you can get in a DIP package, that way you can remove the extra power wasting crap on the board and use a more proper set of batteries.

Second, rather than trusting a wire running across the door to be opened and closed reliably, a magnetic reed switch will be so much better.

Thank you for your help.

  1. My device needs to run for at least six months without requiring to change the batteries. Can you please suggest the replacement for Mega that you mentioned?

  2. Thank you suggesting the reed switch. I am doing some reading on it. However, one thing I don't understand. How will it eliminate using the wires? Won't I still need to run two wires from from the circuit to the door?

Appreciate your help.

Regards,
Peter

PeterTaps:
By earth, I mean the floor and the walls. Can I not use them as a conductor?

Regards,
Peter

You could, if your circuit can accommodate 10 quadrillion Ohms of resistance, give or take some more quadrillion.

I.e., if you placed a battery between your door and door frame, such that one end of the battery is touching the door and the other end the frame, would you expect the battery to deplete?

No. Floors and walls aren't conductive unless you're on a ship or other vehicle.

Here's a good resource on power saving: https://www.gammon.com.au/forum/?id=11497 It starts from an Uno but a Mega will be almost identical.

The reed switch replaces a wire across the door that touches another wire when it's closed. That won't work reliably for more than a month or two. A reed switch will work for years. It does need a magnet on the door though. Usually you buy the switch and magnet together as a pair.

Cat-5 cable is extremely cheap. So cheap that even if you only need 2 wires, it's usually cheaper to buy Cat5, even though it is high-specification twisted-pairs. Just make sure you use two wires from the same pair: blue and blue+white, for example. Telephone cable is equally good for this.

PeterTaps:
Each time I remove the wire from +5V pin, my onLowVoltage routine does get called.

I bed it gets MANY calls.

Not connecting a pin to 5V does not automatically make the pin 0V/LOW :wink: For that, you have to use a pull down resistor to keep it there, otherwise it will just work as an antenna and pick up noise.

Besides, attachInterrupt(interruptNo, onLowVoltage, LOW); does NOT check for a HIGH-to-LOW, it just checks for LOW. For HIGH-to-LOW use FALLING.

Or be smart and invert it. Connect the switch to GND and check for LOW-to_HIGH with RISING. And instead of an external pull down resistor you can just enable the internal pull up's (pinMode(pin, INPUT_PULLUP)) to keep it HIGH when the switch is open.

And for the source, just use a Pro Mini and remove all leds and put it it sleep as much as possible. And instead of a 9V battery (which is a very very poor source) use 3 AA cells (or even AAA have more energy then a 9V) directly to Vcc (to bypass the regulator) or use a LiPo. But for this you need a Pro Mini running at 8MHz (instead of 16MHz) otherwise it might not be stable.

Nope, look up equipotential bonding of pools for instance, the ground can have a potential difference of several volts over 20-30ft…

PeterTaps:
Thank you for your help. I don't understand what you mean.

Can you please explain what exactly is "not gonna happen?"

As I understand your word description, a schematic would be so much better, you think that applying 5V to an input gives you a HIGH reading - this is correct. And removing that 5V gives you a LOW reading - this is wrong. You get a floating input that can read as HIGH or LOW at any time as it picks up interference. You need to connect an input to zero volts some how to get a LOW reading.