Create SD Image Version 0.8.4
Contents
- 1 Bug fixes
- 2 Features
- 3 Install gnuplot
- 4 add -r Retries option to driver wrappers
- 5 How the image was created
- 5.1 Get latest image
- 5.2 Update, upgrade
- 5.3 Install RPi-Cam-Web-Interface
- 5.4 Remove packages we don't need
- 5.5 Install packages we need
- 5.6 Install perl modules
- 5.7 Web Server
- 5.8 Test wiringPi library
- 5.9 phpLiteAdmin 1.9.8.2
- 5.10 gnuplot
- 5.11 gEDA Schematic/PCB layout software
- 5.12 Install streaming software
- 5.13 Install Sensor Drivers
- 5.14 Add crontab entries
- 5.15 Install National Time Protocol Daemon (ntpd)
- 5.16 Install RTC support
- 5.17 Set GPU memory
- 5.18 Install touchscreen pop up keyboard support
- 5.19 Install openOCD
Bug fixes
- Fix problem with config.pl taking a long time to load
- Fix problem with data on charts not aligning properly.
Features
- Change graph generation to gnuplot.
- Added additional graphs for wind and battery voltage.
- Add support for BME680
- Add support for DS18B20
- Increase resolution of the weight from xxx.xx to xxx.xxx
- Added video monitoring with RasPi Cam.
Install gnuplot
sudo apt-get install gnuplot
add -r Retries option to driver wrappers
The maximum number of retries to read a sensor before giving up can be specified.
The shell script wrappers around the sensor drivers (dht22.sh, hx711.sh, hx711py.sh, etc) now accept a -r retries command line argument.
# # Get the command line options (which device/GPIO pin to read), maximum number of times to try reading the sensor # while getopts "d:r:" option do case "${option}" in d) DEVICE=${OPTARG};; r) MAXRETRIES=${OPTARG};; esac done # # If max number of retires not specified, default to 10 # if [ -z $MAXRETRIES ] then MAXRETRIES=10 fi #echo "DEVICE = $DEVICE" #echo "MAXRETRIES = $MAXRETRIES" # # Loop up to MAXRETRIES times trying to read the sensor # DATA_GOOD=0 COUNTER=0 while [ $COUNTER -lt $MAXRETRIES ] && [ $DATA_GOOD -eq 0 ] do
In config.pl, the -r1 option is added to the command line when the driver is called:
if ( $hive_weight_sensor eq "cpw200plus" ) { $raw_hive_weight=`/usr/bin/sudo /home/hivetool/cpw200plus.sh -r1 -d $hive_weight_device`; } elsif ( $hive_weight_sensor eq "HX711") { $raw_hive_weight=`/usr/bin/sudo /home/hivetool/hx711.sh -r1 2>&1`; } elsif ( $hive_weight_sensor eq "HX711py") { $raw_hive_weight=`/usr/bin/sudo /home/hivetool/hx711py.sh -r1 2>&1`; }
How the image was created
Get latest image
Download, verify the SHA256 checksum, unzip, burn image.
Image with desktop and recommended software based on Debian Buster Version: July 2019 Release date: 2019-07-10 Kernel version: 4.19 Size: 1945 MB SHA-256: 2bd0613ec8739b6fa4274ea186ec859046f79e6aee4b8c6af0acb6d88f3f533a
Verify the checksum:
$ openssl dgst -sha256 -hex 2019-07-10-raspbian-buster-full.zip SHA256(2019-07-10-raspbian-buster-full.zip)= 2bd0613ec8739b6fa4274ea186ec859046f79e6aee4b8c6af0acb6d88f3f533a
Unzip the image
$ unzip 2019-07-10-raspbian-buster-full.zip Archive: 2019-07-10-raspbian-buster-full.zip inflating: 2019-07-10-raspbian-buster-full.img
Copy it to the SD card
# dd bs=40M if=2019-07-10-raspbian-buster-full.img of=/dev/sdb 153+1 records in 153+1 records out 6434062336 bytes (6.4 GB, 6.0 GiB) copied, 819.132 s, 7.9 MB/s
Boot
Stretch boots directly into the window system.
....
Update, upgrade
update your system's package list and then upgrade all your installed packages to their latest versions:
sudo apt-get update sudo apt-get dist-upgrade
Install RPi-Cam-Web-Interface
https://elinux.org/RPi-Cam-Web-Interface
First install motion:
sudo apt-get install motion
Then install RPi-Cam-Web-Interface
git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git cd RPi_Cam_Web_Interface ./install.sh
Remove packages we don't need
sudo apt-get remove --purge scratch dillo squeak-vm sonic-pi sudo apt-get autoremove sudo apt-get clean rm -rf /home/pi/python_games sudo rm -rf /opt/minecraft-pi
Install packages we need
sudo apt-get -y install gawk bc libusb-dev libexpat1-dev sqlite3 sudo apt-get -y install dh-autoreconf libudev-dev sudo apt-get -y install gnuplot
Install perl modules
sudo cpan CGI Date::Format XML::Simple DBI DBD::SQLite Chart::Gnuplot sudo cpan DateTime
Install perl DateTime module
apt-get install libdatetime-perl apt-get install libdbi-perl apt-get install libdbd-splite3-perl
Web Server
Configure apache
- Link the cgi.load and include.load module to mods-enabled
- ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled
- ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled
- Add .pl to AddHandler cgi-script
- sudo vi /etc/apache2/mods-enabled/mime.conf
- uncomment #AddHandler cgi-script .cgi (around line 219) and add ".pl .py" so it looks like:
- AddHandler cgi-script .cgi .pl .py
- add Includes and +ExecCGI to Options:
- sudo vi /etc/apache2/apache2.conf
- In stanza <Directory /var/www/>
- change
- Options Indexes FollowSymLinks
- to
- Options Indexes FollowSymLinks Includes ExecCGI
- Add index.shtml to DirectoryIndex:
- sudo vi /etc/apache2/mods-enabled/dir.conf
- Change
- DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
- to
- DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml
- Set up apache to listen on port 8080 if using port forwarding:
- sudo vi /etc/apache2/ports.conf
- add Listen 8080
- Restart Apache
sudo apachectl restart or sudo/etc/rc4.d/S02apache2 restart
Set sudo user privileges for Apache
This is necessary to allow config.pl to read the sensors. Run visudo to edit the sudo config file:
sudo visudo
and insert these line in the "User privilege specification" section:
# User privilege specification root ALL=(ALL:ALL) ALL www-data ALL=NOPASSWD: /home/hivetool/hive.sh www-data ALL=NOPASSWD: /home/hivetool/hx711pyB.sh, /home/hivetool/hx711.sh, /home/hivetool/hx711b.sh www-data ALL=NOPASSWD: /home/hivetool/HX711a128.py, /home/hivetool/hx711py.sh www-data ALL=NOPASSWD: /home/hivetool/dht22_adafruit.sh www-data ALL=NOPASSWD: /usr/bin/nice www-data ALL=NOPASSWD: /home/hivetool/temperhum.sh www-data ALL=NOPASSWD: /usr/local/bin/2591, /usr/local/bin/2561 www-data ALL=NOPASSWD: /usr/local/bin/hx711, /usr/local/bin/hx711wp_chanB, /usr/local/bin/AdafruitDHT.py, /usr/local/bin/Seeed_DHT22
Test wiringPi library
WiringPi is PRE-INSTALLED with standard Raspbian systems. To update (or install):
sudo apt-get install wiringpi
To test:
$ gpio -v gpio version: 2.50 Copyright (c) 2012-2018 Gordon Henderson This is free software with ABSOLUTELY NO WARRANTY. For details type: gpio -warranty Raspberry Pi Details: Type: Pi 3B+, Revision: 03, Memory: 1024MB, Maker: Sony * Device tree is enabled. *--> Raspberry Pi 3 Model B Plus Rev 1.3 * This Raspberry Pi supports user-level GPIO access.
http://wiringpi.com/download-and-install/
To display all the I/O:
$ gpio readall
phpLiteAdmin 1.9.8.2
Install SQLite database administration tools. Download zipped file from
https://www.phpliteadmin.org/download/
and save in /home/downloads.
mkdir /home/downloads/phpLiteAdmin cd /home/downloads/phpLiteAdmin
wget https://bitbucket.org/phpliteadmin/public/downloads/phpLiteAdmin_v1-9-8-2.zip
Unzip and copy the php files to/var/www/html/admin
unzip phpLiteAdmin_v*.zip sudo mkdir /var/www/html/admin sudo cp *.php /var/www/html/admin
Install php
sudo apt install php7.0 php7.0-cli sudo apt-get install php-sqlite3
Configure phpliteadmin
cd /var/www/html/admin/ sudo cp phpliteadmin.config.sample.php phpliteadmin.config.php vi phpliteadmin.config.php
change
$directory = '.';
to
$directory = '..';
gnuplot
sudo apt-get install gnuplot pip install PyGnuplot
gEDA Schematic/PCB layout software
Install the Electronic Design Automation tools
sudo apt-get update sudo apt-get install geda sudo apt-get install pcb sudo apt-get install gerbv
In /home/pi/.gEDA create /home/pi/.gEDA/gschem
vi /home/pi/.gEDA/gschem
and add the following line
(component-library "/home/hardware/symbols")
Copy the schematics and PCB layouts to /home/hardware.
Install streaming software
Install ffmpeg
Install ffmpeg streaming software for streaming audio and video from the hive
sudo apt-get update sudo apt-get install ffmpeg sudo apt-get install ffmpeg-doc
Oops! ffserver has been dropped from ffmpeg! Replace with mjpg-streamer?
Install Sensor Drivers
BME680
PiMoroni Python driver
sudo curl https://get.pimoroni.com/bme680 | bash
DHTxx Temperature/Humidity Sensor
This code uses the PiGPIO libraries (pigpiod).
- Download the DHT11/21/22/33/44 Sensor code from http://abyz.me.uk/rpi/pigpio/code/DHTXXD.zip
- Unzip
- compile
Note that this code uses the Broadcom GPIO numbering so Ras Pi GPIO 2 <=> Broadcom GPIO 27 Ras Pi GPIO 3 <=> Broadcom GPIO 22
mkdir /home/downloads/DHTxx cd /home/downloads/DHTxx wget http://abyz.me.uk/rpi/pigpio/code/DHTXXD.zip unzip DHTXXD gcc -Wall -pthread -o DHTXXD test_DHTXXD.c DHTXXD.c -lpigpiod_if2
HX711 weight ADC
c code driver is hx711wp
Note: The original hx711 code has been modified to use the wiringPi library and a bug fixed.
- Download the software from gitHub
- cd /home/downloads
- sudo git clone https://github.com/ggurov/hx711
- replace hx711.c with hx711wp.c and add locking.h
- compile
- gcc -o hx711wp hx711wp.c -lwiringPi
- Copy hx711 command to /usr/local/bin:
- sudo cp hx711wp /usr/local/bin/hx711
- To read the battery voltage, copy hx711wp_chanB command to /usr/local/bin:
- sudo cp hx711wp_chanB /usr/local/bin/hx711wp_chanB
python driver
TLS2561 Lux Sensor
2561 Adafruit with modified code.
cp 2561 /usr/local/bin
TLS2591 Lux Sensor
2591 Adafruit with modified code.
-rw-r--r-- 1 root root 10439 Aug 3 01:36 2591a.cpp -rw-r--r-- 1 root root 3303 Aug 3 01:36 2591a.h -rw-r--r-- 1 root root 1509 Aug 3 01:36 2591_pi_2.cpp
gcc 2591_pi_2.cpp 2591a.cpp -lwiringPi -o 2591 cp 2591 /usr/local/bin
Add crontab entries
Edit crontab:
sudo crontab -e
Add to crontab:
# # ### Start of Hivetool crontab entries ### # # start PIGPIO daemon on boot @reboot /usr/local/bin/pigpiod # # start Data Acquisition Daemon on boot # use dad7.sh for hardware version 0.1 through 0.3 # use dad8.sh for hardware version 1.0 and greater @reboot /home/hivetool/dad7.sh @reboot /home/hivetool/dad7.sh # # Check hive instruments every 5 minutes. Kill process after 3 1/2 minutes. 0,5,10,15,20,25,30,35,40,45,50,55 * * * * timeout -s KILL 3.5m /home/hivetool/hive.sh >/dev/null 2>&1 # # Check the server status. Kill process after 1 minute. 4,9,14,19,24,29,34,39,44,49,54,59 * * * * timeout -s KILL 1m /home/hivetool/server_status.sh > /var/www/html/server_status.txt # # Reset the rain gauge at midnight 1 0 * * * timeout -s KILL 1m /home/hivetool/rain_reset.sh # # ### End of HiveTool crontab entries ### #
Install National Time Protocol Daemon (ntpd)
sudo apt-get -y install ntp
Install RTC support
Edit /boot/config.txt. Add:
#enable RTC DS3231 module dtoverlay=i2c-rtc,ds3231
Edit /lib/udev/hwclock-set and comment out these three lines:
#if [ -e /run/systemd/system ] ; then # exit 0 #fi
Set GPU memory
Set GPU_MEM, GPU_MEM_256, GPU_MEM_512, and GPU_MEM_1024 for different Pi models in config.txt. Maybe:
GPU_MEM=64 GPU_MEM_256=64 GPU_MEM_512=128 GPU_MEM_1024=256
Install touchscreen pop up keyboard support
sudo apt-get install matchbox
Install openOCD
sudo apt-get install openocd