Lightning occurs.... arduino Mega dies.

Hi all

This issue has me going over and over in circles, and I don´t know how to solve it.

Here it is:

I got a Mega controlling a greenhouse with relays, temp sensors, rain sensor, switches to detect water levels, curtain levels, etc.

Rain season is here, and so far the lightnings have killed 3 Megas.

The Arduinos are not inside the greenhouse, they are in a secure, safe and dry room; long wires go from the electronic paraphernalia, to the Megas.

I already connected the ground of the Mega to a ground line inside the house -- still no luck, today the third one died.

How do they die? they won´t do anything -- avrdude sends timeouts, and even trying to reprogram them with the atmel tools, they just won´t "see" the arduino.

Arduino IDE does see the port connected, but I cannot upload anything... they are just there, two leds on all the time (one of them has a led slowly blinking).

Before I spend more money, I would like to get some suggestions from you as to what might be happening.

For the record, I was thinking about drilling a hole in the greenhouse structure, and put a screw there with a wire connected to the common ground wire of all the sensors. Do you think that could help me?

Thanks for your time to read this.

Connecting the household ground directly to an arduino may be a little risky.

See Here

Maybe adding surge / lightning protectors to the power supply on the household side for the Arduino would be at least a start.
They are not too expensive but beware of cheap Chinese ones for this application.

Any sensors would probably have to be isolated and NOT grounded to other structures too.

If you have so many items then maybe it would be worth considering using such as ESP,s to send the data back to your Arduino by wireless so that if its a sensor that takes the hit then it would just be the sensor you have to replace.

Water level / rain sensors I think would be more prone to spikes in your case but without knowing the sensor make/model its hard to guess.

Have a read of Protecting Inputs in Digital Electronics | DigiKey

Ideally avoid having analogue signals feeding back from the greenhouse to the mega. It is best if you can do the conversion locally and then feed back the digital information.
It is probably induced voltage from the lightning being fed down the wiring and back to the mega which is causing the damage. Using zener diodes to limit the voltage spikes etc... as mentioned in that article would help.

gblades:
Ideally avoid having analogue signals feeding back from the greenhouse to the mega. It is best if you can do the conversion locally and then feed back the digital information.

Hello

I don't fully understand this. how to do the conversion locally?

The analog signals I got are 1 rain sensor and 6 temp sensors.

The rest of the signals are digital / on-off

Thanks a lot!

Ballscrewbob:
Connecting the household ground directly to an arduino may be a little risky.

See Here

Yeah I already tried --- the relays don´t work.... :frowning:

Ballscrewbob:
Maybe adding surge / lightning protectors to the power supply on the household side for the Arduino would be at least a start.
They are not too expensive but beware of cheap Chinese ones for this application.

The Arduino is inside a PC cabinet, getting 12v power from the power supply inside, which has a regulated UPS.

Ballscrewbob:
Any sensors would probably have to be isolated and NOT grounded to other structures too.

Not one sensor is touching ground -- my water level sensors are only floating switches -- when water goes down from certain point, the relay controlling the water valve opens.

Ballscrewbob:
If you have so many items then maybe it would be worth considering using such as ESP,s to send the data back to your Arduino by wireless so that if its a sensor that takes the hit then it would just be the sensor you have to replace.

What do you mean ESP? Please excuse my ignorance.

Thanks!

You could use a couple of these https://www.ebay.co.uk/itm/172232402565 to convert the analogue signals to digital. Then you only have digital signals which you can protect more easily

I think he means the ESP8266. Initially it behaves like a wireless modem but you can write your own software. So you could have it query all the sensors and send the data back over your wireless network.

Krantz:
Yeah I already tried --- the relays don´t work.... :frowning:
The Arduino is inside a PC cabinet, getting 12v power from the power supply inside, which has a regulated UPS.

Not one sensor is touching ground -- my water level sensors are only floating switches -- when water goes down from certain point, the relay controlling the water valve opens.

What do you mean ESP? Please excuse my ignorance.

Thanks!

It sounds like you have taken care with the project and the only things above what you have done may be to use opto isolators between the sensors and the Arduino and separating the power to the sensors away from the Arduino. And even though you have a UPS it should have reputable surge protection either built in or on the UPS mains side.

ESP8266 is a small wireless device that can be used to send and receive data and is fully programmable with the Arduino IDE. It is ideal for remote sensors to talk to Arduinos.

Ballscrewbob:
And even though you have a UPS it should have reputable surge protection either built in or on the UPS mains side.

A friend told me it would be worth to encapsulate the PC cabinet where the Arduino is inside a Faraday cage ---- what do you think of this?

gblades:
Have a read of Protecting Inputs in Digital Electronics | DigiKey

I read all this material -- thanks a lot for sharing!!!

So, would you say that the option named "External clipping diodes" is the most appropriate for my needs?

I was thinking maybe I could make small pipe-like circuits with the diodes, capacitors and resistors, and put those before getting to the Arduino -- that would be easier and faster.

However, I wonder if I should make a circuit for each wire going to the greenhouse? even the 5v and ground? or just those pins for sensors and relays?

Thanks!

I don't think the faraday cage will make any difference. It is not the lightning voltage getting directly to the arduino which is the problem but the wires from the greenhouse picking up voltage which is too high for the arduino to deal with and damaging it.
What cables are you using from the greenhouse?
If not already then screened cables and connecting the screen to ground will help.

The protection circuits should be placed close to the arduino. Obviously one circuit for each interface would be needed.
With regard to the 5V this comes either from the USB port or the 5V source within the arduino itself. What are you powering the arduino from?
If you are powering from a higher voltage then a separate 5V supply for the sensors and the 5V to the diodes of the protection circuit would be a good idea as the protection circuit dumps any high voltage from the data lines onto the 5V supply so you don't want this going back to the arduino and damaging it that way.

The protection circuit will interfere with analogue inputs a little. It might not be significant for the rain sensor but depending on your circuit for the temperature sensors it may cause different readings. You might want to think about switching the temperature sensors for something like the DS18B20 which has a digital connection. For the rain sensor either use an op-amp and have a digital output to say whether it is raining or not or if you want indication of the amount of water use an analogue to digital converter to convert the signal to digital.

gblades:
What cables are you using from the greenhouse?
If not already then screened cables and connecting the screen to ground will help.

Inside the greenhouse I am using gardening cables for automatic watering systems -- copper.

From the central hub of wires inside the greenhouse to the Arduino, I am using 3 main cables, each with 24 separated wires, all screened with aluminum and grounded to the Arduino. (They're made of an special alloy, the sales guy told me, seems aluminum with something else, very good conductivity, but lighter and very resistant).

gblades:
The protection circuits should be placed close to the arduino. Obviously one circuit for each interface would be needed.

You mean one circuit for each wire?

gblades:
With regard to the 5V this comes either from the USB port or the 5V source within the arduino itself. What are you powering the arduino from?

The arduino is inside a PC cabinet which has it's original power source of 250 watts.
I clipped one of the 12v cable and it´s ground pair, connected the interface needed for the arduino - that's how I am powering it.

gblades:
If you are powering from a higher voltage then a separate 5V supply for the sensors and the 5V to the diodes of the protection circuit would be a good idea as the protection circuit dumps any high voltage from the data lines onto the 5V supply so you don't want this going back to the arduino and damaging it that way.

Noted - separate 5v source for the circuits.

gblades:
The protection circuit will interfere with analogue inputs a little. It might not be significant for the rain sensor but depending on your circuit for the temperature sensors it may cause different readings. You might want to think about switching the temperature sensors for something like the DS18B20 which has a digital connection. For the rain sensor either use an op-amp and have a digital output to say whether it is raining or not or if you want indication of the amount of water use an analogue to digital converter to convert the signal to digital.

For the rain sensor, I am sure is just a matter of adjusting thresholds.

Temp sensors --- I am already using the DS18B20 water resistant version, they all are hooked to one data cable only, but each has its own 5v / ground combination -- my mistake, I forgot those are digital as well.

Krantz:
You mean one circuit for each wire?

Yes you will need one protection circuit for each of the data wires back to the arduino. The protection circuit +5V connection should go to the +5V of the separate power to the modules and not the +5V output of the arduino.
Something like http://www.ebay.co.uk/itm/291696752759 would allow you to connect it to the 12V output of your existing computer PSU and adjust the output voltage. A 5.1V zener diode across it's output would help to dissipate any induced voltage and reduce spikes. Any spikes on the data lines are dissipated to 5V so this protection on the 5V line will help stop that increasing in voltage. Just adjust the output voltage of the supply before adding the zener to make sure you don't set it too high and try dumping 3A through the zener which it won't like for very long!
An additional 470uf or so capacitor on the supply at the greenhouse end would help to give a stable supply voltage to the sensors as well.

gblades:
The protection circuit +5V connection should go to the +5V of the separate power to the modules and not the +5V output of the arduino.
Something like http://www.ebay.co.uk/itm/291696752759 would allow you to connect it to the 12V output of your existing computer PSU and adjust the output voltage. A 5.1V zener diode across it's output would help to dissipate any induced voltage and reduce spikes. Any spikes on the data lines are dissipated to 5V so this protection on the 5V line will help stop that increasing in voltage. Just adjust the output voltage of the supply before adding the zener to make sure you don't set it too high and try dumping 3A through the zener which it won't like for very long!

So, can I use the same PC power source, just a different 12V cable?

gblades:
An additional 470uf or so capacitor on the supply at the greenhouse end would help to give a stable supply voltage to the sensors as well.

We're talking about the 5v line here, right?

Yes you can even use the same 12V cable if you wish. The main point is to not use the internal 5V supply within the arduino as it is quite low power and also powers the arduino itself so any voltage spikes going back in could damage it. Using a separate power supply for the sensors and protection circuit avoids this risk. It doesn't matter if you use the same 12V cable or a different one as they are connected to the same place inside the computer psu anyway.

Yes an additional capacitor on the 5V line inside the greenhouse.

Ferrite cores could be quite helpful, also (especially) opto-isolation for your digital control lines. There are even isolated power supplies available that can derive power from another power supply.

The idea is to make the Arduino MEGA as electrically isolated as possible, then deal with the remaining signals in the next best way.

To really give improved suggestions, we could use more details of your circuit:

Could you post a detailed diagram of your connections?
Are you using relay module(s) and do they have opto isolation? (need link to your relays).
Also, links to your power supply (supplies) would be useful.

Hello
Thanks for your reply.

All my issues and problems were immediately solved when I installed a Ruggeduino Mega.

(Rugged MEGA — Rugged CircuitsRugged Arduino)

It is not as cheap as a regular / clone Mega, but the quality and the toughness is amazing.

It´s not easy to pay over 100 usd for a Mega, I know; but for me, the peace of mind it gives is priceless. Before I got the Ruggeduino, lightning fried 4 megas.

Thanks for the link.
Suitably impressed by some of the products they offer.