Jump to content

Is it possible to shutdown properly an OrangePi Zero in case of power loss?


gounthar

Recommended Posts

Hi there,

 

I am about to use an OrangePi Zero to handle the temperature and display some information on a custom contraption related to network.
The problem I have is that this contraption will be powered on and powered off at will, without notice.
So... I guess that after some time, the Zero running Armbian won't be that happy about being shut off brutally.

I have seen some setups with supercapacitors for Raspberry Pis, but has anyone in here tried something similar with the OrangePi Zero? Or anything else that would delay the power loss, so that the board can shutdown properly?
I made searches about supercapacitors with Armbian, but only found some information related to RTC (which would be nice to have too...).
Thanks!

Link to comment
Share on other sites

What about a small powerbank? Either selfmade with a premade PCB and one or two cells or a ready to use one. Just make sure it can be charged and discharged the same time.

Split the input voltage to the powerbank and a GPIO pin. Once it drops create a small script that notice the drop on the GPIO and sends a shutdown command.

Link to comment
Share on other sites

 

21 minutes ago, guidol said:

Do you got a "feature-name" for this option? I think all my powerbanks can be only be charged or dis-charged :( 

Unfortunately no clue. A few years ago I had one bank that supported this but it got broken in the meantime....

Link to comment
Share on other sites

Wait. The PCB was broken, the cells not. And I fixed it that time.

It can be charged and discharged the same time. The problem is that as soon as I disconnect mains the SBC restarts probably due to voltage drop on switch-over. This may be fixable using a small capacitor or something. I found the PCB I bought: https://www.ebay.com/itm/5V-2A-Power-Bank-Charger-Board-Charging-Circuit-Board-Step-Up-Module-Dual-USB/36258955162320200216_181439.thumb.jpg.8961ec5ca21a7a54e400ed1a75b188f8.jpg

Link to comment
Share on other sites

7 hours ago, gounthar said:

I think it is called passthrough, but there may be other names.

That was also my first idea and it redirected me to a thread on reddit which was not that helpful.

I also could not find anything in the ebay description that could suggest such a feature. Probably because it is not fully functional due to the voltage drop mentioned above.

 

Maybe I can find some time and put an oscilloscope in between to see what we are dealing with...

Link to comment
Share on other sites

2 hours ago, MacBreaker said:

I had also had a lot power outages.

 

I bougt a "Bms 18650 Batterie Schild V3 Expansion Board"
(https://de.aliexpress.com/item/32996504176.html?spm=a2g0s.9042311.0.0.1ec64c4da6MXpj) with a 18650 Batterie, and the problen was solved.

 

Interesting. The downside I noticed so far is that the loading current seems to be limited to .5 amps which is not enough if you run certain SBCs with a decent load...

Link to comment
Share on other sites

Thanks for the link. That's very basic, and does not totally address my issue, but that would help anyway.

I would need to shutdown properly when a main power loss is detected, and then start once again when the main power comes back.

Link to comment
Share on other sites

if it does not have to be a all in one package you can still achieve this by reducing the 5V supply to 3.3v somehow (like putting 4 1N4007 diodes in series to create a drop of 2x 0.7 volts and yes, that would be a very crude hack ^^) and put it on a GPIO pin. If there is an outtage the board recognizes it.

Link to comment
Share on other sites

8 hours ago, gounthar said:

Thanks for the link. That's very basic, and does not totally address my issue, but that would help anyway.

I would need to shutdown properly when a main power loss is detected, and then start once again when the main power comes back.

if there would only be a SBC which has on board LIPO charging features with powerdetection and that boardvendor would sell cells which fit to the board...

 

oh wait..

https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXino-LIME2/open-source-hardware

 

such boards exist.. :lol::blink:

Link to comment
Share on other sites

Aight, I was able to do some testing with the powerbank mentioned above and I guess I was lucky I did not kill my board with it. :lol:

An overview:

20200219_060552.jpg.86c4828939c36b52ed30fc2a5a500b40.jpg

 

From the left to right.

First the SBC was powered by the powerbank with close to 5 volts.

Then I attached mains 5v to the powerbank and got a 9 volt spike which luckily was short enough (around 1ms with inclined edges) to not cause any damage.

While charging the voltage drops a bit and seems quite rough.

Then I disconnected mains again and you can see a voltage drop that causes the board to restart. Here it is in high resolution:

20200219_060707.jpg.1e2b4943040eece15ca44212dd6e9818.jpg

The voltage came as mentioned above not very high already, very close to undervolage. The drop to two volts finally kills it and let it reboot as soon as the voltage rises again.

 

tl;dr: I'll discard the idea using the powerbank to create a crude UPS.

 

Link to comment
Share on other sites

You could just add some larger capacitor in parallel to the power bank. If chosen right it should surpress the voltage spike and buffer enough so it does not drop. Might even use more than one to get a better frequency response. Or put a 5.2 volt zener / tvs diode across the board to protect it from the spike. 

 

I can edit this with some wiring later if needed. 

 

EDIT: Some wiring idea:

 

image.thumb.png.fbc23d129e74d78f57dc86c39241c7c9.png

 

Use some resistor voltage divider on the powerbank input (eg. 10k to 10k which gives you 0.5) to get some measurement to your sbc. With the given voltages this would be: 5V in -> 5V * (10k / (10k + 10k)) = 5V * 0.5 = 2.5V .

If you feed this to some GPIO you can either use some analog pin to measure it directly (and initiate shutdown if it goes to low) or you can hook it up to some digital one if you only want to know wether it is high or low. Might need to change the resistor ratio then. Do not exceed your max gpio voltage!

 

On the Powerbank output add either D1 or D2  (zener or transient voltage surpressor diodes) rated for slightly above 5V. These will get rid of nasty voltage spikes for you. Additionally use some small capacitor (to remove high frequency ripple) and some larger one in parallel (to reduce low frequency ripple / voltage drops) to buffer over the voltage drop when powerbank is switching on / off.

 

 

 

Cheers, 

count-doku

Link to comment
Share on other sites

Thanks for the effort but I still will not put any more time into this. The reason is that this powerbank also has bad output voltage as seen above. It is well below 5v and probably close to undervoltage shutdown of the board. Also I did these measurements without any load on the board, just idle OS.

THOUGH, I did measure the stuff via GPIO and powered it through DC jack so the voltage drop across the board is included. But this could also be solved only by increasing the input voltage which is not possible and not worth the effort.

Link to comment
Share on other sites

Yeah that might work.

 

Keep in mind though that this module will still output 3.3V if the input is lower than 5V. Checking the datasheet http://www.advanced-monolithic.com/pdf/ds1117.pdf it seems like this regulator has a dropout voltage of about 1.2V. So 4.5V input would still allow this module to output 3.3V signaling to your SBC that everything is OK while at 4.5V input to your SBC it will probably fail.

 

This is obviously not ideal!

 

EDIT: Easiest way to do it would be to instead of the converter just use a potentiometer (10k or something like that). Connect the ends to 5V and GND, and adjust it until the slider is at about 3V (measure with multimeter). Then attach the slider pin to some GPIO and check GPIO state. Keep turning down the voltage just until the GPIO reads as LOW. Turn back up a bit until it is HIGH. Then once the input drops below 5V the poti output will also drop slightly causing the GPIO to go LOW -> use this as shutdown. 

 

This is also not perfect, beware: never turn the poti to high (watch out for anything >3.3V on your GPIO) also you might have to experiment 'till you have a good setting. Minor power fluctuations should not cause a shutdown. 

Link to comment
Share on other sites

Nice, I have received the same kind of boards lately, but I'm afraid it is too simple. It won't allow to balance the charge for several batteries, so I have to use just one (which is perfectly fine for my use), and I'm not sure of how it will behave when the main current stops.
I have to make tests (replacing the SBC with a USB fan for example).
What worries me about your board is

Quote

1.Don't use output to connect more than 1200mA devices;otherwise, PCB will burn

I know most of the time, our loads don't need much current, but I would not leave this board doing its job far away from sight.

 

Other charging PCBs are on their way to my home, so that I can do more tests.

Link to comment
Share on other sites

Two new boards have been tested.
This one did not work for me, partially because I did not understand what it is supposed to do... It's written in Chinese, and I have not been able to get 5V out of it... yet, only 4.2V.

This second one worked for me despite my very crude soldering job and the salvaged 18650.
So, after a few dozens of minutes charging the battery, I just unplugged the power on the charging board, and did not get any error on the OrangePi Zero...
Now, I would like to get some information on the voltage and other relevant information on the board to see if that's working properly, or if it's just luck...

And... I have to plug the 3.3V step down converter to one GPIO pin (linked to the main power), and see what's going on.

HTB1sGX7SyrpK1RjSZFhq6xSdXXaE.jpg

HTB1HG.ZXjzuK1RjSspeq6ziHVXaI.jpg

Link to comment
Share on other sites

So... I was thinking of using this library to detect the voltage drop on one GPIO pin.
I have checked and the converter board I found goes from 3.3V to 0V in a heartbeat.

I have not yet found a definitive OrangePi Zero GPIO guide for dummies, so if you know one, or just the pin I could use for that, please let me know.
I suppose we could get inspired by this clean shutdown project.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines