An uninterruptible power supply for Raspberry Pi that can provide more than an hour of backup power and can shutdown the Pi safely. This UPS can be used to power any 5V device with upto 3A continous current. It is based on Texas Instruments BQ25895 power management IC and TPS61236P boost converter IC.
This UPS can power a Raspberry Pi through the GPIO header by using it as a hat. When used as a hat, the GPIO pins 2, 3 and 4 will be utilised for I2C and interrupt signals.
Note:
-
Do not connect two input sources together!
-
The device does not have reverse polarity protection, be sure to observe the polarity marked in the battery holder.
-
Input: 3.9V - 14V DC, 2A - 3A
-
Input Ports: Screw Terminal, micro USB
-
Output: 5V, upto 3A
-
Output Ports: Screw Terminal, USB A, 40 pin GPIO header for Raspberry Pi
-
Battery: Samsung INR18650-29E (Other 18650 size batteries can be used)
-
Communication: I2C
-
IN: Input connected or not
-
STATUS: ON- Charging, OFF- Charging done, Blinking- Error
-
OUT: Output on or off
Run the command
sudo raspi-config
Choose Interfacing Options, then I2C and then enable.
Install smbus by running the following command:
sudo apt-get install -y python-smbus
For more information, checkout the link
sudo apt-get install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service
You can Install the MQTT client using PIP with the command:
pip install paho-mqtt
More info
cd ~
git clone https://github.com/tjohn327/raspberry_pi_ups.git
-
Insert the battery into the UPS making sure to follow the correct polarity mentioned on the battery holder. Installing the battery in the wrong way can damage the UPS!
-
Place the UPS over the Raspberry Pi and insert the header of the UPS into the GPIO header of the Raspberry Pi.
-
Connect the power source to the micro usb input of the UPS.
-
Turn on the Switch on the UPS to start powering the Raspberry Pi.
-
Run the script ups.py for normal ups operation.
-
Use the upsmqtt.py script for sending the ups status through mqtt.
sudo nano /lib/systemd/system/ups.service
Copy and paste the following, make necessary changes and save the file:
[Unit]
Description=UPS Service
After=multi-user.target mosquitto.service
Wants=mosquitto.service
[Service]
Type=idle
User=pi
ExecStart=/usr/bin/python /home/pi/code/raspberry_pi_ups/src/upsmqtt.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable ups.service
sudo systemctl start ups.service
Install Node-Red and Node-red dashboard. Import the flow, /src/ups_flow.json into the Node-Red environment. Deploy the flow and open the dashboard link of Node-Red.
https://www.kickstarter.com/projects/tjohn327/power-pi-a-smart-ups-for-the-raspberry-pi/