Jump to content

OrangePi Auto On


damies

Recommended Posts

Hi All,

 

Sorry if this has been asked before, I haven't been able to find the answer yet.

 

I wish to configure my OrangePi's (Lite and PC+) such that they power on automatically whenever the power is restored after a power outage without needing to press the power button.

 

I'm not sure where we could configure this as the OrangePi's don't seem to have a bios like a Desktop PC.

 

Dave.

Link to comment
Share on other sites

First, it would not be possible to differentiate between manual power up and power up after power loss (at least more or less reliably).

Second, this board does not have a power button at all, this is "Stand-by/Resume" button, and I believe stand-by feature is not supported in Armbian (however it's possible to configure this button to trigger shutdown or reboot).

 

Edit: turning on after power is applied is the default behavior (unless unclean shutdown/power loss causes significant filesystem corruption)

Link to comment
Share on other sites

Tell me solution to restart button :)

For sun8i-legacy (H3 Oranges and similar):

1. Create a file /etc/udev/rules.d/72-power-button.rules with these contents:

ACTION=="remove", GOTO="power_switch_end"
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="sunxi-gpiokey", TAG+="power-switch"
LABEL="power_switch_end"

2. Create a file /etc/systemd/logind.conf.d/power-button.conf with these contents:

[Login]
HandlePowerKey=reboot

3. Reboot (easiest way to apply both changes)

Link to comment
Share on other sites

First, it would not be possible to differentiate between manual power up and power up after power loss 

 

Actually I don't really care, in my case I just want it to power on and boot up the os after the power is restored regardless of the reason for the power loss. I am planning to embed these boards in a solar powered device, so if the battery goes flat I don't want to be visiting the devices to press the button just to get the OS back up.

 

So I gather I need to change something in /etc/udev/rules.d/72-power-button.rules ? or should that be /etc/udev/rules.d/71-axp-power-button.rules ?

 

Is there some documentation for this file somewhere?

 

Dave.

Link to comment
Share on other sites

I am planning to embed these boards in a solar powered device, so if the battery goes flat I don't want to be visiting the devices to press the button just to get the OS back up.

 

Simply read again what Zador wrote: "Turning on after power is applied is the default behavior (unless unclean shutdown/power loss causes significant filesystem corruption)"

 

The power button doesn't play any role for this on H3 devices but in case you allow that the board's power gets cut you might run into other troubles. You might have to take care of filesystem corruption with your scenario since this will prevent 'powering up' in the meaning of 'booting into a useable state' for sure. :)

Link to comment
Share on other sites

Ok, now I understand. It works by default as I wanted not as I expected.

 

I was planning to use a battery big enough to power it for 24-48 hours without the solar panel and the location gets 10 hours of sunlight in mid winter so it would take several dark days in a row for this condition to occur, so unlikely but not impossible, maybe a couple of times a decade. I just want to make the system as robust as possible.

 

Thanks everyone for the answers here.

 

Dave.

Link to comment
Share on other sites

In my opinion using H3 devices battery powered is not the best choice. I would prefer boards that come with PMIC support (not true for H3, will also not be true for other H SoCs) since all you then need is to wire the battery to the PMIC and get control over battery parameters (shutdown when it goes flat -- on the other hand then you run in exactly the problem you fear turning it automatically on again).

 

Which devices suited for such use cases come with battery support?

  • Any device using Allwinner's 'old' tablet SoCs (A10, A13, A20) or the A13 variants R8 (used on the so called C.H.I.P) or GR8 (next SoC/SBC from NextThing)
  • Devices with A64 for example Pine64 (the non GbE version starting at $15)
  • A33 and maybe R16 (same as A33 but IoT), currently only one rather expensive board available

Nothing as cheap os those H3 thingies...

Link to comment
Share on other sites

You're trying to solve the wrong problem. OPI ONE/LITE power on nicely when you feed them enough juice if they have been shut down cleanly. Your problem is not starting but shutting down the boards cleanly when there is not sufficient power anymore. You'll obviously need some external logic to trigger controlled shutdown, cut power to the OPI and reattach it based on available minimum battery level to safely run the board and not ruin the battery. Good luck with your project. 

Link to comment
Share on other sites

Your problem is not starting but shutting down the boards cleanly when there is not sufficient power anymore. You'll obviously need some external logic to trigger controlled shutdown, cut power to the OPI and reattach it based on available minimum battery level to safely run the board and not ruin the battery.

 

And how should this look like? Someone recommended using an INA219 to me to do voltage measurements a while ago. Could this work? How expensive in the end?

 

In the meantime I thought about simply preventing filesystem corruption instead (overlayfs for example).

Link to comment
Share on other sites

And how should this look like? Someone recommended using an INA219 to me to do voltage measurements a while ago. Could this work? How expensive in the end?

Any ADC (i.e. with SPI or I2C interfaces), MCU like ATtiny25 or comparator with voltage reference can be used, this depends only on programming, soldering and prototyping skills of a person who decides to implement this.

Link to comment
Share on other sites

And how should this look like?

 

For battery-buffered operation ( charging from solar or AC-DC DC-DC chargers ) see http://forum.armbian.com/index.php/topic/1737-optimize-orange-pi-pc-for-power-cut/#entry13467

 

Battery buffers could be stacked in series to prolong runtime without charging or run in parallel to allow hot swapping of power supplies for added robustness.

 

 

 MCU like ATtiny25 or comparator with voltage reference can be used

 

Bingo. Use low voltage on battery side to let ATTINY trigger OPI shutdown via GPIO pin, let ATTINY cut power to OPI after sufficient delay and restart power when sufficient battery voltage is available again.

Link to comment
Share on other sites

Use low voltage on battery side to let ATTINY trigger OPI shutdown via GPIO pin, let ATTINY cut power to OPI after sufficient delay and restart power when sufficient battery voltage is available again.

 

Too much time, too much hassles (for me). I was really asking for a project where some sort of 'data logger' should operate constantly on battery. I remembered that I've bought an Anker powerbank a while ago -- now connected to a Banana Pro measuring provided voltage while discharging (5.13V when Banana is idle, 5.03V when Banana runs cpuburn-a7 -- this will be the mode for tonight with some USB consumers added to Banana Pro to get the power bank flat and have a look whether available voltage will decrease to estimate when powerbank will be empty).

 

Then I'm about to order something for 30 bucks that looks exactly like an Anker 21W 2-Port USB Solar Charger PowerPort Solar. Idea: Combine it with an AXP209 device that can be powered through DC-IN and USB OTG separately. Connect the solar panel to DC-IN, connect the panel's 2nd port to a powerbank that is connected to the device's USB OTG port. AXP209 will take power from solar panel if sufficient, when voltage drops it will use the power bank on OTG port too to compensate and by monitoring voltage available on DC-IN it could be estimated when power bank will start to go flat. At least that's the idea ;)

Link to comment
Share on other sites

this will be the mode for tonight with some USB consumers added to Banana Pro to get the power bank flat and have a look whether available voltage will decrease to estimate when powerbank will be empty

 

The power bank uses a buck converter to load the 3v7 batteries from 5v input and a boost converter to pump the 3v7 up to your needed 5v. The output of the converter may or may not let you estimate the remaining battery capacity. Measure the voltage of the battery and you are set. Charging stops when a target voltage 4v2 of the batteries is reached, discharging stops when a low point e.g. 3v2 is reached.  I combine TWO simple powerbanks by hooking them together on the battery side. Now I can charge through one circuit and discharge through the other simultaneously. Solar panels via step-down converter or various 5v chargers replenish the power bank and the board draws power from the batteries. Tested. Works.

 

 

Too much time, too much hassles (for me).

 

I'm afraid it won't get any simpler than that. Measuring the battery voltage will tell you when to shut down the board.

Link to comment
Share on other sites

I'm afraid it won't get any simpler than that. Measuring the battery voltage will tell you when to shut down the board.

 

It gets simpler if you use an SBC that has everything already on board that's needed. Next step is getting two C.H.I.P. for $9 each: https://irclog.whitequark.org/linux-sunxi/2016-09-22#17642124;

 

AXP PMICs are great since they measure all the time and can be fed with 3 different power sources at the same time (DC-IN, OTG and battery). This allows a lot of different modes to test through, the only open question is whether the device starts automagically when power is provided through DC-IN again (chg-in called with the C.H.I.P.). From other AXP209 equipped devices I know that they power on automagically when fed with DC-IN but require the press of a button when power is provided through OTG or battery connector only. I hope it's the same with C.H.I.P.

 

Edit: with a C.H.I.P. (or any other AXP209 equipped device with battery support that treats DC-IN and OTG differently) you could do some fancy stuff. 

  1. Most simple mode that works always: Attach the solar panel to DC-IN and add a battery. AXP209 will compensate from voltage fluctuations on DC-IN by using the battery partially. If voltage on DC-IN gets too low or no power at all it will rely on the battery only while you're able to measure all the time battery's capacity and can initiate a clean shutdown when a certrain treshold is reached
  2. Different mode: get a dual port solar panel, connect one port to DC-IN (chg-in), the other to a powerbank and the powerbank to OTG. Now AXP209 will take power by default from DC-IN, will compensate voltage drops there by using the powerbank on OTG and since you can monitor this behaviour over time you get the idea when it gets too dark and can estimate how long it will take until the powerbank goes flat to initiate a clean shutdown
  3. More advanced mode: As N° 2 but add a LiPo battery to AXP209's battery connector. This would be the most safe and most expensive mode (and needs some testing since it might be that AXP209 in this mode ignores the powerbank connected to OTG port. If that's the case using solar panel + powerbank on DC-IN would be the better idea, of course combined with a 2nd battery under AXP209 control)

BTW: the cheap Pine64 could also implement N° 1 (not sure whether AXP803 drivers need some attention, at least in pine64 forum a lot of weird stuff is written regarding batteries), but not sure about 2) and 3) since there the OTG port is exposed as normal Type A port normally used to provide vcc-5v to connected USB peripherals

 

Edit 2: 'Any AXP equipped device that is able to...' is not that much, especially if it should be affordable. The rather cheap 'LinkSprite pcDuino3 Nano Lite' (available for $15 in the US) provides neither a battery port nor powering through OTG (hardwired to DC-IN), the cheapest other A20 alternative (Banana Pi) is still pretty expensive, same applies to A10 boards so at the moment we're talking solely about the C.H.I.P. (which is a bargain given that it already comes with 4GB NAND and WiFi/BT) and Pine64.

 

Edit 3: One A10 device which can implement all 3 modes above seems to be sold out currently (can get it for 19,-€ here): https://www.amazon.com/dp/B00I0WUR2Q (performance identical as with C.H.I.P. but more connectors and in case a large disk would be needed Olimex' Lime has an own boost converter to provide power to a connected SATA disk so combining this with a cheap solar panel providing 5V would be enough)

Link to comment
Share on other sites

Of course it is much simpler to solve another problem than the one at hand ;)  The proposed simple solution works with any board.

 

You probably won't believe it but I get that it's possible to use 1 or even 2 powerbanks together with any device that is happy with 5V. The question was: How to determine when the powerbank's battery goes flat?

 

Remember? You proposed 'let ATTINY trigger OPI shutdown via GPIO pin, let ATTINY cut power to OPI after sufficient delay and restart power when sufficient battery voltage is available again'.

 

I wanted to remind those people that only know Raspberries and Oranges that one of the nice features of SBC using tablet SOCs is that they're accompanied by a PMIC (power management IC). All the fancy and time consuming stuff you have to do externally when choosing the wrong device (Raspberries, Oranges) works here internally and out of the box.

 

For me it's either/or:

  • combine a dumb solar panel providing 5V with a $9 C.H.I.P. and any LiPo battery (3.7 V, 2 mm JST) and use Zador's kernel patch to monitor battery's voltage/capacity to initiate a clean shutdown when battery goes flat
  • combine a dumb solar panel providing 5V with 2 powerbanks, a $10 OPi One, an ATTINY and some other fancy stuff, fiddle around with the soldering iron and Arduino IDE...

SBCs making use of PMICs exist, no need to re-invent the wheel :)

 

BTW: The Anker powerbank I discharge since yesterday already shows ~0.07V less when Banana Pro is idle (according to Anker's leds still 40% capacity remaining). Will see this evening if 5V provided to device can be used to determine powerbank capacity (using AXP209, no need for external ADCs, ATTINY, solder iron)

Link to comment
Share on other sites

You probably won't believe it

 

I do actually ;).

 

 

combine a dumb solar panel providing 5V with a $9 C.H.I.P. and any LiPo battery (3.7 V, 2 mm JST) and use Zador's kernel patch to monitor battery's voltage/capacity to initiate a clean shutdown when battery goes flat

 

And this does also recharge batteries while the board is off and restart the board when sufficient juice is available again ?

Link to comment
Share on other sites

And this does also recharge batteries while the board is off and restart the board when sufficient juice is available again ?

 

With AXP209 it's that the device powers on again when sufficient voltage is provided through DC-IN (barrel plug on Olimex A10 Lime, chg-in pin on C.H.I.P.'s GPIO header). I monitored the voltage available through the powerbank I test with and it's not possible to determine battery capacity from voltage behind the boost converter.

 

So with an AXP209 equipped device it's easy: Choose any dumb solar panel that does not need the press of a button to provide power to a connected device and combine it with any LiPo battery with JST 2mm header (those Olimex is selling -- see accessories -- fit also on the C.H.I.P.). This way AXP209 can be used to read out battery capacity / voltage and also whether solar panel provides power or not. Shut down when battery goes flat (20 percent left) to have some reserve when solar panel 'accidentally' powers on the board later.

 

Important: 'special' cables are needed to provide power since the USB OTG port can not be used to power on the board again (would require pressing the power button). For Olimex it would be an USB to 5.5/2.1 barrel cable and for the C.H.I.P. it's USB to jumper wires to access chg-in and GND pins.

 

At the moment it seems Olimex A10 Lime is being sold out (got it for 19,-€ including shipping/VAT) so it's the better deal anyway (Ethernet, real SATA, HDMI, more USB ports). Also C.H.I.P. orders seem to be delayed (again) due to NAND problems.

Link to comment
Share on other sites

Update: I ordered an A10-OLinuXino-Lime in the meantime. This A10 device is roughly comparable to the C.H.I.P. but has more features (true Ethernet, HDMI and real SATA). Bad news: Idle consumption of this board is pretty high. With default Armbian installations we're at around ~1500 mW (a bit less with vanilla).

 

I tweaked some settings (see commits from today) and now we're at 1050 mW idle consumption with mainline kernel. I hoped for less but without drastically reducing DRAM clockspeed or trying to undervolt the SoC at low clockspeeds (and of course switching off the Ethernet PHY when not used) it seems we're not able to fall below the 1W barrier.

 

On the other hand that's more or less comparable with H3 boards like Orange Pi PC or One but there we provide the h3consumption tool to conveniently adjust consumption settings. BTW: It seems with the C.H.I.P. consumption situation is identical: http://www.raspibo.org/wiki/index.php/Chip:_Some_tests_on_power_consumption (but please don't trust blindly in numbers, with some quick tweaks consumption on headless devices can easily be reduced -- but since shipping costs are rather high and production is delayed again I won't get a C.H.I.P. anytime soon to play with).

Link to comment
Share on other sites

So as mentioned above, Orange Pi always starts up is power is applied ( no BIOS setting here)

Then you may want to properly shutdown :

 

Measuring solar power voltage : use INA219 module

example shop : https://www.aliexpress.com/item/Free-shipping-Zero-drift-CJMCU-219-INA219-I2C-interface-Bi-directional-current-power-monitoring-sensor-module/32379404350.html?spm=2114.01010208.3.2.mJh0zY&ws_ab_test=searchweb0_0,searchweb201602_4,searchweb201603_6&btsid=96fb7c32-74f5-4c83-a410-db8234053bd2

 

Check here : https://binaryfury.wann.net/2014/04/solarbatteryload-power-logging-with-raspberry-pi-and-ina219/  has python example script.

 

then you need to change the script to shutdown the sbc some time before the battery is empty, based on the measured battery voltage.

 

Note 1 : I advise to NOT use an acs712 ($ 1.38) as that has very noise results, INA219 ($1.88) is a bit more expensive, but superior)

( But  acs721 us very useful when you want to measuer current with electrical isolation, but you don't need that here.

 

Note 2 : Yes with INA219, the SBC can measure its own power consumption, but that is another story.

Link to comment
Share on other sites

Hello @tkaiser,

 

I find it really interesting the work you've been done to make armbian more IoT-oriented (monitoring and reducing consumption particularly). I'm getting into the SBCs world and my first choice was an Orange Pi Lite some weeks ago. I thought it would be fairly easy to add a battery backup to guarantee clean shutdowns in case of power outage, but I recently learned the importance of PMIC/PMU as other boards have.

 

So now it's time to look for a solution since I wouldn't want to opt for a more expensive board and discard the OPi Lite (as a student, my budget is quite reduced). I have thought of using an AXP209 equipped device as C.H.I.P or OLinuXino A10 and powering the Lite through a USB (or micro USB) port.

 

C.H.I.P seems ideal to act as an UPS due to its lower price (plus onboard Wi-Fi and NAND storage). Also in theory it can supply up to 1000 mA -whereas OLinuXino being limited up to 500 mA- in its micro USB port, but I am still not sure of this. Do you have any experience with similar approaches or maybe I should look for other solutions?

 

On the other hand, is it possible to power an Orange Pi (in this case Lite) through its micro USB port? According to Xunlong's page no, but I have read contradictory information. And at last but not least: if it is turned off, when the power is restored to the micro USB port (in case of being able to use it as DC-IN) it automatically turns on as it happens when we use the power jack?

e Lite

Of course this isn't only aimed at tkaiser, I would appreciate any kind of help.

 

Thanks in advance! :)

 

Edited by Taurus
More information added.
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