Difference between revisions of "Create SD Image Version 0.8.4"

From HiveTool
Jump to: navigation, search
(Get latest Stretch image)
 
(91 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
 +
The HiveTool image for the Raspberry Pi Version 0.8.4 Release is available here:
 +
 +
https://drive.google.com/file/d/1OOj3Qr1wLT34Kb_9Wgc6NaWjjhrD8Xwc
 +
 +
The sizes are:
 +
-rw-r--r-- 1 root root  7633912320 Mar 19 07:49 hivetool084.img
 +
-rw-r--r-- 1 root root  3018060152 Mar 19 21:50 hivetool084.img.zip
 +
 +
 +
The sha1, md5 and sha256 sums of the zipped image are:
 +
 +
$ sha1sum hivetool084.img.zip
 +
64ce4377b7a57e22b7603ad72467118a70a8e5f3  hivetool084.img.zip
 +
 +
$ md5sum hivetool084.img.zip
 +
dc3f9f64289f35f38ecf9eb4f0d50723  hivetool084.img.zip
 +
 +
$ openssl dgst -sha256 -hex hivetool084.img.zip
 +
SHA256(hivetool084.img.zip)= 80dfe6c7109cde72fa8980780b54075ba3710a76230177a0e4f9fde619073319
 +
 +
 +
The sha1, md5 and sha256 sums of the unzipped image are:
 +
 +
$ sha1sum hivetool084.img
 +
508e109511c1203f2b8eb25d0ef0589d5dd4a0ef  hivetool084.img
 +
 
 +
$ md5sum hivetool084.img
 +
6be6f7185d2348ce1bdd1f078af2d870  hivetool084.img
 +
 +
$ openssl dgst -sha256 -hex hivetool084.img
 +
SHA256(hivetool084.img)= 2bc149b4267a9e4a6593d7ef290abd654f3ffce35b8f1555029038ba8de5d14a
 +
 +
See the [[Remote Access]] page for details using PuTTy, XRDP or VNC for remote access.
 +
 +
 
===Bug fixes===
 
===Bug fixes===
 
#Fix problem with config.pl taking a long time to load
 
#Fix problem with config.pl taking a long time to load
 
#Fix problem with data on charts not aligning properly.
 
#Fix problem with data on charts not aligning properly.
 +
#Fix problem with config.pl when saving with blank fields (elevation).
 +
#Fix problem with weather station temp and dew point dropping negative signs (not parsing correctly in hive.sh).
 +
#:add -E to grep command and \-? to regex.
 +
#Fix problem with hive.sh failure when locale set to Norway.
 +
#:Add export LC_ALL=C.UTF-8 to beginning of hive.sh
  
 
===Features===
 
===Features===
Line 9: Line 50:
 
#Add support for [[Sensors: DS18B20|DS18B20]]
 
#Add support for [[Sensors: DS18B20|DS18B20]]
 
#Increase resolution of the weight from xxx.xx to xxx.xxx
 
#Increase resolution of the weight from xxx.xx to xxx.xxx
 +
#Added video monitoring with RasPi Cam.
  
 
=== Install gnuplot===
 
=== Install gnuplot===
Line 69: Line 111:
  
 
==How the image was created==
 
==How the image was created==
=== Get latest Stretch image ===
+
=== Get latest image ===
 
Download, verify the SHA256 checksum, unzip, burn image.
 
Download, verify the SHA256 checksum, unzip, burn image.
  
  Version: November 2018
+
Image with desktop and recommended software based on Debian Buster
  Release date: 2018-11-13
+
  Version: July 2019
  Kernel version: 4.14
+
  Release date: 2019-07-10
 +
  Kernel version: 4.19
 +
Size: 1945 MB
 +
SHA-256: 2bd0613ec8739b6fa4274ea186ec859046f79e6aee4b8c6af0acb6d88f3f533a
  
 
Verify the checksum:
 
Verify the checksum:
  
  $ openssl dgst -sha256 -hex 2018-11-13-raspbian-stretch-full.zip
+
  $ openssl dgst -sha256 -hex 2019-07-10-raspbian-buster-full.zip
+
  SHA256(2019-07-10-raspbian-buster-full.zip)= 2bd0613ec8739b6fa4274ea186ec859046f79e6aee4b8c6af0acb6d88f3f533a
  SHA256(2018-11-13-raspbian-stretch-full.zip)= 0ca644539fdaf4e19ec7cebf9e61c049b82ba45b1a21cdec91fa54bd59d660d2
 
  
 
Unzip the image
 
Unzip the image
  
  $ unzip 2018-11-13-raspbian-stretch-full.zip
+
  $ unzip 2019-07-10-raspbian-buster-full.zip  
  Archive:  2018-11-13-raspbian-stretch-full.zip
+
  Archive:  2019-07-10-raspbian-buster-full.zip
  inflating: 2018-11-13-raspbian-stretch-full.img
+
  inflating: 2019-07-10-raspbian-buster-full.img
  
 
Copy it to the SD card  
 
Copy it to the SD card  
  
  # dd bs=40M if=2018-11-13-raspbian-stretch-full.img of=/dev/sdc
+
  # dd bs=40M if=2019-07-10-raspbian-buster-full.img of=/dev/sdb
  126+1 records in
+
  153+1 records in
  126+1 records out
+
  153+1 records out
  5297405952 bytes (5.3 GB, 4.9 GiB) copied, 890.612 s, 5.9 MB/s
+
  6434062336 bytes (6.4 GB, 6.0 GiB) copied, 819.132 s, 7.9 MB/s
  
 
Boot
 
Boot
 +
Buster 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
  
Stretch boots directly into the window system.
+
=== 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 libcgi-pm-perl
 +
apt-get install libxml-perl
 +
apt-get install libxml-simple-perl
 +
apt-get install libdatetime-perl
 +
apt-get install libdbi-perl
 +
apt-get install libdbd-sqlite3-perl
 +
apt-get install libchart-gnuplot-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
 +
#Copy 000-default.conf to sites-enabled and add port 8080
 +
#:cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/
 +
#Edit /etc/apache2/sites-enabled/000-default.conf and add port 8080
 +
#:vi sites-enabled/000-default.conf
 +
#:and change the first line to:
 +
#:<VirtualHost *:80 *:8080>
 +
# Turn off logging for video frames
 +
#:vi sites-enabled/000-default.conf
 +
#:CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
 +
#:SetEnvIf Request_URI "^/cam_pic.php$" dontlog
 +
 
 +
#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: /home/hivetool/bme680-1.py, /home/hivetool/bme680.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 -y install geda pcb 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.
 +
 
 +
===LibreCAD software===
 +
sudo apt-get install librecad
 +
 
 +
===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
 +
 
 +
 
 +
 
 +
====Python DHT22 code from Adafruit====
 +
 
 +
'''''DEPRICATED''''' Do not use - breaks I2C bus
 +
 
 +
*** sudo apt-get install python-dev *** NOT NECESSARY ALREADY INSTALLED ***
 +
cd /home/downloads
 +
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
 +
cd Adafruit_Python_DHT
 +
sudo python setup.py install
 +
cd examples
 +
python AdafruitDHT.py
 +
 
 +
====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
 +
 
 +
===Set up users/passwords for web interfaces===
 +
 
 +
htpasswd -c /usr/local/.htpasswd [USER]
 +
 
 +
Create access levels for RPi Cam
 +
 
 +
vi /var/www/html/cam/userLevel
 +
 
 +
===Add version to wallpaper for desktop===
 +
sudo cp /home/pi/temple_hivetool.jpg /usr/share/rpd-wallpaper/

Latest revision as of 18:11, 20 March 2020

The HiveTool image for the Raspberry Pi Version 0.8.4 Release is available here:

https://drive.google.com/file/d/1OOj3Qr1wLT34Kb_9Wgc6NaWjjhrD8Xwc

The sizes are:

-rw-r--r-- 1 root root  7633912320 Mar 19 07:49 hivetool084.img 
-rw-r--r-- 1 root root  3018060152 Mar 19 21:50 hivetool084.img.zip


The sha1, md5 and sha256 sums of the zipped image are:

$ sha1sum hivetool084.img.zip 
64ce4377b7a57e22b7603ad72467118a70a8e5f3  hivetool084.img.zip

$ md5sum hivetool084.img.zip
dc3f9f64289f35f38ecf9eb4f0d50723  hivetool084.img.zip

$ openssl dgst -sha256 -hex hivetool084.img.zip 
SHA256(hivetool084.img.zip)= 80dfe6c7109cde72fa8980780b54075ba3710a76230177a0e4f9fde619073319


The sha1, md5 and sha256 sums of the unzipped image are:

$ sha1sum hivetool084.img
508e109511c1203f2b8eb25d0ef0589d5dd4a0ef  hivetool084.img
 
$ md5sum hivetool084.img
6be6f7185d2348ce1bdd1f078af2d870  hivetool084.img

$ openssl dgst -sha256 -hex hivetool084.img
SHA256(hivetool084.img)= 2bc149b4267a9e4a6593d7ef290abd654f3ffce35b8f1555029038ba8de5d14a

See the Remote Access page for details using PuTTy, XRDP or VNC for remote access.


Bug fixes

  1. Fix problem with config.pl taking a long time to load
  2. Fix problem with data on charts not aligning properly.
  3. Fix problem with config.pl when saving with blank fields (elevation).
  4. Fix problem with weather station temp and dew point dropping negative signs (not parsing correctly in hive.sh).
    add -E to grep command and \-? to regex.
  5. Fix problem with hive.sh failure when locale set to Norway.
    Add export LC_ALL=C.UTF-8 to beginning of hive.sh

Features

  1. Change graph generation to gnuplot.
  2. Added additional graphs for wind and battery voltage.
  3. Add support for BME680
  4. Add support for DS18B20
  5. Increase resolution of the weight from xxx.xx to xxx.xxx
  6. 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 Buster 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 libcgi-pm-perl
apt-get install libxml-perl
apt-get install libxml-simple-perl
apt-get install libdatetime-perl
apt-get install libdbi-perl
apt-get install libdbd-sqlite3-perl
apt-get install libchart-gnuplot-perl

Web Server

Configure apache

  1. 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
  2. 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
  3. 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
  4. 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
  5. Set up apache to listen on port 8080 if using port forwarding:
    sudo vi /etc/apache2/ports.conf
    add Listen 8080
  6. Copy 000-default.conf to sites-enabled and add port 8080
    cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/
  7. Edit /etc/apache2/sites-enabled/000-default.conf and add port 8080
    vi sites-enabled/000-default.conf
    and change the first line to:
    <VirtualHost *:80 *:8080>
  8. Turn off logging for video frames
    vi sites-enabled/000-default.conf
    CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
    SetEnvIf Request_URI "^/cam_pic.php$" dontlog
  1. 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: /home/hivetool/bme680-1.py, /home/hivetool/bme680.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 -y install geda pcb 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.

LibreCAD software

sudo apt-get install librecad

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).

  1. Download the DHT11/21/22/33/44 Sensor code from http://abyz.me.uk/rpi/pigpio/code/DHTXXD.zip
  2. Unzip
  3. 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


Python DHT22 code from Adafruit

DEPRICATED Do not use - breaks I2C bus

*** sudo apt-get install python-dev *** NOT NECESSARY ALREADY INSTALLED ***
cd /home/downloads
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python setup.py install
cd examples
python AdafruitDHT.py

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.

  1. Download the software from gitHub
    cd /home/downloads
    sudo git clone https://github.com/ggurov/hx711
  2. replace hx711.c with hx711wp.c and add locking.h
  3. compile
    gcc -o hx711wp hx711wp.c -lwiringPi
  4. Copy hx711 command to /usr/local/bin:
    sudo cp hx711wp /usr/local/bin/hx711
  5. 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

Set up users/passwords for web interfaces

htpasswd -c /usr/local/.htpasswd [USER]

Create access levels for RPi Cam

vi /var/www/html/cam/userLevel

Add version to wallpaper for desktop

sudo cp /home/pi/temple_hivetool.jpg /usr/share/rpd-wallpaper/