Affordable UPS Solution: Ensure That Your ODROID-HC2 Has 100% Uptime

UPS with ODROID-HC2

A lot of NAS systems have an Uninterrupted Power Supply (UPS) to protect their valuable data from accidental corruption due to loss in main power.

This article helps you build an UPS for the ODROID-HC2 using some off-the-shelf parts. It is based on an inexpensive mini DC UPS, which I believe is good alternative to expensive UPS’s. This mini DC UPS offers 12V output. This is stepped down to 5V using two resistors as voltage dividers.

Following are the steps to create your own UPS.

Parts List

Disassemble mini DC UPS and Wiring

The mini DC UPS has two parts: one is the PCB and the other is a battery.

Figure 1
Figure 1

Figure 2
Figure 2

The battery connector of the PCB offers the 12V output. The soldered red wire is at +12V and the black wire is ground (GND).

ADC Reference voltage Changing

The USB IO Board can be setup for the default 3.3 V or 5 V, based on the the position of R1 (soldering is required). The selection becomes the ADC reference voltage.

Figure 3
Figure 3

I have decided to use 5V ADC reference voltage. I soldered the R1 resistor to VBUS 5V from 3V3 on the PCB.

Define value of resistors

Using two resistors 10 KOhm( R1) and 7.143 KOhm (R2), we can divide the 12 V output to 5 V and 7 V using the formula: 12V x ( R2 / (R1 + R2) ) = 5V For example, if R1 is 10,000 Ohm, R2 is about 7,143 Ohm.

However, since there is no 7,143 Ohm resistor out there, I used a 10 K potentiometer. With my selection of R1 of 9.98 KOhm (5 V) and R2 of 7.44 KOhm (7 V) I observed the mini DC UPS offering slightly less than 12V when charged fully. I increased the R2 value a little more to get an ADC value to a full 10 bit value of 1024.

Figure 4
Figure 4

The circuit diagrams are below:

Figure 5
Figure 5

Figure 6
Figure 6

Figure 7
Figure 7

Define the Maximum & Minimum ADC value

Build the software using the following commands:

$ sudo apt-get install libusb-1.0-0-dev
 $ git clone https://github.com/hardkernel/Odroid-USBIO
 $ cd Odroid-USBIO/usbio/linux
 $ make
 $ sudo ./usbio
Then the sequence of options is: a. Toggle LED b. AN0/POT Value c. Button status d. Get Register e. Set Register f. Get Register Bit g. Set Register Bit q. Exit

Use the following values:

msb = 512, lsb = 212 potentiometerValue = 724

I have set the maximum ADC value to 1023 (10 bits all high) by manipulating R2 when mini DC UPS is charged fully. We have to know the minimum ADC value to see remaining battery level. I have found this minimum ADC value to be 724 by giving some load like, stress app to the system supplied power using mini DC UPS only.

This following script helps me to get minimum ADC value.

# cat -n batCheck.sh
 #!/bin/bash

for i in {1..100000}
 do
 ./usbio << endl >> ./adcValue.log
 b
 q
 endl
 echo "`date +%Y/%m/%d-%H:%M:%S` : ${i}"
 sleep 2
 done
 # nohup ./batCheck.sh &

Remaining battery level

Now that we have figured out the maximum and the minimum ADC value, we can calculate the remaining battery level. You may refer to the shell script in the Wiki article.

Remaining battery level(%) =
 (ADC value - minimum ADC value) x 100
 --------------------------------------
 (1023 - minimum ADC value)
As noted before, the minimumADC value was found to be 724 by experimentation, so I set the minimumADC value is 800 by a wide margin in this script. If the remaining battery level of the mini DC UPS is lower than 10 % as I set ${minRemainBat} in the script, it is going to invoke the shutdown procedure.

Reference

For more information, please refer to the wiki article at https://goo.gl/zMwFbf.

Be the first to comment

Leave a Reply