持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第21天,点击查看活动详情
安装Ubuntu Server系统
树莓派安装Ubuntu Server系统 - 掘金 (juejin.cn)
使用I2C
进入系统,运行以下命令,安装i2c-tools、python3-pip
sudo apt install -y i2c-tools python3-pip
使用pip安装smbus2
sudo pip3 install smbus2
通过OTA更新UPS固件
UPS Plus文档地址:wiki.52pi.com/index.php?t…,右下角可以设置中文。
注:在升级过程中不要关闭电源或断开网络连接。如果升级失败,UPS PLUS将无法正常工作。
-
将树莓派和UPS PLUS使用铜柱固定起来。撞针为压下状态。
-
按住UPS Pro开关键,将电池插入电池舱。
-
插入电池后等待Raspberry Pi运行,在系统终端执行以下python脚本完成升级。
cd ~ git clone https://github.com/geeekpi/upsplus.git cd ~/upsplus python3 OTA_firmware_upgrade.py
注:第一次运行时,可能会提示设备没有注册。如果是合法的设备,只需等待几秒钟,再试一次。
- 升级后,UPS Plus将被关闭,请拔掉电源插头,从UPS Plus中取出电池。
- 将电池插回UPS Plus,然后连接电源并按下电源开关,将其打开。
系统运行正常即可将树莓派和UPS Plus关机,拆开树莓派和UPS Plus进行组装。
设置自动关机保护
在系统的终端运行
curl -Lso- https://git.io/JLygb | bash
当遇到低电量时,它将自动关闭并关闭UPS,当交流电来临时,它将重新启动。
检测电池状态
切换到upsplus目录下
cd /usr/mydata/upsplus
注:这是我自己移动之后的目录,upsplus是在更新UPS固件时从github上clone的。
运行命令执行upsplus.py文件
python3 upsplus.py
查看输出信息
- Current information of the detected Raspberry Pi(树莓派信息)
- Batteries information(电池信息)
- Voltage of Batteries:电池电压
- Battery Current (discharge/Charging) Rate:电池电流(放电/充电)率
- Currently not charging/Currently charging via Type C Port:当前未充电/使用Type C充电