From 165ce49e3417497946d2e17bd1ad57f0bd2b9ea4 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sat, 2 Jan 2021 10:38:34 -0600 Subject: [PATCH] update README.md, rename blonk to chipmonk --- README.md | 50 +++++++++++------------------------------------- chipmonk.cfg | 6 +++--- chipmonk.service | 5 ++--- chipmonk.sh | 28 +++++++++++++-------------- 4 files changed, 30 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 676c599..f8bd3aa 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,23 @@ ## Description -This script monitors the battery voltage, battery charge current and a GPIO pin. -+ If battery is low and not charging, or -+ the pin is pulled down (GND) it initiates a shutdown. +This script monitors the battery voltage, battery charge current. ++ Can send an alert if battery is not charging or is low. ## Installation 1. **clone** repository to your C.H.I.P. device - # If not changed: default username "chip" and password "chip". - ssh chip@ - cd - git clone https://github.com/rubienr/chip.git +2. **copy** -2. automatically **start** it from **/etc/rc.local** + cp ./chipmonk /usr/local/bin/ + cp ./chipmonk.service /etc/systemd/system/ - #!/bin/sh -e - # - # 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 +4. automatically **start** it using systemd -## Adjustment -The battery low **voltage** and **current levels** are adjustable using: + systemctl enable chipmonk.service + systemctl start chipmonk.service + - # SHUTDOWN_MIN_BATTERY_VOLTAGE ... [mV] - SHUTDOWN_MIN_BATTERY_VOLTAGE=2100.0 - # SHUTDOWN_MIN_BATTERY_VOLTAGE ... [mA] - SHUTDOWN_MIN_BATTERY_CURRENT=20.0 +## Use as utility -The shutdown GPIO pin is adjustable using: - - # 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 -![GPIO switch](https://raw.githubusercontent.com/rubienr/chip/master/screenshots/switch.jpg) +You may also run script 'chipmonk` without the -d flag to display system stats. diff --git a/chipmonk.cfg b/chipmonk.cfg index 3d99ec2..381183c 100644 --- a/chipmonk.cfg +++ b/chipmonk.cfg @@ -1,7 +1,7 @@ -# blonk.cfg -# Configuration for /usr/local/bin/blonk.sh which is normally +# chipmonk.cfg +# Configuration for /usr/local/bin/chipmonk.sh which is normally # 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 diff --git a/chipmonk.service b/chipmonk.service index 6942b6e..c9931f7 100644 --- a/chipmonk.service +++ b/chipmonk.service @@ -1,12 +1,11 @@ -# blonk.service -- version: "28-Feb-2020" -# See https://github.com/ondsinet/chip/tree/master/Programs/blonk +# chipmonk.service -- version: "02-Jan-2021" [Unit] Description=Monitors and Reports sensors on the C.H.I.P. such as battery, temp etc After=default.target [Service] Type=simple -ExecStart=/usr/local/bin/blonk.sh +ExecStart=/usr/local/bin/chipmonk -d [Install] WantedBy=default.target diff --git a/chipmonk.sh b/chipmonk.sh index ec674d0..b1e4d6e 100755 --- a/chipmonk.sh +++ b/chipmonk.sh @@ -8,8 +8,8 @@ # Version 1.0 (April 5th, 2016) # # -# Improved (?): -# https://github.com/ondsinet/chip/tree/master/Programs/blonk +# This version cloned from, with modifications: +# https://github.com/ondsinet/chip/tree/master/Programs/chipmonk # if [ "$1" == "-d" ]; then @@ -51,10 +51,10 @@ read_config(){ TEMPERATURE_SHUT_VALUE= TEMPERATURE_WARN_VALUE=50 - if [ -f /usr/local/etc/blonk.cfg ]; then : - source /usr/local/etc/blonk.cfg + if [ -f /usr/local/etc/chipmonk.cfg ]; then : + source /usr/local/etc/chipmonk.cfg else : - #blonk_error "can't find /usr/local/etc/blonk.cfg" + #chipmonk_error "can't find /usr/local/etc/chipmonk.cfg" fi } @@ -63,24 +63,24 @@ read_config(){ check_i2c_installed(){ # Need to communicate with AXP209 via I2C commands 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 } -blonk_cleanup(){ +chipmonk_cleanup(){ return 0 } -blonk_stop(){ - blonk_cleanup - echo "blonk: stopped" +chipmonk_stop(){ + chipmonk_cleanup + echo "chipmonk: stopped" exit } -blonk_error(){ - blonk_cleanup +chipmonk_error(){ + chipmonk_cleanup while [ -n "$1" ]; do : - echo "blonk: $1" + echo "chipmonk: $1" shift # get next error string into $1 done exit 1 @@ -326,7 +326,7 @@ echo #fi - trap "blonk_stop" 1 2 3 15 + trap "chipmonk_stop" 1 2 3 15 ######################################### LAST_TIME_SENSORS=`date +%s`