Use the Python APIs to integrate into your code
Sixfab offers Python API which allows a user to integrate UPS HAT v2 into their own project.
Enabling the I2C on the Raspberry Pi.
To connect via I2C you’ll need to first enable the interface on the Pi. This is done via raspi-config which can be run in a terminal window:
In the raspi-config user interface navigate to Interfacing Options >> I2C and answer the question "Would you like the ARM I2C interface to be enabled?" with . After the next reboot user pi will be able to use the I2C bus without root privileges.
If Python 3 has already been installed on the system, execute the command below to install pip3:
sudo apt -y install python3-pip
Install Power API
If pip3 has already been installed on the system, execute the command below to install power-api
pip3 install power-api
Use the following command to uninstall the library:
pip3 uninstall power-api
Use the following command to upgrade the library to the latest:
pip3 install power-api --upgrade
All the methods can be accessed from the API doc.
Here's a list of example actions that you can do using the Python API:
Note that you must configure the RTC with the set RTC example before creating an event. Otherwise, the events will not happen.
One of the simple ways to use the Python API is to use the Python Interpreter.
Updated about 1 year ago