Raspi UPS HAT Board

From Geekworm Wiki
Jump to navigation Jump to search

Geekworm UPS HAT V1.1 Front
Geekworm UPS HAT V1.1 Back
Geekworm UPS HAT V1.1 + 2600mAh Battery
Raspberry Pi UPS HAT Board V1.0 + 2500mAh Battery
Raspberry Pi UPS HAT Board V1.0 + 2500mAh Battery
Raspberry Pi UPS HAT Board V1.0
Raspberry Pi UPS HAT Board V1.0 + 2500mAh Battery

Instruction

NOTE: we released the last UPS HAT 3 on May. 2020.

Features:

  • Standard dimension of Raspberry Pi HAT, and it's compatible with all of the expansion board.
  • Cascading design saves space while powering raspberry pi and expansion boards without affecting GPIO expansion.
  • Support up to 2A quick-charge technology, can rapidly charge full the battery.
  • Can be charged and supplied power to raspberry pi at the same time.
  • With 4 LED power indicator;
  • Provides an example code to beginner to demonstrate how to demonstrate battery capacity displays the current battery level in the raspberry pi current program, it can detect the current battery, voltage etc.
  -- Applicatoin scene 1: You can program to control automatic backup of data at low power and safe shutdown.
  -- Applicatoin scene 2: Remind users to charge at low battery levels. etc.)
  • Removable battery, user can choose a more larger capacity lithium battery pack (NOTE: voltage must be 3.7V).
  • With safety protection circuit to prevent overcharge and over discharge.
  • Retains the raspberry GPIO interface, you still can use all kinds of expansion board;
  • It is Mini UPS power supply; maximum 5V / 1.5A output, and maximum 5V / 2A input.

Note:

  • The last version is V1.1. We use another power management chip, but it has exactly the same features witch V1.0. The only difference is that you need to press the button for a little longer when you shut down.
  • The capacity of Lithium Battery is 2600mAh, But you can use the more big capacity battery. PS: Voltage must be 3.7V
  • The USP HAT will provide power to Raspberr pi via GPIO pin;
  • Don't connect the micro USB to rasberrry pi; please connect the micro USB to UPS HAT board;
  • Connector specification is: PH 2.0 2-PIN connector

Two algorithm to obtain Battery capacity

Voltage estimation algorithm

Obtain the voltage, then estimate the current battery capacity by the following rules.

Charging
LED VBAT (Voltage of Battery)
1 to 2 3.622
2 to 3 3.832
3 to 4 4.043
FULL 4.182
Discharging
LED VBAT (Voltage of Battery)
4 to 3 3.74751
3 to 2 3.501
2 to 1 3.35
Off 2.756

Coulomb meter algorithm

Please refer to Raspi UPS HAT Board#how to USP HAT use via i2c

PS:

But because every battery has its own different features so UPS HAT need to take time to learn and adapt it.

Driver and Sample code

File:Rpi-ups-hat-20190621.zip File:Rpi-ups-hat.zip this is old version.

File:UserManual.pdf

How to use UPS HAT via driver

Please refer to How to use UPS HAT via driver

How to USP HAT use via i2c

In fact, you can use i2c to obtain the battery capacity and voltage. This python sample code is from a buyer friend, his name is Joachim, thank your very much.


  • File:Ups-hat-c.zip, this is C language source code from a friend, his name is Chris, thank your very much.

How to use it?

unzip File:Ups-hat-c.zip to get main.c

compile like this

gcc main.c -o ups-read

run with sudo

if no switches the it gives only integer percentage

if -v switch is used gives voltage

if -c gives full percentage

both switches can be used together

if you include it in sudoers config like this %wheel ALL = (root) NOPASSWD: /sbin/ups-read

then it can be run without password, ideal for displaying the percentage in a desktop toolbar

if you have any questions please do ask...

The LED and UPS Switch

IMG 0108.jpg

IMG 0110.jpg Charging LED.jpg

USB to Dual Micro USB Charging Cable

NOTE: the switch is disabled when you use USB to Dual Micro USB charging cable;

The raspberry pi will be power on automatically after the battery capacity is be exhausted when you use the one to two USB cable.

IMG 2344-how to work.jpg

FAQ

1.Is there a way to know if the battery is being charged or not?

Answer:

There is no direct way to know if the battery is being charged or not. BUT you can get many time volatage in a short time, then judge the volage value. For example: In 20 second, we get the 20 volatage value: 5.11v,

5.08V,

5.04V

5.01V

4.99v

... thus we can know the battery is charging. because the voltage value is raising...

2. What pins of the Raspi header does the UPS hat occupy?

Answer: Only 5V, GND, I2C (SDA, SCL) are occupied.


3. Can a physical power button be used to trigger a custom user script?

Answer: Sorry, not support!

Is there an API that allows us to detect whether the UPS is connected to an external power adapter or is using battery power only?

Answer: Sorry, no!

Add your comment
Geekworm Wiki welcomes all comments. If you do not want to be anonymous, register or log in. It is free.


Anonymous user #51

8 months ago
Score 0++
it seems if you short out power switch and dual power connected then it works the way ups does, soon as power is applied battery get charge and pi is up and running then power goes out pi continue running on battery until battery dies, add voltage divider for 5v input power to any GPIO pin to detect power outage. it works the way my needs.

Anonymous user #50

26 months ago
Score 0++
we have purchased a few of these and are attempting to design a 3d printed case. is there a cad file available?

Anonymous user #49

29 months ago
Score 0++
checkbilly@qq.com; 13601735618

Anonymous user #48

33 months ago
Score 0++
Is it possoble to mount solar panels (pv) to she shield?

Anonymous user #47

38 months ago
Score 0++
This is mind blowing information. thanks for sharing this precious information with us,

Anonymous user #46

40 months ago
Score 0++

Some days ago, microswitch break out. I received new microswitch and soldered again. But,it continues without working. I tested and microswitch is well. Any solution, please?

Before, I was very happy with Raspi UPS Hat. Worked very well, but now, I'm unable to switch off.

Anonymous user #45

40 months ago
Score 0++

This HAT board is completely USELESS as UPS: when you switch the main power off (simulating a black out), the battery starts discharging (ok), but when you switch the main power on again (e.g. black out is over), the battery keeps on discharging. For a correct recharge of the battery after the main power returns, you have to: 1 - safely shutdown the Raspberry 2 - manually switch off the UPS HAT button 3 - manually switch on the UPS HAT button

In practice, the man must be in the loop each time a black out (or a power surge) occurs...

Ok4rm

42 months ago
Score 0++
And one modification. When the USB cable is connecte to a PC, LED1+2 are on and LED3+4 flash, about twice per second.

Ok4rm

42 months ago
Score 0++

Does not work. Let me describe again. When UPS is stand-alone: 1. after connecting battery, all four LEDs light and never go off 2. after connecting USB cable, LED1+2 flash, after 1 sec all four LED are on, then 1 sec all LEDs go off. 3. battery does not charge

When connected to Pi Zero: - everything same as above, but I can read voltage.

- it does not charge, anyway

Anonymous user #44

42 months ago
Score 0++

Does not work. When I connect it to micro USB, LED1+2 switch on, after ~1 sec LED3+4 go on, after yet another ~1 sec all LEDs switch off, and so on... Cannot find any description what this means.

When I connect it to RasPi Zero W: I can measure voltage, it works as UPS, but the battery slowly discharges and no charging.

Anonymous user #43

45 months ago
Score 0++

my serial terminal does not work when i power it through the Raspi UPS HAT Board? if i pull the power supply from Raspi UPS HAT Board and put on RPi board, the serial terminal works again.

Is there something that interferes with serial pins (RXD,TXD) when Raspi UPS HAT Board is powered up?

Wouterlet

45 months ago
Score 0++

I followed your manual but get stuck on the last part:

sudo python example.py

This gives me the error: Unable to open I2C device: No such file or directory

I enabled I2C copied example.py and raspiupshat.so into /home/pi/wiringpi and started the command from there

One thing is that I used this link to copy, because yours was unavailable:

git clone https://gith...gpi/wiringpi

Can you help me with this?

Anonymous user #42

46 months ago
Score 0++
Can I use I2C DS1307 RTC with Raspi UPS HAT Board?

Anonymous user #41

48 months ago
Score 0++
How can I switch on the raspberry pi when the power supply is plug in to the ups?

Anonymous user #38

50 months ago
Score 0++
where can I get a program to control automatic backup of data at low power and safe shutdown.

Anonymous user #40

49 months ago
Score 0++

sudo raspi-config # Enable Interfacing Options>I2C sudo apt-get install i2c-tools # Install i2c-tools nano ~/ups.py # Make a new python script

... import struct import smbus import sys import time import os

lowest = 60

def readVoltage(bus): "This function returns as float the voltage from the Raspi UPS Hat via the provided SMBus object" address = 0x36 read = bus.read_word_data(address, 2) swapped = struct.unpack("<H", struct.pack(">H", read))[0] voltage = swapped * 78.125 /1000000 return voltage

def readCapacity(bus): "This function returns as a float the remaining capacity of the battery connected to the Raspi UPS Hat via the provided SMBus object" address = 0x36 read = bus.read_word_data(address, 4) swapped = struct.unpack("<H", struct.pack(">H", read))[0] capacity = swapped/256 return capacity

def shutdown(): os.system("sudo shutdown -h now")

bus = smbus.SMBus(1) # 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1) print "Voltage:%5.2fV" % readVoltage(bus) print "Battery:%5i%%" % readCapacity(bus)

  1. Only check if we are low

if readCapacity(bus) <= lowest: first = readCapacity(bus) time.sleep(5) second = readCapacity(bus)

  1. If battery capacity is dropping

if first > second: shutdown() ...

crontab -e

  • /5 * * * * python /home/pi/ups.py > /dev/null 2>&1 #Add to crontab. Run script every 5 min.

Anonymous user #40

49 months ago
Score 0++

Anonymous user #36

50 months ago
Score 0++
I just bought v1.1 and I notice that the 4 indicator LEDs have no limiting resistors ! I think that is a desgin flaw tkat could damage the chip (U3).

Anonymous user #37

50 months ago
Score 0++

I manage to find what U3 is :)

It is IP5306 and it doesn't need the resistors

Anonymous user #35

50 months ago
Score 0++
Is there a way to replace the switch via commands or pin on the GPIO?

Anonymous user #35

50 months ago
Score 0++
Is there a way to provide power via the GPIO (not through the microUSB)?

Anonymous user #34

51 months ago
Score 0++

It's possible to power up Raspberry PI 4? The current consumption is 3A instead of 2.5A of the old raspberry PI 3.

What's the maximu current load privided by the hat?

Anonymous user #33

52 months ago
Score 0++

"Don't connect the micro USB to rasberrry pi; please connect the micro USB to UPS HAT board;"

VS

"USB to Dual Micro USB Charging Cable"

Se we can use dual micro usb or not?

Anonymous user #32

55 months ago
Score 0++

I have looked into the schematic, created a minimal modification of the Geekworm UPS hat and additionally have created a small board that implements the missing functionality. This board can be created even with beginner‘s soldering skills, all as open source. Please see the following link: https://gith...ttiny_daemon

By the way, I‘m the Joachim whose sample code is referenced above.

Anonymous user #31

56 months ago
Score 0++

Im using a "USB to Dual Micro USB Charging Cable" to have the RPI up and running as much time as possible during short power outages. But I noticed that when there is a power outage, both boards turns off immediately after the power is cut.I tried with two boards with the same result.

I can send you a video.

Anonymous user #30

56 months ago
Score 0++
Hello, something needs to be done so that the battery starts charging again after the power source power has been interrupted for a few seconds?. the raspberry pi goes out because the charge does not start again

Anonymous user #29

57 months ago
Score 0++
Can I charge and supply the Raspberry Pi at the same time in a long time like 12 hours without breaking my battery?

Anonymous user #29

57 months ago
Score 0++
Can I charge and supply the Raspberry Pi at the same time in a long time like 12 hours without breaking my battery?

Anonymous user #28

58 months ago
Score 0++

Does the Raspi UPS HAT Board keep the battery charged or I need to recharge the battery manually plugging a Dual Micro USB charging cable?

Can a program running on the raspberry be PI notified when a switch from power supply to the battery occurs?

Anonymous user #27

58 months ago
Score 0++
which pin(s) does this supply power to the raspberry pi from?

Anonymous user #27

58 months ago
Score 0++
Running into an issue where when using the HAT, all of my pins are in use when I run i2cdetect -y 1. However this isn't the case when I connect my devices directly to my raspberry pi. Any idea why this would be happening?

Admin

58 months ago
Score 0++

Hello, sir

Sorry, we don't understand your mean.

case?

please email to support@geekworm.com

Anonymous user #26

58 months ago
Score 0++
after the pi is powered on, if micro usb is plugged into the ups hat, the battery does not charge. is this normal? this also occurs if the pi is powered on but has external power removed, reconnecting external power stops the battery from charging.

Admin

58 months ago
Score 0++

This is not normal, at any time, as long as you plug in the PSU, the battery will be charged Please check if your battery cable is reversed.

or email: support@geekworm.com

Anonymous user #2

58 months ago
Score 0++

I am trying to migrate my python2 app to python3 and got the following error message when running with python3. How can I fix this to work? import raspiupshat

ImportError: /home/pi/build/raspiupshat.so: undefined symbol: Py_InitModule4

Admin

58 months ago
Score 0++

Sorry. sir.

We will update the so file for python 3 soon.

Anonymous user #25

58 months ago
Score 0++
Hi, can I turn on the raspberry without pressing the button on the UPS HAT?

Admin

58 months ago
Score 0++

Hi, Please refer to the above photo, you can consider to use USB to Dual Micro USB Charging Cable. NOTE: the switch is disabled when you use USB to Dual Micro USB charging cable;

The raspberry pi will be power on automatically after the battery capacity is be exhausted when you use the one to two USB cable. Best regards,

Cindy/Geekworm

Anonymous user #23

59 months ago
Score 0++

Hi! Could you please explain the correct procedure to have the UPS turn off? This is what I am doing:

1. I first shutdown the Raspberry. `shutdown -h now` 2. Then I press the power pushbutton. The energy is gone on the Raspberry. 3. The UPS LEDs stay on. 4. Then I disconnect the power cable from the UPS. 5. The last LED starts flashing. The LEDs remain ON. 6. I am forced to disconnect the battery to have everything off.

Would you be so kind to explain the right procedure to power off the UPS completely without disconnecting the battery?

Thank you!

Anonymous user #23

59 months ago
Score 0++
By the way. I have not yet installed any drivers.

Admin

59 months ago
Score 0++

Hello sir, It is a little hard to figure out the problem here. Could you please send us a detail video about the process? Please send to email support@geekworm.com . Please attach an order number and item link thanks! Best regards,

Cindy

Anonymous user #24

59 months ago
Score 0++
Use the micro switch on the HAT to turn power to the Pi on and off. After your "shutdown -h now" command on the Pi, press and hold the micro switch on the HAT and the green LED will go out. The 4 white LED's are just showing the state of the 3.7v 2500 mah battery and as long as the USB power is plugged in, it will be re-charging the backup battery.

Anonymous user #21

59 months ago
Score 0++

Continuing from the last question:

In the video above the Dual Micro USB cable is used to power the system. Now at one point the cable is pulled from the wall plug. Now the system is in battery mode with the USB connector of the RPi and the UPS hat being electrically connected. This means that the 5V in of the UPS hat is electrically connected to the 5V pins of the RPi. This in turn means that the input of the charging circuit is connected to the output of the boost converter.

How is this situation handled by the UPS?

Admin

59 months ago
Score 0++

Hello, Would you mind tell us what problem have you met? Please send us your order number and item link and with photos and problem details to email : support@geekworm.com . Then we can help you with it, thanks very much! Best regards,

Cindy

Anonymous user #21

59 months ago
Score 0++

Hi,

Connecting two USB-cables to RPi and UPS means that the 5V input on the UPS is directly connected to the 5V-pins of the RPi (Pin 2 and 4, see schematic of RPi). What happens when no external power is available and the system switches to battery power?

If I understand it correctly, then the UPS tries to charge its battery from its own output. Is this really the case?

Admin

59 months ago
Score 0++

Hello,

If there is no external power , there is no need to connect the USB to Dual Micro USB Charging Cable.

Anonymous user #39

50 months ago
Score 0++
If i disconnect both micro USB cables and have no input voltage but have a fully charged 3.7v battery connected correctly with the green light on and all four LEDs illuminated, the UPS Hat does not power on the Rasp Pi. It also doesn't appear to provide any power over the GPIO ports as well. What am i doing wrong here? Battery is fully charged and wired correctly, The Hat is installed correctly and the raspberry pi 3 B is in working order.

Anonymous user #20

59 months ago
Score 0++
How can I control the switch from gpio?

Admin

59 months ago
Score 0++
Hello, Sorry, it is not available now.

Anonymous user #19

60 months ago
Score 0++
can i get battery consumption in Watt from the code?

Admin

60 months ago
Score 0++

Hello sir,

Do you refer to the file we attched? If not any inofmration about it, then it may be not.

Anonymous user #18

60 months ago
Score 0++
Capacitor C4 got burnt after running for a while. Any idea why did this happen?

Admin

60 months ago
Score 0++

Hello sir,

We are so sorry to hear that, where do you order the board? Can you replace it at your side?

Anonymous user #17

61 months ago
Score 0++

Hello, my UPS HAT when fully charged and on power will stop the ouput power to raspberry pi then start again then stop. Is this normal when fully charged and on power ?

Thank you

Admin

61 months ago
Score 0++

Hello, Maybe we can not understand your meaning clearly.Can you contact us by email and attach some photo or details? Best regards,

Cindy/Geekworm

Anonymous user #16

61 months ago
Score 0++
how can i calibrate the battery? from the LED indicator it still blink (2 LEDs), but from the program shows 0%, then about in hour, my Raspi run out of battery

Admin

61 months ago
Score 0++

Hello, Could you please check if your battery 2pin port the red and black cable if in the right place as the photo above. Or you can change another 3.7v battery to have a try. Best regards,

Cindy/Geekworm

Anonymous user #15

62 months ago
Score 0++
what dimension of board?

Admin

62 months ago
Score 0++

Hello,

The UPS HAT board is with standard Raspberry Pi Pi HAT size!

Anonymous user #14

62 months ago
Score 0++
Hello, when I measure the battery capacity I get values over 100%. For this measure I use the formula that appear in this document "File:How-to-use-via-i2c.pdf". I'm missing something?

Admin

62 months ago
Score 0++

Hello, Could you please show some more details? Please attached some photos about your data.

You can contact us by support@geekworm.com , please tell us your order number and product link of where you buy it, thanks!

Anonymous user #13

62 months ago
Score 0++
Voltage and percentage values returned by ups-read or python module are not changing. Am I missing something? I'd left my Raspberry Pi Zero W on battery last night and it was without juice by the morning, but I didn't receive any changes notifications or power down message on telegram (I'd basically replaced print commands with sendMessage methods of telepot Python module and it works like a charm). Do I need to turn your board off and on to refresh these values?

Admin

62 months ago
Score 0++

Hello sir, 1. First please check according to the photo above of the 2.0b portof your battery to see if the red cable and black cable is in wrong side. 2.Please Send us your order number and item URL to support@geekworm.com about the problem details. Best regards,

Cindy/Geekworm

Anonymous user #12

63 months ago
Score 0++
Can two of these modules be used at the same time on a raspberry pi 3b+? Each module on top of the other?

Admin

63 months ago
Score 0++

Hello, Sorry, the ups hat board is not support to stack to use, you can not use two of these modules at the same time . Best regards,

Geekworm

Anonymous user #11

63 months ago
Score 0++
how long battery last?

Admin

63 months ago
Score 0++

Hello sir, It depends on what battery capacity you use and the battery quality, we suggest that you use big capacity batteries,thank you. Best regards,

Cindy

Anonymous user #10

63 months ago
Score 0++

I've written a nodejs module to communicate with the MAX17048 chip that monitors battery charge on this board.

See https://www....age/max17048

Admin

63 months ago
Score 0++

Hello, What can we help you? Best regards,

Geekworm

Anonymous user #22

59 months ago
Score 0++
Nice!

Anonymous user #9

63 months ago
Score 0++

Hi, I have some problems with undervoltage when my RPI 3+ is powered by the UPS HAT. This occurs both while the power supply (PSU) via micro-USB is connected or not. I have tried to power the PRI directly from the PSU, and no undervoltage here. The HAT must be the culprit. I'm running a barebone raspian (stretch). The problem becomes worse when I open programs or put load on the RPI in any other way. The yellow lightning icon in upper right corner is almost persistent then.

Can you please advise?

Admin

63 months ago
Score 0++

Hello, Thanks for your message, we suggest that you can contact us by email: support@geekworm.com to confirm more details. 1.Please tell us what battery do you use for the UPS. 2.Please test the output voltage of ups hat by the GPIO PIN. 3.Please also tell us where do you order this board. Thank you! Best regards,

Cindy/Geekworm

Anonymous user #22

59 months ago
Score 0++

Hi! I had the same issue once I left the Raspi running for a couple of hours. I think the SD got corrupted for some undervoltage. The undervoltage symbol used to appear on the right whether connected or not. Nonetheless, I left the UPS disconnected for a night. I disconnected the battery as well. Now I am using it normally. I am not sure this is due to the "training stage" of the UPS.

Now, I am using the UPS normally. For a period of time, the LEDs did not always turned off when everything was OFF. But nowadays, it is all working as expected.

Anonymous user #8

63 months ago
Score 0++
Hi, can the battery percentages for led lights be modified? My boards lights are always all on unless charging. They do not behave as in your battery capacity table. Reading from ic2 works fine.

Admin

63 months ago
Score 0++

Hello sir, Would you mind tell us where do you order this board? What battery do you use? Please check if the red cable and black cable of the battery 2.0 port in the right place, and also refer to the photo above. If any questions, please contact us by email: support@geekworm.com. Best regards,

Cindy/Geekworm

Anonymous user #6

64 months ago
Score 0++

Hi, I would like to power my Raspi Zero W with a Hifiberry mini hat (https://www....rds/miniamp/ using the geekworm UPS.

Does it work with a Raspi Zero W?

Admin

64 months ago
Score 0++

Hello sir, Sorry, the UPS HAT board only can power the Raspberry Pi zero W by weld the GPIO pin header on it, but if you add the Hifiberry mini hat on it, then it will not possible to add the UPS HAT board by GPIO PIN, hope to get your understanding! Best regards,

Cindy/Geekworm

Anonymous user #7

64 months ago
Score 0++
What if I first add the UPS HAT board on the Raspberry Pi Zero W and on top of the UPS hat the Hifiberry mini hat?

Admin

64 months ago
Score 0++

Hello sir, We do not test it, so we can not confirm anything, hope to get your understanding! Maybe you can do a test. Best regards,

Geekworm

Anonymous user #5

64 months ago
Score 0++
Hi, is there a way to know if the raspberry is powered by the battery, or external power ? Or, in other way, to know if the external power fails ?

Admin

64 months ago
Score 0++

Hello, We are so sorry, it seems that there is no way know if raspberry is powered by the battery, we will do a research about it, thank you! Best regards,

Geekworm

Anonymous user #4

65 months ago
Score 0++
Where can I reach the schematics of this card?

Admin

65 months ago
Score 0++

Hello, All the information is on this wiki page. Sorry, there is no schematics of this card provided, hope to get your understanding! Best regards,

Geekworm