UPS3 with Pi3

Post Reply
hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

UPS3 with Pi3

Post by hblanken »

I am quite new to GPIO and different voltages for breakout boards. I have a UPS3 running with Odroid C2 and think it would be an ideal solution also for my Pi3.
http://odroid.com/dokuwiki/doku.php?id=en:odroid-ups3

Could the board be mounted onto a RaspPi3 and work in the same way to provide power for a couple of hours to the Pi?
I know Hardkernel is a separate company, however I would appreciate the community's point of view.

I use the Pi3 for getting video through an HDMI-in shield and the CSI connection at 1080p, something Odroid C2 unfortunately cannot provide. :(

So I need several Pi3 and several Odroids, I like both systems.

So any help to help me get the UPS3 running on Pi would be appreciated. Do I need to watch out for anything, or can I just mount it onto the Pi much the same way it works with my C2. What do I need to change/watch out for? Thanks!

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

You need to check the initial state of Pin#15 or Pin#26 on RPi3 40pin GPIO header.
It must be "High" state in the booting process to enable the UPS3 output power by default.
http://odroid.com/dokuwiki/doku.php?id= ... -c1_c1_c21

hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: UPS3 with Pi3

Post by hblanken »

Thank you.
I have now assembled it onto my Pi3 and it works.

The GPIO 26 is high and receives power at bootup.

I want to write a safe shutdown script, however the pin values give me trouble.

I have now checked GPIO.IN channels 11 and 13 from my Pi.
GPIO.setup(11,GPIO.IN)
GPIO.setup(13,GPIO.IN)

I only get
>>> GPIO.input(11)
0
>>> GPIO.input(13)
1

This happens for all the various scenarios - if I connect AC power only, if I connect AC power and battery, if I only connect charged battery. I always get 11 == 0 and 13 == 1.

Why is this happening?
How can I check if battery power drops below 3.7v to then shutdown the Pi?
Thanks for any help.

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

Do you have a DMM to measure the voltage of AC_OK & BATTERY_OK signals in the schematics?
http://odroid.com/dokuwiki/lib/exe/fetc ... rev0.1.pdf

hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: UPS3 with Pi3

Post by hblanken »

Hi there - I tested with a DMM.

Here are the results:

Tests
a) OFF, with battery connected to board
=> 13 = 3.3V, 11 = 0

b) OFF, with power cord and battery connected to board (blue led on):
==> 13= 3.3V, 11= 0.3V

c) ON, with battery only
==> 13 =3.3V, 11 = 0

d) ON, with power cord and battery (blue led is on)
==>13 = 3.3V, 11=0

What does this tell me? What is happening with pin 11?
How could I code a safe shutdown script with these readings?

Thanks a lot for help.

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

If the Pin 11/13 are output mode on RPi3 40 header, you can't read the UPS status.
I think the pin-numbers in GPIO.setup API could have a different pin numbering.

hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: UPS3 with Pi3

Post by hblanken »

Hi there - I am not sure I understand your reply.

The Odroid C2 11 and 13 pin are at the same location as the Pi3. Take a look at Pi3 Board: http://www.raspberrypi-spy.co.uk/2012/0 ... -and-pins/
Take a look at C2: http://www.hardkernel.com/main/products ... &tab_idx=2

Or am I missing something?
Thanks

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

Exported GPIO number and Wiring number must be different.
For example, Pin#11 is Export_GPIO#247 and Wiring number is GPIO#0 on ODROID-C2.
http://odroid.com/dokuwiki/doku.php?id= ... connectors

hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: UPS3 with Pi3

Post by hblanken »

Now I am completely lost.

GPIO, Export GPIO, Wiring number!? I have no idea how I can ever write a script to read the voltage on the correct pins.

My intent was to use more of these UPS3 on my odroids and PI3s with CSI2 1080p cameras.

But if I am not able to safely shut down the SD card when the battery is low, then this does not seem to be a good solution :(

Can't be that hard to find the correct pin for checking battery voltage, right?

What are we doing wrong in our thinking?

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

Since I don't have any RPI, it is not easy to help you.

According to your link (http://www.raspberrypi-spy.co.uk/2012/0 ... -and-pins/),
Pin#11 is GPIO17 and Pin#13 is GPIO27 on RPi3.
It is the main reason why your script code doesn't work.

Image

hblanken
Posts: 6
Joined: Thu Dec 22, 2016 7:32 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: UPS3 with Pi3

Post by hblanken »

Thank you for your support even without having a Pi3.

I think that PIN 13, wiringpi pin 2 is the pin which lets the power flow into the Pi. It is always high, even if the board is switched off.

When I switch the board on, with the battery connected, then physical pin 1, 17 are high (which is correct as those are the 3.3v pins) AND pin 13 is high as well.

I have not written any script yet - I would like to write a script, however, I first need to identity that the BATT_OK and AC_OK pins have voltage. At the moment only physical pin 13, wiringpi pin 2, has 3.3v, I cannot identify the BATT_OK pin - both pins right next to 13 according to the UPS3 schematics should provide high voltage when turned on, but they are both on 0 when measuring with DMM, why?

According to Odroid specification the pins are exactly the same for Odroid C2 and Pi3, except for 3 pins.

And here is the matching schema for Pi3 and wiringpi pin is 0 and 2 - like on odroid.
http://raspberrypihobbyist.blogspot.com ... agram.html

Do I need to set the AC and BATT pin somehow to enable a voltage measure?

I want to identify the right pin to know that the battery is still strong enough, before triggering a safe shut down

User avatar
odroid
Site Admin
Posts: 41543
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3321 times
Been thanked: 1837 times
Contact:

Re: UPS3 with Pi3

Post by odroid »

If the RPI pins are output mode by default, the voltage will not change.
So you need to set the pin as input mode first.

Or remove the UPS3 from RPI and check the voltage of two pins with DMM.

max_mustermann
Posts: 1
Joined: Fri Aug 11, 2023 12:30 am
languages_spoken: english
Has thanked: 0
Been thanked: 1 time
Contact:

Re: UPS3 with Pi3

Post by max_mustermann »

It's an old thread, but maybe this might be useful to someone. I was facing a similar issue and managed to get it working by adding the following to config.txt:

gpio=17=pu

This sets GPIO pin 17 to pull-up, otherwise the AC power detection wasn't working correctly.

I also had to modify the script provided by Odroid slightly and change GPIO pin numbers to correspond to the RPI 3 numbering scheme. The modified script is attached.

The only part I didn't manage to get working yet is the POWER_LATCH functionality, as GPIO pin 7 always seems to be high even after the Pi has been powered down and setting the pin to pull down in config.txt causes a boot loop. Everything else works including the Pi powering down when the UPS battery gets low, but the UPS stays powered up after the Pi has shut down.
Attachments
ups3.sh
Odroid UPS3 shell script modified to work on the Raspberry Pi 3
(1.37 KiB) Downloaded 7 times
These users thanked the author max_mustermann for the post:
odroid (Fri Aug 11, 2023 9:41 am)

Post Reply

Return to “UPS”

Who is online

Users browsing this forum: No registered users and 1 guest