# raspberrypi_ups **Repository Path**: dfrobot/raspberrypi_ups ## Basic Information - **Project Name**: raspberrypi_ups - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-02 - **Last Updated**: 2025-02-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### Configure UPS enviroment 1. External source of power for UPS and Rasberry Pi 2. Enable to I2C: * 1. Input sudo raspi-config in the terminal * 2. Select: Interfacing Options * 3. Select: I2C; enable to I2C 3. cd /home/pi 4. git clone https://github.com/DFRobot/raspberrypi_ups.git 5. cd raspberrypi_ups 6. sh setup.sh * 1. Authorize * 2. Compliation of so ups ups_count ups_wdog * 3. Move ups .so .h * 4. Revise self-start files 7. Run ups -i, if your configuration is successful you will see the output as below. Then UPS can supply Rasberry Pi when you startup the conputer next time. * id :DF * version:10 * energy :99% * adc1 :364 * adc2 :355 * vcc :4230 * rgb_r :0 * rgb_g :0 * rgb_b :0 * Audio :enable * electricity require :11 ## API * setup I2C ,return file descriptor
int Init(int id); * get information of UPS
int getId(int fd); //get id
int getVersion(int fd); //get version number
int getEnergy(int fd); //get battery info
int getAdc1(int fd); //get adc1
int getAdc2(int fd); //get adc2
int getVcc(int fd); //get vcc
int getFunction(int fd); //get register of enable function
int getRgbR(int fd); //R
int getRgbG(int fd); //G
int getRgbB(int fd); //B
int getTimer(int fd); //get time of timing start-up
int getElectricity(int fd); //get require Electricity
* set UPS
int setFunction(int fd,int flag); //set register of enable function
int setRgbR(int fd,int num); //R
int setRgbG(int fd,int num); //G
int setRgbB(int fd,int num); //B
int setTimer(int fd,int num); //set time of timing start-up
int shDown(int fd,int time); //shutdown, time=0 or do not write time
int setElectricity(int fd,int value);// set require Electricity
## UPS Functions * ups -h help * ups -i get information * ups -s shutdown: the time unit for it is the minute, default setting of shutdown now without a stated period of time * ups -rgb set rgb value: connect RGB device to UPS bord * ups -t timing start-up: when shutdown UPS, you can set time to start-up, the time unit for it is the minute. * ups -r set time of programs porfrom when powered on * Rasberry will switch itself on in setting when UPS turns off and run the program as below, the time unit for it is the minute. * ups -a 1 /home/pi/ups/example/ups_count * Rasberry will switch itself on in one minute when UPS turns off and run the file: /home/pi/ups/example/ups_count * The function of file is count, Rasberry will turn off when one minute pass. * ups -a Audio enabled, and 1 is turn on, 0 is turn off * ups -e Set the current. When the current is less than the set value(mA), UPS will shut down and give out power to the outside * UPS can realise amplication by external device such as speaker and etc.