This follow-up is an attempt to capture all of the changes required when installing RaspberryPints on Raspbian Jessie using the latest Apache2 web server and the latest LXDE desktop.
The full installation procedure can be found
here.
Changes required to "make various things work" are listed below.
Notes For All New Installations On Jessie
Two of the instructions in Step 5 are out of date:
- Instead of using the autostart file shown in the instructions as
/etc/xdg/lxsession/LXDE-pi/autostart
use
/home/pi/.config/lxsession/LXDE-pi/autostart
- and instead of adding
@chromium --kiosk localhost
add
@chromium-browser --incognito --start-fullscreen localhost
Step 7 refers to the "default apache page" at /var/www
The current release of Apache2 has the default document root located at /var/www/html, where the RaspberryPints instructions reference /var/www, so you need to adjust accordingly - or change the document root back to /var/www.
If you want to keep the document root at /var/www/html you have to change a pointer in the Python listener.
Edit /var/www/html/python/flow_monitor.py
Find these two lines:
# Edit this line to point to where your rpints install is
poursdir = '/var/www'
Change /var/www to /var/www/html
If you want to change the document root to /var/www,
don't change the Python listener pointer, but instead change the Apache2 config file.
Edit /etc/apache2/sites-available
and change
DocumentRoot setting from /var/www/html to /var/www.
Using an AlaMode with Raspbian Jessie on RPi3
The RaspberryPints installation procedure as documented was developed using Raspbian Wheezy on RPiB and RPi2B platforms.
Since then, the warty Raspbian Jessie became the defacto standard, the RPiB and RPi2B faded into history, and the RPi3 implementation broke many paradigms.
One of which was to commandeer the hardware serial port for use by wifi and bluetooth modules on the RPi3.
This leaves a software serial port for use by devices such as the AlaMode.
To get an AlaMode working with RaspberryPints on an RPi3, do the following:
- Follow the full RaspberryPints installation up to Step 6 (don't execute what's shown).
- Install DOS2UNIX (a conversion tool to make text files written on Windows platforms more "unix-y"):
$ sudo apt-get update
$ sudo apt-get install dos2unix
- Disable Serial Port messaging:
Edit /boot/config.txt
Change enable_uart=0
- Now, fetch the Alamode setup kit:
wget
https://github.com/wyolum/alamode/raw/master/bundles/alamode-setup.tar.gz
- Unpack it from your /home/pi folder:
pi@raspberrypi ~ $ tar -xvzf alamode-setup.tar.gz
- Change focus into the kit you just unpacked:
pi@raspberrypi ~ $ cd alamode-setup
- Run DOS2UNIX against the setup file for Jessie:
$ sudo dos2unix jessie-setup
- Execute the converted script:
$ sudo jessie-setup
- Re-start the RaspberryPi before continuing
- Continue the installation procedure from Step 7 as shown on the raspberrypints.com page, noting the applicable changes listed in this post.
If using an Uno instead of AlaMode
Do not perform the AlaMode support installation in Step 6 of the raspberrypints installation procedure. Skip Step 6 entirely.
The Python port "listener" needs to know what device to monitor for "pour" messages.
The default setting is to listen for TTYS0, while an Uno connected via USB will typically show up as TTYACM0.
Edit /var/www/html/python/flow_monitor.py
Find these lines:
#The following line is for serial over GPIO
port = '/dev/ttyS0'
#The following line is for serial over USB
#port = '/dev/ttyACM0'
Add a comment # in front of the ttyS0 line and remove same from the ttyACM0 line.
If using an Uno CLONE instead of AlaMode
Do not perform the AlaMode support installation in Step 6 of the raspberrypints installation procedure. Skip Step 6 entirely.
Again, the Python port "listener" needs to know what device to monitor for "pour" messages.
The default setting is to listen for TTYS0, while an Uno Clone connected via USB will typically show up as TTYUSB0
I believe this is due to clones using a CH340 USB/serial bridge chip instead of the Mega16U2 used on "genuine" Arduino Uno boards.
Edit /var/www/html/python/flow_monitor.py
Find these lines:
#The following line is for serial over GPIO
port = '/dev/ttyS0'
#The following line is for serial over USB
#port = '/dev/ttyACM0'
Add a comment # in front of the ttyS0 line and remove same from the ttyACM0 line.
Then change /dev/ttyACM0 to /dev/ttyUSB0.
If using the Adafruit flow meters
There are two files that need to be changed.
The first one is the sketch file that has to be loaded via the Arduino IDE.
This is the same file that always requires user-specific edits for the number of pins and the pin list.
- Edit /var/www/html/arduino/raspberrypints/raspberrypints.ino
Find this line:
if ( pulseCount
> 100 ) {
and change it to:
if ( pulseCount > 35 ) {
The second file receives pour messages from the Python port listener (/var/www/html/python/flow_monitor.py) and translates them into data that fits the MySql database format.
- Edit /var/www/html/includes/pours.php
Find this line:
$amount = $PULSE_COUNT / 21120;
and change it to:
$amount = $PULSE_COUNT / 1500;
Cheers!
[edit]
Thought I'd try to capture everything in one post, so I've added the changes for using a USB-connected Uno instead of the AlaMode, and for using the Adafruit flow meters instead of the SwissFlow SF800s.