update README.md, rename blonk to chipmonk
parent
924a6d12c4
commit
165ce49e34
50
README.md
50
README.md
|
|
@ -1,51 +1,23 @@
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This script monitors the battery voltage, battery charge current and a GPIO pin.
|
This script monitors the battery voltage, battery charge current.
|
||||||
+ If battery is low and not charging, or
|
+ Can send an alert if battery is not charging or is low.
|
||||||
+ the pin is pulled down (GND) it initiates a shutdown.
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. **clone** repository to your C.H.I.P. device
|
1. **clone** repository to your C.H.I.P. device
|
||||||
|
|
||||||
# If not changed: default username "chip" and password "chip".
|
2. **copy**
|
||||||
ssh chip@<your-device>
|
|
||||||
cd
|
|
||||||
git clone https://github.com/rubienr/chip.git
|
|
||||||
|
|
||||||
2. automatically **start** it from **/etc/rc.local**
|
cp ./chipmonk /usr/local/bin/
|
||||||
|
cp ./chipmonk.service /etc/systemd/system/
|
||||||
|
|
||||||
#!/bin/sh -e
|
4. automatically **start** it using systemd
|
||||||
#
|
|
||||||
# rc.local
|
|
||||||
#
|
|
||||||
# This script is executed at the end of each multiuser runlevel.
|
|
||||||
# Make sure that the script will "exit 0" on success or any other
|
|
||||||
# value on error.
|
|
||||||
#
|
|
||||||
# In order to enable or disable this script just change the execution
|
|
||||||
# bits.
|
|
||||||
#
|
|
||||||
# By default this script does nothing.
|
|
||||||
|
|
||||||
# add this line:
|
|
||||||
/bin/bash /home/chip/chip/chip-off.sh
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
## Adjustment
|
systemctl enable chipmonk.service
|
||||||
The battery low **voltage** and **current levels** are adjustable using:
|
systemctl start chipmonk.service
|
||||||
|
|
||||||
|
|
||||||
# SHUTDOWN_MIN_BATTERY_VOLTAGE ... [mV]
|
## Use as utility
|
||||||
SHUTDOWN_MIN_BATTERY_VOLTAGE=2100.0
|
|
||||||
# SHUTDOWN_MIN_BATTERY_VOLTAGE ... [mA]
|
|
||||||
SHUTDOWN_MIN_BATTERY_CURRENT=20.0
|
|
||||||
|
|
||||||
The shutdown GPIO pin is adjustable using:
|
You may also run script 'chipmonk` without the -d flag to display system stats.
|
||||||
|
|
||||||
# see http://docs.getchip.com/#how-you-see-gpio
|
|
||||||
POWER_BUTTON_GPIO_NUMBER="414"
|
|
||||||
POWER_BUTTON_GPIO="/sys/class/gpio/gpio$POWER_BUTTON_GPIO_NUMBER"
|
|
||||||
|
|
||||||
## Screenshots
|
|
||||||

|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# blonk.cfg
|
# chipmonk.cfg
|
||||||
# Configuration for /usr/local/bin/blonk.sh which is normally
|
# Configuration for /usr/local/bin/chipmonk.sh which is normally
|
||||||
# installed as a service started at bootup.
|
# installed as a service started at bootup.
|
||||||
# See https://github.com/ondsinet/blonk
|
# See https://github.com/ondsinet/chipmonk
|
||||||
|
|
||||||
SENSOR_READ_FREQUENCY=5 # Period for polling sensors in seconds
|
SENSOR_READ_FREQUENCY=5 # Period for polling sensors in seconds
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
# blonk.service -- version: "28-Feb-2020"
|
# chipmonk.service -- version: "02-Jan-2021"
|
||||||
# See https://github.com/ondsinet/chip/tree/master/Programs/blonk
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Monitors and Reports sensors on the C.H.I.P. such as battery, temp etc
|
Description=Monitors and Reports sensors on the C.H.I.P. such as battery, temp etc
|
||||||
After=default.target
|
After=default.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/blonk.sh
|
ExecStart=/usr/local/bin/chipmonk -d
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
|
|
|
||||||
28
chipmonk.sh
28
chipmonk.sh
|
|
@ -8,8 +8,8 @@
|
||||||
# Version 1.0 (April 5th, 2016)
|
# Version 1.0 (April 5th, 2016)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Improved (?):
|
# This version cloned from, with modifications:
|
||||||
# https://github.com/ondsinet/chip/tree/master/Programs/blonk
|
# https://github.com/ondsinet/chip/tree/master/Programs/chipmonk
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ "$1" == "-d" ]; then
|
if [ "$1" == "-d" ]; then
|
||||||
|
|
@ -51,10 +51,10 @@ read_config(){
|
||||||
TEMPERATURE_SHUT_VALUE=
|
TEMPERATURE_SHUT_VALUE=
|
||||||
TEMPERATURE_WARN_VALUE=50
|
TEMPERATURE_WARN_VALUE=50
|
||||||
|
|
||||||
if [ -f /usr/local/etc/blonk.cfg ]; then :
|
if [ -f /usr/local/etc/chipmonk.cfg ]; then :
|
||||||
source /usr/local/etc/blonk.cfg
|
source /usr/local/etc/chipmonk.cfg
|
||||||
else :
|
else :
|
||||||
#blonk_error "can't find /usr/local/etc/blonk.cfg"
|
#chipmonk_error "can't find /usr/local/etc/chipmonk.cfg"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,24 +63,24 @@ read_config(){
|
||||||
check_i2c_installed(){
|
check_i2c_installed(){
|
||||||
# Need to communicate with AXP209 via I2C commands
|
# Need to communicate with AXP209 via I2C commands
|
||||||
if [ ! -x /usr/sbin/i2cget -o ! -x /usr/sbin/i2cset ]; then :
|
if [ ! -x /usr/sbin/i2cget -o ! -x /usr/sbin/i2cset ]; then :
|
||||||
blonk_error "need i2c-tools" "Use: sudo apt-get install i2c-tools"
|
chipmonk_error "need i2c-tools" "Use: sudo apt-get install i2c-tools"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
blonk_cleanup(){
|
chipmonk_cleanup(){
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
blonk_stop(){
|
chipmonk_stop(){
|
||||||
blonk_cleanup
|
chipmonk_cleanup
|
||||||
echo "blonk: stopped"
|
echo "chipmonk: stopped"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
blonk_error(){
|
chipmonk_error(){
|
||||||
blonk_cleanup
|
chipmonk_cleanup
|
||||||
while [ -n "$1" ]; do :
|
while [ -n "$1" ]; do :
|
||||||
echo "blonk: $1"
|
echo "chipmonk: $1"
|
||||||
shift # get next error string into $1
|
shift # get next error string into $1
|
||||||
done
|
done
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -326,7 +326,7 @@ echo
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
|
|
||||||
trap "blonk_stop" 1 2 3 15
|
trap "chipmonk_stop" 1 2 3 15
|
||||||
#########################################
|
#########################################
|
||||||
|
|
||||||
LAST_TIME_SENSORS=`date +%s`
|
LAST_TIME_SENSORS=`date +%s`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue