Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: mauricio on March 17, 2014, 06:08:46 PM

Title: How to know when A20 is running sourced by barrel power jack or not ?
Post by: mauricio on March 17, 2014, 06:08:46 PM
using A20 with Debian image, sourced by a 9v ac adaptor

I'm trying to use a battery connected to jst as a UPS, principally while closing some processes and shutdown in an eventually failure of the main power (220v)

I can't figure out how to know when the board is sourced through barrel or not, is there a way to know about ?

I would like to use a python script running as a daemon

please, any advice will be appreciated

thanks in advance
Title: Re: How to know when A20 is running sourced by barrel power jack or not ?
Post by: codifies on March 18, 2014, 06:28:58 AM
I'm not on the device but from memory look in

/sys/class/power I think? Have a dig around !

There are folders for ac and battery, if current_now in battery is zero there's a good chance its using mains!

You can also pick up the battery percentage too

A simple cron job every 5 mins or so to check ac and then battery percentage should be simple to make...

if you thing you have a high drain the battery might stop supplying sufficient current before it reaches 0% so you may want to test the battery to exhaustion a few times recording %age

Title: Re: How to know when A20 is running sourced by barrel power jack or not ?
Post by: mauricio on March 18, 2014, 11:53:59 PM
great !

that's it !

thank you a lot !