sw documentation - acaird/raspi-scale GitHub Wiki

BeanBot’s software is written in Python, which is a pretty nice language for things like this.

I wrote most of the functions as separate files so each one can be run on its own to see if it’s working.

The files are:

  • scale.py
  • scaleAlerts.py
  • scaleConfig.py
  • scaleEmail.py
  • scalePlotly.py
  • scaleTwitter.py

Installation

Following these steps has a reasonable likelyhood of installing this software on your Raspberry Pi.

Software needed on your Pi

Git
You need Git so you can clone down the software, to install Git on your Pi type:
apt-get install git
    
Python 2.7
Or 2.something where something is a nice number. To install Python on your Raspberry Pi type:
		     apt-get install python-2.7
    
pip
pip is a tool to install Python packages, which we need to do. It’s possible pip came with your Python distribution, but if not, you can install it by typing:
	    apt-get install python-pip
    
RPi.GPIO
RPi.GPIO is the Python package that lets programs communicate with the Raspberry Pi’s GPIO subsystem. Install this by typing:
		 pip install RPi.GPIO
Plotly Python libraries
BeanBot uses Plot.ly to make its plots, so you need the Plot.ly Python libraries. Install these by typing:
	pip install plotly
Python/Twitter libraries
In order to tweet the state of your beans and alert you via Twitter when you are low, you need Python to talk to Twitter. BeanBot’s scale.py and scaleTwitter.py expect the python-twitter package, so install it by typing:
	pip install python-twitter

Installing the BeanBot software

git clone https://github.com/acaird/raspi-scale.git

Or pick a release from https://github.com/acaird/raspi-scale/releases and download a .tgz file.

Configuring BeanBot

There is some art to this, but you’ll edit the scaleConfig.yaml file and create some .sec files.

Starting the BeanBot software

sudo python ./scale.py &

The BeanBot software

scale.py

The main program

scaleAlerts.py

The function to decide on sending alerts. It also updates the scaleState.db file to keep track of the alert state between software restarts.

scaleConfig.py

The function to read the configuration file. It also contains the hard-coded defaults for all of the available settings.

scaleEmail.py

The function to send email for updates and alerts.

scalePlotly.py

The function to talk to Plot.ly and update the chart.

scaleTwitter.py

The function to talk to Twitter for updates and alerts.

⚠️ **GitHub.com Fallback** ⚠️