ATmega328 eeprom damaged by power surge?

I had a power surge the other day followed by power cuts that lasted around a second and another about 5 seconds later. Everything seemed OK in the house and even the oven clock was still working and that always reset during a brownout. However my garden watering timer was showing garbage on the LCD so I reset it. I then found that it wasn’t saving the settings for the time and duration of watering the garden. To cut a long story short it appears the eeprom had failed, it was no longer storing it’s settings. I also found a bug in the code whilst I was digging around and fixed that so I’ve updated the download on the project’s page.

I made some changes and made it so that the settings are stored on the eeprom on the ZS-042 module instead and also made another version that stores the settings in a variable in SRAM to get around the problem. I increased the value of the smoothing capacitor on the 5V rail to 1000uf from 220uf and fitted another 0.1uf bypass capacitor near the arduino nano board. Hopefully that will fix the issue. Other than that I may need to change the brownout detection from the default 2.7V to 4.3V. It appears to be working OK now and keeping my garden tubs watered.

I’ve gone over my code and it only writes to the eeprom after the time and / or duration is changed so I don’t think I’ve simply worn it out. The timer worked fine for a year and the eeprom will have been worn out within a week if it was being constantly written to. Just seems a coincidence that I noticed the fault after a power surge. Very strange…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.