Giter Club home page Giter Club logo

raspiupsmonitor's Introduction

RaspiUpsMonitor

a Python monitor script for Raspi UPS HAT

Raspi UPS HAT was a board for Raspberry Pi with a controller and a LiPo battery that act like an UPS. On board, there's a MAX17034 chip (connected to i2c bus) that could be asked for battery voltage and remaining capacity (0-100%). With this simple script, far to be perfect (and you are encouraged to fix and improve it !), you can shutdown safely your RPi when battery on UPS Hat reach a critical level, avoid any potentials data loss.

Requirements

You need to install smbus2 with sudo pip install smbus2

Install

Installation is pretty simple: just do python setup.py build and sudo python setup.py install. If you want to execute as a daemon on startup, just copy raspiupsmonitor.initd to /etc/init.d (cp raspiupsmonitor.initd /etc/init.d/raspiupsmonitor, sudo chmod +x /etc/init.d/raspiupsmonitor, sudo update-rc.d /etc/init.d/raspiupsmonitor defaults) and the wrapper raspiupsmonitor.sh to /usr/local/bin. Then you can use it as other system services with:

/etc/init.d/raspiupsmonitor [start|stop]

Configure

Configuration is in raspiupsmonitor.cfg must be copied to either

  • /etc/raspiupsmonitor.cfg
  • ~/.raspiupsmonitor.cfg
  • raspiupsmonitor.cfg

and the relevant part is [Monitor]:

[Monitor]
# On alert level of 10%, just alert all users...
alert_level=10
alert_action=/usr/bin/wall "UPS Battery is dying..."
# When battery is dying, halt the system safely
critical_level=5
critical_action=/sbin/halt -p

"level" is the percentage of power remained, in a range from 0 to 100. When battery is discharging and reach the alert or critical level, "action" was executed.

raspiupsmonitor's People

Contributors

akuhtz avatar caguna avatar michelep avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

raspiupsmonitor's Issues

can't get the status

Hi,
In my Rasberry Pi 3B+, I have UPS HAT v.1.0 and Waveshare display 2.9inch.

I follow the documentation, No error or problems during the installation.
It has started RaspiUpsMonitor as a service.
I restart the rasb and go to check the status of the battery, but hit this:

`pi@raspberrypi:~ $ /etc/init.d/raspiupsmonitor status
● raspiupsmonitor.service - LSB: Monitor RaspiUPS battery status
Loaded: loaded (/etc/init.d/raspiupsmonitor; generated)
Active: active (exited) since Sun 2020-04-19 21:55:15 EEST; 5min ago
Docs: man:systemd-sysv-generator(8)
Process: 2209 ExecStart=/etc/init.d/raspiupsmonitor start (code=exited, status=0/SUCCESS)

Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: File "/usr/lib/python2.…ipt
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: self.require(requires…ns)
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: File "/usr/lib/python2.…ipt
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: exec(script_code, nam…ce)
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: File "/usr/local/lib/py…le>
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]:
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: File "build/bdist.linux…age
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: File "/usr/local/lib/py…ata
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: ioctl(self.fd, I2C_SM…sg)
Apr 19 21:55:16 raspberrypi raspiupsmonitor[2209]: IOError: [Errno 121] Remo…ror
Hint: Some lines were ellipsized, use -l to show in full.
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.