PiSugar
Jump to navigation
Jump to search
The PiSugar[1] is a hat for the Raspberry Pi that comes in several different variants.
I have a PiSugar 3 Plus unit attached to a Raspberry Pi 4B.
The following are miscellaneous notes and other information regarding the PiSugar.
The PiSugar has downloadable package that, once installed, provides a web based GUI for status and control of the unit.
Status
Power Source
You can query for the power source being present (charging) or absent from the command line with the following:
i2cget -y 1 0x57 0x02 | cut -b 3- | tr "[:lower:]" "[:upper:]" | xargs echo "obase=2; ibase=16;" | bc | awk '{printf "%08d\n", $1};' | head -c1
Possible return values:
- 0 = external power source absent (running on battery)
- 1 = external power source present
Note: In the command above, awk pads the output to 0 zeros to ensure that the leading 0 is preserved by the command and not dropped.