gounthar Posted February 15, 2020 Posted February 15, 2020 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!
Werner Posted February 16, 2020 Posted February 16, 2020 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.
guidol Posted February 16, 2020 Posted February 16, 2020 8 hours ago, Werner said: Just make sure it can be charged and discharged the same time. Do you got a "feature-name" for this option? I think all my powerbanks can be only be charged or dis-charged
Werner Posted February 16, 2020 Posted February 16, 2020 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....
Werner Posted February 16, 2020 Posted February 16, 2020 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/362589551623 2
gounthar Posted February 16, 2020 Author Posted February 16, 2020 6 hours 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 I think it is called passthrough, but there may be other names.
Werner Posted February 17, 2020 Posted February 17, 2020 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... 1
manuti Posted February 17, 2020 Posted February 17, 2020 This Pimoroni board do: LiPo SHIM ► https://shop.pimoroni.com/products/lipo-shim But is conceived for Raspberry Pi (maybe it can be adapted) and is not cheap. This is the script to control de Clean Shutdown ► https://github.com/pimoroni/clean-shutdown
MacBreaker Posted February 17, 2020 Posted February 17, 2020 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. 1
Werner Posted February 17, 2020 Posted February 17, 2020 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... 1
gounthar Posted February 17, 2020 Author Posted February 17, 2020 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.
Werner Posted February 17, 2020 Posted February 17, 2020 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. 1
chwe Posted February 18, 2020 Posted February 18, 2020 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.. 1
gounthar Posted February 18, 2020 Author Posted February 18, 2020 Nice one, unfortunately way too expensive for my projects...
lampra Posted February 18, 2020 Posted February 18, 2020 Not sure if this is applicable on armbian or if it could fit your case but maybe you could use extroot overlay. Take a look here in the case of openwrt. 1
Werner Posted February 19, 2020 Posted February 19, 2020 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. An overview: 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: 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. 1
Heisath Posted February 19, 2020 Posted February 19, 2020 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: 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 1
Werner Posted February 19, 2020 Posted February 19, 2020 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.
Heisath Posted February 19, 2020 Posted February 19, 2020 I was not expecting you to put more time into it. It was more directed at the original poster, to address the issues pointed out by you. And to give him an idea what he could do to make it work with a powerbank... 1
gounthar Posted February 19, 2020 Author Posted February 19, 2020 Thanks for the ideas @count-doku. I don't think I'm able to do it by myself, but I will get some help and try to implement it.
gounthar Posted February 23, 2020 Author Posted February 23, 2020 I found another circuit with supercapacitors, but have no idea of the price.
gounthar Posted March 3, 2020 Author Posted March 3, 2020 It may be too simple to be a good idea. What if I used a step down converter to output 3.3V (taken from the main 5V) on a GPIO pin? I found some at 0,26€... Coupled to the 18650 charger @MacBreaker was referring to, I could get what I need?
Heisath Posted March 3, 2020 Posted March 3, 2020 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. 1
gounthar Posted March 4, 2020 Author Posted March 4, 2020 Thanks a lot. My ultimate goal would be to have a board designed by a colleague that knows how to do it properly. I will give him all the information found in this thread.
Werner Posted March 27, 2020 Posted March 27, 2020 I just received this little guy: https://www.ebay.de/itm/USB-Li-Po-18650-5V-1A-Lithium-Battery-Protection-Boost-Step-up-Charger-Board/153077054028?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2648 Connect one or multiple 18650 cells to it and it will act as UPS. Working very well. 1
gounthar Posted March 28, 2020 Author Posted March 28, 2020 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.
Werner Posted March 28, 2020 Posted March 28, 2020 14 minutes ago, gounthar said: Other charging PCBs are on their way to my home, so that I can do more tests. Keep us updated 1
gounthar Posted April 6, 2020 Author Posted April 6, 2020 I tested two of the boards I received a few days ago. There is a 1s gap between main power loss and batteries starting to give power. https://youtu.be/fcUTzm3je9w https://youtu.be/zKAVTx7NDgQ I still have a few different boards to try.
gounthar Posted April 9, 2020 Author Posted April 9, 2020 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. 1
gounthar Posted April 10, 2020 Author Posted April 10, 2020 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.
Recommended Posts