Arduino Power Loss Detection with 2 Components - Saving State to EEPROM

preview_player
Показать описание
Short(ish) overview on a very simple way to detect wether your Arduino project is loosing power.

Usually when such an event is detected, you'd want to save variables you wish to survive reboots to EEPROM (be it internal or external)

Рекомендации по теме
Комментарии
Автор

Man, such a great idea. I watched it twice to get it and then I was like "aha". Thank you for sharing it.

majedmohammad_
Автор

Thank you for showing this very nice approach to handle power loss. Power loss can come in more forms. It can be some external fault, that will create a ripple voltage on the supply of 100 Hz or 120 Hz. It can also be a short time power voltage dip due to a neighbor having a short circuit in his home. I guess it is "next level" to decide what to do in such situations.

sewingmachinesindetail
Автор

Excellent tutorial. Been looking for something like this. I needed to write lots of times which was proving to be messy. This method works beautifully. The only adjustment I made was that I didn't use the system timers. I used a delay function "if (millis() - previousMillis >= interval)". Thanks for the video man.

Arcademan
Автор

Its actually very difficult to read your code. Could you please paste it in the comment? Thank you!

dreamlessfull
Автор

Great idea. Many have tried to resolve this. You have a very original approach. This worked for me. I needed to be careful during testing. I didn't want to put the CPU in a loop that wrote to the EEPROM. The LED that goes on is a great sanity check. Interesting how the voltage jumps above 1000 when power is lost.

gladiator
Автор

Thanks!! Great Idea and Really Very great tricky way to know power down in arduino.

anooptiwari
Автор

Great! This was just the thing I was searching for. I was looking for a solution to store a position-value of a stepper to the EEPROM when there is a powerloss. But only then because of the limited cycles of the EEPROM. Your scematic works almost perfect. I found out there is a peak of 5v when the cap is being charged using your scematic. So in my case as an addition to a power loss, everytime the cap is being charged it writes away to the EEPROM. This reduces the lifetime of the EEPROM significantly. Therefore I tried to ad a voltage devider to your scematic. It seems to work now whitout the peaks of 5V when the cap is beging charged and only 5V when there is a power loss. I used 22k and 220k resistors for the voltage-devider to keep the charged peak around 4.5V. My knowledge of electronics is quite limited, so I'm not sure this is the way to go but it seems to work.

ismailtan
Автор

Hello and thank you very much for this outstanding tutorial.
I'm working on a small project with the ATTiny84A and need to save to EEPROM at power loss but not having much luck. Is this even possible with the ATTiny84A? Best Regards!

vinnyp
Автор

Have a confusion, the moment powercut happens, after that how much millisecond does the module has to save in eeprom !

Also if there is too much code, loops - in that case will this example work ?

sohan
Автор

I am trying to make a power loss counter, what happens to the Counter / incremental register when the reset button is pressed? Does that is equivalent to power fail state? I had coded as you said, but on reset button press its incrementing counter of no. of time power failed. any comments ?

hacker
Автор

Buddy, I followed this and it worked. However, a few things I noted.

1) We are charging the bulk capacitor off the 5V o/p of Arduino. At power loss, we are feeding back to the same port the voltage from Capacitor. Is this allowed? Shouldn't Arduino be run via Vcc pin if not from USB port and barrel pin connector for external power supply.
2) I used 5.5V 1F Super capacitor. It gave me 30 seconds of ON time after power loss. However, within a day, I have spoilt 3 Super capacitors. They initially work for 30+ seconds and provide enough current. After 3-4 trials, suddenly their current capacity drops. They still hold voltage but no current.

Not sure what am I doing wrong.

I am trying to add a diode for charging super cap so there is no reverse current. Will feed + of diode to AREF. Use a boost converter to step up to 7+ volts and feed to Vcc pin of Arduino.

Do you have any suggestions?

dafpnp
Автор

I am little confused why we need charge that analog pin side cap ?

berkcan
Автор

In my circuit GSM module included..when i added this power loss detection function in my program, gsm module doesn't doesn't read incoming sms...why this happened

Microsree
Автор

Great job and thanks. A suggestion for the coding, you can use "else" instead of using return. I tried your code and it works perfectly. Thanks for the brilliant idea!

kenchia
Автор

Would this still work on arduinos that are 3.3V w/ 5V on Vusb?

choilive
Автор

Just curious. How would you execute this if the unit was powered through the VIN pin and the capacitor would stabilize the VIN pin if power was loss prior to that part of the circuit?

longlivekel
Автор

This is a great concept and it worked with my Arduino UNO.
Is there a way to connect a type of battery that is better than a capacitor?

timonsmind
Автор

Thanks Darieee. I did make use of this idea for one of my Arduino project named Multi Player Score Tracker.

shajeebtm
Автор

Great tutorial and forks fine for arduino.
I am trying to implement this this for ESP8266. I used basic timer in loop to make sure there will be no problem with timer library and it works for arduino, but does not work for ESP8266.
I am testing with voltmeter and getting 0V reading form A0, whereas on arduino it is above 4V.
Do you have any ideas what can be wrong?
Thanks in advance.

oom
Автор

Hey man, ive been looking for better way to write into eeprom on powerloss and came to the right place. Thanks for this wonderful tutorial. Btw, is 25v capacitor enough for 22uf and 1000uf?

karti
welcome to shbcf.ru