Introduction

The ODROID-UPS3 (Uninterrupted Power Supply) device is designed specifically for the ODROID-C1,C1+ and ODROID-C2.
It is equipped with a rechargeable Lithium-Polymer Battery, Charger IC and 5Volt Boost DCDC.

When the AC power source is removed, the UPS3 keeps supplying the power to the ODROID boards with the battery.
There is a digital output pin to send the battery low-level warning to the ODROID to trigger the shutdown process.
It will significantly reduce the risk of data loss by sudden power loss.
When the AC power source becomes available again, the UPS3 will supply power to the ODROID again automatically.

201604191444388644.jpg

Because of LiPo chemical characteristics, Battery Level can go little high when the load is quite light.
If your device reboot after shutdown, you should add a more delay after low battery alarm.

Specification

Power Input
Dc Input Voltage DC 4.8~ 5.4V
DC Input Current 2A Min.
Charger
Charging Time 3 ~ 4 hours
Battery Charging Current 1A Max.
Power Ouput
DC Output Current 2A Max.
DC Output Voltage 5 V
Battery Pack
Type Lithium-Polymer
Capacity 3000 mAh typical
Nominal Voltage 3.7 V
Battery Life 400 charge/discharge cycles @ 20℃±5℃
Integrated Protection PCBOvercharge/discharge Protection
ODROID-C2 Estimated Running Time with typical load of 500mA @ 5V about 3 hours when fully charged

Schematic: ODROID-UPS3 for C series

PCB Layout(DWG):ups3_board_rev0.1_mech.zip

PCB Pattern(PNG):ups3.zip

When the battery was fully charged(VBAT=4.2V), we performed the load test with UPS3.

Time to power-off at the Load

Current Time to power-off No Load Output voltage Output voltage at the Load VBAT
2A 25sec 4.97V 4.65V 4.14 V
1.8A 140s 4.69V 4.12 V
1.6A 450s 4.71 4.05V
1.4A 810s 4.73V 3.98V
1.2A 1470s 4.81V 3.95V

If your C2 takes 800mA and USB devices take 850mA, the UPS3 can supply the power to your system around 3~4 minutes at least.
It seems to be fine to shutdown the system safely.

LED Indicators

BLUE LED(D1)

  • Illuminated when power is connected and battery is charged
  • OFF when charger is idle:
    1. Battery is fully charged
    2. Power is not connected or shutdown
  • Rapidly blinking when power is connected but battery is not connected

Power Status Indicator & Control Pins

  • AC_OK output pin (pin#11 of J2) is high when the AC source is available.
  • BAT_OK output pin (pin#13 of J2) is high when the battery voltage is higher than 3.7V.
  • POWER_LATCH input pin (pin#15,26 of J1) must be high to supply 5V to the load.

How to configure HW

Set up switches

  • SW1 - Output on/off

The slide switch, SW1 is to control the 5V supply to the ODROID.

  • SW2 - Board select

UPS3 supports C1/C1+ and C2.
You need to select the model using the slide switch, SW2.

Ensure that slide switch SW1 is to the left to enable power output.
Even when SW1 is off, the charging function keeps working.

Assemble guide

Assemble as the UPS3 as shown in Figure.

201604191155298511.jpg

Pin assignment to configure SW

There are three signals to control auto shutdown and wake-up based on battery status.

  • AC_OK : The AC_OK pin is high when the AC source is available.
  • BAT_OK : The BAT_OK pin is high when the battery voltage is higher than 3.7V.
  • POWER_LATCH : This pin must be high to supply 5V to the load.
AC_OK BAT_OK POWER_LATCH
Pin GPIO Pin GPIO Pin GPIO
C1/C1+ 11 88 13 116 15 115
C2 11 247 13 239 26 225

The BAT_OK and AC_OK signals are used to monitor the current AC and battery status
and turn off system based on the status.
You can find setup examples with the signals for Ubuntu and Android in the following sections.

How to configure SW (1) - Ubuntu

On Ubuntu, a common scheduling utility, cron daemon can be used with a script
to monitor the AC and battery status and control system shutdown by controlling three signals of UPS3.

Auto shutdown Script

This script checks the status of power and battery.
Save the following code as ups3.sh in home directory.
Note that this script can be used with U3 as well as C1/C1+/C2 without modification.

Let's assume that ups3.sh is located in /home/odroid/ups3.sh.

#!/bin/sh
MODEL=$(cat /proc/cpuinfo | grep ^Hardware | awk -F " " '{print $3}')
SYSFS_GPIO_DIR="/sys/class/gpio"
 
retval=""
 
gpio_export()
{
        [ -e "$SYSFS_GPIO_DIR/gpio$1" ] && return 0
        echo $1 > "$SYSFS_GPIO_DIR/export"
}
 
gpio_getvalue()
{
	echo in > "$SYSFS_GPIO_DIR/gpio$1/direction"
        val=`cat "$SYSFS_GPIO_DIR/gpio$1/value"`
        retval=$val
}
 
gpio_setvalue()
{
	echo out > "$SYSFS_GPIO_DIR/gpio$1/direction"
        echo $2 > "$SYSFS_GPIO_DIR/gpio$1/value"
}
 
if test $MODEL = "ODROIDC"
then
        AC_OK_GPIO=88
        BAT_OK_GPIO=116
	LATCH_GPIO=115
	gpio_export $LATCH_GPIO 
	gpio_setvalue $LATCH_GPIO 1
elif test $MODEL = "ODROID-C2"
then
        AC_OK_GPIO=247
        BAT_OK_GPIO=239
	LATCH_GPIO=225
	gpio_export $LATCH_GPIO 
	gpio_setvalue $LATCH_GPIO 1
else 
        AC_OK_GPIO=199
        BAT_OK_GPIO=200
fi
 
gpio_export $AC_OK_GPIO
gpio_export $BAT_OK_GPIO
gpio_getvalue $AC_OK_GPIO
if [ $retval -eq  1 ]
then
        echo "DC Input Okay"
else
        echo "Power is shutdown or AC Adaptor is disconnected"
        gpio_getvalue $BAT_OK_GPIO
        echo $retval
        if [ $retval -eq 0 ]
        then
                echo "battery is lower than 3.7V"
                /sbin/shutdown -P 1
        else
                echo "battery is good"
        fi
fi

Give execute permission to everybody with following command.

$ sudo chmod a+x /home/odroid/ups3.sh

Cron setup

This can be set up by running crontab.

$ sudo crontab -e

This example script will run ups3.sh script every 2 minutes.

# m h  dom mon dow   command
*/2 * * * * /home/odroid/ups3.sh

To confirm that cron works with ups3.sh, check the syslog.

$ tail -f /var/log/syslog
...
...
Jul 25 04:53:01 odroid64 CRON[1824]: (root) CMD (/home/odroid/ups3.sh)
Jul 25 04:53:01 odroid64 CRON[1823]: (CRON) info (No MTA installed, discarding output)
...
Jul 25 04:55:01 odroid64 CRON[1960]: (root) CMD (/home/odroid/ups3.sh)
Jul 25 04:55:01 odroid64 CRON[1959]: (CRON) info (No MTA installed, discarding output)
...

Depending on the particular Battery State of Charge (SOC), this script can issue a reboot a few times based on the specific load.
This means that the battery voltage can go over the threshold level very quickly when the load is off.
However, it will turn off the board after cycling the power a few times.

How to configure SW (2) - Android

Android packages that are released since the following version already include UPS3-related implementations.
Please check your Android version first.

  • ODROID-C2 - Android 5.1.1 V3.5
  • ODROID-C1+ - Android 4.4.4 V3.7

If you have an older version, follow the whole process of this manual.
If not so, you only need to block “disable” part of ups3 service in /init.odroid2.board.rc or /init.odroid.board.rc.

On Android, you need to register the monitoring script, ups3.sh in android init rc.

Auto shutdown Script

Here is an example script for Android and the default path is /system/bin/ups3.sh.


#!/bin/sh
SYSFS_GPIO_DIR="/sys/class/gpio"
 
retval=""
 
gpio_export()
{
	[ -e "$SYSFS_GPIO_DIR/gpio$1" ] && return 0
	echo $1 > "$SYSFS_GPIO_DIR/export"
	echo $1
}
 
gpio_getvalue()
{
	echo in > "$SYSFS_GPIO_DIR/gpio$1/direction"
	val=`cat "$SYSFS_GPIO_DIR/gpio$1/value"`
	retval=$val
}
 
gpio_setvalue()
{
	echo out > "$SYSFS_GPIO_DIR/gpio$1/direction"
	echo $2 > "$SYSFS_GPIO_DIR/gpio$1/value"
}
 
check()
{
	gpio_export $AC_OK_GPIO
	gpio_export $BAT_OK_GPIO
	gpio_getvalue $AC_OK_GPIO
 
	if [ $retval -eq  1 ]
	then
		echo "DC Input Okay"
		lowVoltageCount=0
	else
		echo "Power is shutdown or AC Adaptor is disconnected"
		gpio_getvalue $BAT_OK_GPIO
		echo $retval
		if [ $retval -eq 0 ]
			then
				echo "battery is low than 3.7V"
				sleep 118
				lowVoltageCount=$(( lowVoltageCount+1 ))
				if [ $lowVoltageCount  -gt 5 ]
				then
					echo "power off"
					am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN --ez KEY_CONFIRM true --activity-clear-task
				fi
		else
			echo "battery is good"
		fi
	fi
}
 
MODEL=`getprop ro.product.board`
echo $MODEL
 
if [ `echo $MODEL | grep -c "odroidc2"` -gt 0 ]
then
	AC_OK_GPIO=247
	BAT_OK_GPIO=239
	LATCH_GPIO=225
	gpio_export $LATCH_GPIO
	gpio_setvalue $LATCH_GPIO 1
elif [ `echo $MODEL | grep -c "odroidc"` -gt 0 ]
then
	AC_OK_GPIO=88
	BAT_OK_GPIO=116
	LATCH_GPIO=115
	gpio_export $LATCH_GPIO
	gpio_setvalue $LATCH_GPIO 1
else
	AC_OK_GPIO=199
	BAT_OK_GPIO=200
	LATCH_GPIO=204
	gpio_export $LATCH_GPIO
	gpio_setvalue $LATCH_GPIO 1
fi
 
lowVoltageCount=0
while true
do
	check
	sleep 2
done

Register the monitoring service in Android init

To enable UPS service, add a service routine in the Android init rc.
For each model, the default path is different.

  • C1/C1+ : /init.odroid.board.rc
  • C2 : /init.odroid2.board.rc
shell@odroidc2:/ $ su
root@odroidc2:/ # mount -o rw,remount /
[  298.823337] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
root@odroidc2:/ # vi /init.odroidc2.board.rc
service ups /system/bin/ups3.sh
    class core
    user root                                                                
    group root
#    disabled
    oneshot

As aforementioned, ups3.sh and init routine are added by default since a specific Android version.
If you have the new version, only make sure to block disabled part of ups3 service in /init.odroid2.board.rc or /init.odroid.board.rc.

Tip for servo or motor driving application

Reported by Ameridroid
Remove the voltage detector IC (Reference number is U3 on the UPS3 & UPS2 board schematics)

While developing a walking robot that uses the UPS2 with ODROID-C1, we found the UPS2 would shut off while moving servos after only a few minutes. We were led to this modification that WILL void your UPS3 & UPS2 warranty, but will likely solve your issues.

Without this modification, we would get less than a few minutes of runtime out of our walking robot.
After the modification, we could get over an hour.

ODROID FORUM

You can find a nice video in the above link that explains how to mod the UPS2 board.