Arduino + metal enclosure and grounding (230v)

Hello,

I am working on a project including a power supply (230V to 24V), some electronics and an arduino.
All this stuff is put into a metal enclosure.

I can start the program using a external button. In my code, I've put an interrupt which checks if the button is pressed again, to stop the program.

My main issue is when I touch the metal enclosure or move it, the program stops.
My enclosure is NOT connected to earth ground, and I'm wondering if noise is generated by moving the metal parts, disturbing the arduino...

Thank you !

If the mains enter the box, ground the box.

For the problem, show how you connected the switch. Please NO Fritzing breadboard mess, hand drawing will do.

PS Interrupt is NOT needed for user input :slight_smile:

Thank you for your fast reply. Yes, +230V enters the box so I will ground the box.
The switch is just connected between D4 and GND, directly on the arduino (well it's a Wemos D1 mini pro).

As for interrupt, I know it's overkill but I didn't find a solution to start the programm and stop (reset) using the same push button...

Last part isn't that hard... You just need to implement state change detection (and probably debounce). Easy way, grab a library like Bounce2.

Is that switch on that box or connected via a (long) wire?

The metal switch is connected to the metal box using 2 X 30cm wires and connected to D4 and GND.

This kind of button :

http://www.elka-electronique.com/345-thickbox_default/bouton-poussoir-anti-vandalisme-onpow.jpg

The state change looks interesting but I need to stop the program instantly when the button is pressed, and there are some delays in the program.
Interrupt is very reactive but I would like to delete this anyway ...

Internal pull up enabled? If so, try adding a higher value external and/or button debounce

Thibaultgd:
and there are some delays in the program.

Now there is your problem :wink: Get rid of them :slight_smile:

And even now, how do you stop the program from the interrupt? You just keep in in the interrupt or what?

Internal pull up enabled.

The delays needs to be deleted, I agree ! :smiley:

In fact I use the interrupt to reset the arduino, with :

void(* resetFunc) (void) = 0;//declare reset function at address 0

This is not the cleanest way to restart the program I guess ...

Thibaultgd:
This is not the cleanest way to restart the program I guess ...

Mild way of saying it :smiley:

Right :slight_smile: Thank you again, I'll ground the box and modify the program.

Hi,

  1. I don't think all the pins in ESP8266 are capable of internal pull-up. Correct me if I am wrong. Also something that I've experienced is that, even when we enable internal pull-up those pins tends to float with noises. So I highly recommend adding pull-up resistors of 10k.

  2. Never use 230V/110V applications with metal enclosures without grounding. That is a must for the safety.

  3. Also make sure all your Arduino power cables, buttons and communication cables as well as the ESP modules are well away from the current carrying cable. (230 V) If the currents are bit high they can cause noises in your program.

good luck. :slight_smile:

@manjulaelcid, GIO0 to 15 have pull ups. GPIO 16 has a pull down. But they are called weak pull ups for a reason :slight_smile: