Go Down

Topic: Saving data when Arduino turns off. (Read 3048 times) previous topic - next topic


Ok, I admit I don't really know how to integrate a transistor here. I only can put a relay instead. But let's try to calculate the transistor which fits here.
For example we can use a BC547 (Vcbo = 50, Vceo = 45), and assume an Ic = 200mA. I guess Ie = Ic = 200mA. I suposse I need hfe value but in the datasheet there are 3 values:
Classification      A              B             C
hFE             110 ~ 220  200 ~ 450  420 ~ 800
I can't go on with calculations, sorry. Any help?


we can use a BC547 (Vcbo = 50, Vceo = 45),

Then that is fine. Some transistors can not stand the base being that much higher than the collector.


Then that is fine. Some transistors can not stand the base being that much higher than the collector.

If the base goes more than about 0.6V above the collector, then the collector-base junction will conduct, feeding some current to the MCU +5V supply (limited by the 4K7 base resistor), but otherwise doing no harm.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.



I guess that what I am going to ask must have already been asked before, but I promise I have tried hard a lot in order to find it but without success.
I am developing a project with Arduino where it is necessary saving some data when Arduino turns off. I am using the EEPROM to get it.
The problem I have is that I am not really able to DETECT when Arduino is turning off. I use a capacitor which let Arduino keep on for 1 second after power turns off. 1 second is certainly enough since I am saving 10 bytes. I do know the prgramation I have written is ok because I have checked it with a button FALLING like power would do.
I need some circuit so that a digital pin can detect 1 when powering and 0 when turning off. I have tried wiring the input directly to the power but although power turns off, the pin doesn't detect it (I have also tried with a pullup resistor).
Of course I am using an external 5V supply power.

Waiting ideas. Thanks a lot.

I did exactly what you want to do. What I did was this:

(1)  Connect a 4700 uF cap across 5V and gnd to maintain power for a few seconds.

(2)  Used a resistor divider connected to an analog input pin. This serves two purposes: First the program itself monitors the battery voltage and reports when the battery is low. Secondly, the voltage value is checked once for each pass through the main loop and compared to the previous reading. If it drops fast enough (i.e. the difference between two readings is large enough), that is considered a "powering down" condition and then the program saves it's current state to EEPROM, to be re-loaded and resumed at next powerup.

The key is the capacitor to keep the board powered long enough to recognize a shutdown event and then have enough time to write to EEPROM.
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up