Create SD Image 0.7.3

From HiveTool
(Redirected from Software: Image Details)
Jump to: navigation, search

This page describes how the bootable Raspian-HiveTool image was created. This is for information only. The easiest and best way to install Hivetool is to download the latest image.

Bug Fixes

  1. replace hx711 and dth22 code with fixed versions.
  2. add export LC_NUMERIC="en_US.UTF-8" to
  3. don't remove python tools when removing bloatware. Keep: wolfram-engine - a scientific platform, Idle and Idle3 - python language editors

Feature Request


  1. add Ryans Hive Controller code
  2. add xrdp, open62541 packages
  3. add Data Acquisition Daemon (DAD) code

Dad supports battery voltage monitoring and the rain gauge.


  1. Done Test most recent raspbian distro Jessie (4.1 Kernel)
  2. Done Removal of bloatware from Raspbian (games, educational, etc.)
  3. Done Hivetool Support Pi & Pi2 (auto detect preferred)
  4. Automatic removal of erroneous data from sensors
  5. Done Basic navigation from webserver index.html, especially and Hivestats with download.
  6. Menu driven selection & configuration of sensors (gpio 2,3 for DHT22s preassigned by menu default)
  7. Menu driven setup of essential parameters with choices that don't crash app when saving, grey out unused.
  8. Done Sensor calibration provisions (gain, offset)
  9. Display instantaneous sensor readings from config screen with read button
  10. Preload & configure Apache Webserver and database, Hivetool, sensor drivers for proven sensors.
  11. Update local & online hivestats graphs to display lux trend pen, (use latest hivestats with enhanced autoscaling for local)
  12. Network / wifi support out of the box seems to work well now, handle configuration on router side with DHCP reservation as may be needed.
  13. Add configuration menu item for naming pi, same as hivestats name?
  14. Minimize need to enter Raspiconfig, can timezone and time all be handled in hivetool config?
  15. Done Enable i2c & serial.

How the image was created

Get latest Jessie image

Download, verify the SHA-1 checksum, unzip, burn image.

Verify the checksum:


Unzip the image and copy it to the SD card

dd bs=4M if=2016-02-09-raspbian-jessie.img of=/dev/mmcblk0

Boot Jessie boots directly into the window system. There is now a GUI to Menu -> Preferences->Raspberry Pi Configuration DO NOT EXPAND file system!

Set up Wi-Fi

1. Add your network information to /etc/wpa_supplicant/wpa_supplicant.conf. For an unencrypted open network with an ESSID of dlink:

vi /etc/wpa_supplicant/wpa_supplicant.conf

2. Wi-Fi auto reconnect to AP

Go to /etc/ifplugd/action.d/ and copy the ifupdown file to

cp /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/

Then copy the script provided with wpa supplicant to /etc/ifplugd/action.d/

cp /etc/wpa_supplicant/  /etc/ifplugd/action.d/ifupdown

Remove packages we don't need

This will make room for software without expanding the image.

sudo apt-get remove --purge penguinspuzzle scratch dillo squeak-vm squeak-plugins-scratch sonic-pi netsurf-gtk netsurf-common
sudo apt-get autoremove
sudo apt-get clean
rm -rf /home/pi/python_games
sudo rm -rf /opt/minecraft-pi NO! Don't do this if you want to use the video camera: sudo rm -rf /opt/vc

Update, upgrade

Update the GPU firmware

sudo apt-get install rpi-update
sudo rpi-update

Update the package list and then upgrade the Debian packages (CPU) (includes firmware)

sudo apt-get -y update
sudo apt-get upgrade

Install packages we need

sudo apt-get -y install gawk bc apache2 libusb-dev libgd-graph-perl libexpat1-dev sqlite3
sudo apt-get install dh-autoreconf libudev-dev libusb-1

Install HiveTool software

Create symbolic links to the hivetool log files:

sudo ln -s /home/hivetool/hivetool_raw.db /var/www/html
sudo ln -s /home/hivetool/hive.conf /var/www/html
sudo ln -s /home/hivetool/hivetool.log /var/www/html

Patch perl module GD::Graph

The Perl Module, GD::Graph needs a patch to correctly draw a graph with two y axes. Note that the target directory changes with each new perl version. This time it is 5.20.2. Copy the patched file to it's proper location:

sudo cp /home/downloads/ /usr/local/share/perl/5.20.2/GD/Graph/

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 so it looks like:
    AddHandler cgi-script .cgi .pl
  3. add Includes and +ExecCGI to Options:
    sudo vi /etc/apache2/apache2.conf
    In stanza <Directory /var/www/>
    Options Indexes FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
  4. Add index.shtml to DirectoryIndex:
    sudo vi /etc/apache2/mods-enabled/dir.conf
    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm
    DirectoryIndex index.html index.cgi 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. Restart Apache
sudo apachectl restart   or      sudo/etc/rc4.d/S02apache2 restart

Set sudo user privileges for Apache

This is necessary to allow to read the sensors. Run visudo to edit the sudo config file:

sudo visudo

and insert this line in the "User privilege specification" section:

www-data ALL=NOPASSWD: /usr/local/bin/2591, /usr/bin/nice, /home/hivetool/, /usr/local/bin/hx711, /usr/local/bin/Seeed_DHT22

Create SQLite database

cd /home/hivetool
sqlite3 hivetool_raw.db
sqlite> .read create_hivetool_sqlite.sql
sqlite> .quit

Make it writable or will fail to save to the database.

sudo chmod a+w /home/hivetool/hivetool_raw.db
sudo chmod a+w /home/hivetool

Create a symbolic link to /home/hivetool/hivetool_raw.db from /var/www/html so and can access the database:

sudo ln -s /home/hivetool/hivetool_raw.db /var/www/html/


Install SQLite database administration tools.

sudo apt-get install php5 php5-sqlite
cd /var/www/html
sudo mkdir admin
cd admin
sudo wget
sudo unzip

sudo cp phpliteadmin.config.sample.php phpliteadmin.config.php
vi phpliteadmin.config.php


$directory = '.';  


$directory = '..';

Install TEMPerHUM software

sudo apt-get update
sudo apt-get install dh-autoreconf libudev-dev libusb-1.0-0-dev cmake-curses-gui
cd /home/downloads
sudo git clone git://
cd hidapi
sudo ./bootstrap
sudo ./configure
sudo make
sudo make install
cd ..
#sudo git clone git://
#cd TEMPered
#sudo git clone
#cd TEMPered-v6-2015
git clone git://
sudo ccmake .

Then the sub commands: "c" to configure then "g" to save and go

sudo make
sudo make install

Add /usr/local/lib/arm-linux-gnueabihf/ to /etc/

sudo vi /etc/

So it looks like this:

include /etc/*.conf

Run ldconfig to pick up the new libraries

sudo ldconfig

Install Broadcom 2835 Library

Download and install the bcm2835 library:

cd /home/downloads
curl -o bcm2835-1.42.tar.gz
tar xvf bcm2835-1.42.tar.gz
cd bcm2835-1.42
sudo make check
sudo make install

Install i2c support

  1. Install i2c tools
    apt-get install i2c-tools
  2. run raspi-config and turn on i2c

Install wiringPi library

  1. get wiringPi code from github and compile it
    cd /home/downloads
    git clone git://
    cd wiringPi
  2. Test
    gpio -v
    gpio readall

DHT22 Temperature/Humidity Sensor

Groove Seeed - DHT22 with modified code. Note that the code has been modified to return the temperature and humidity in floating point instead of having to divide it by 10, and a few other "improvements".

  1. Install wiringPi libraries
  2. Get the DHT22 software
    cd /home/downloads
    sudo git clone
    cd Grove-RaspberryPi/Grove\ -\ Temperature\ and\ Humidity\ Sensor\ Pro
    sudo cp Seeed_DHT22 /usr/local/bin

HX711 weight ADC


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

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:

# 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/
# Check the server status. Kill process after 1 minute.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * timeout -s KILL 1m /home/hivetool/ > /var/www/server_status.txt


Install VLC media software. Note that for the camera to work, it must be enabled by running raspi-config.

apt-get install vlc

To automatically start the video streaming using Real Time Streaming Protocol to port 8554, add to /etc/rc.local

# start video stream
su pi /home/hivetool/

/home/hivetool/ should be:

raspivid -n -o - -t 0 -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264

This method uses raspivid to streams video from the PiCam to vlc where is can be accessed with videoLAN, a free and open souce media player for Apple, Linux, Microsoft platforms at port 8554 using RTSP://hive.ip:8554

Access Point

apt-get install hostapd isc-dhcp-server

gEDA Schematic/PCB layout software

sudo apt-get update
sudo apt-get install geda
sudo apt-get install pcb
sudo apt-get install gerbv
sudo apt-get install zip


sudo apt-get install xrdp


sudo git clone git://
# ### sudo apt-get install git build-essential gcc pkg-config cmake python python-lxml
sudo apt-get install cmake cmake-data python-lxml
# enable additional features
sudo apt-get install libexpat1-dev # for XML-encodingi  ### already done
sudo apt-get install liburcu-dev # for multithreading
sudo apt-get install check # for unit tests
sudo apt-get install graphviz doxygen # for documentation generation 

sudo cd open62541
sudo mkdir build
sudo cd build
sudo cmake ..
sudo make

# select additional features
sudo ccmake .. # enter g to build and exit
sudo make

Install touchscreen pop up keyboard support

sudo apt-get install matchbox

Install Hivecontrol

  1. Download
  2. Unzip in /home/hivetool2.
  3. Copy /home/hivetool2/www/public_html/ files to /var/www/html/hivecontrol
  4. Set up virtual host on port 81
  5. Add path to phpSQLiteadmin to database file.
hive-data.db -> /home/HiveControl-master/data/hive-data.db

This may not be right, should link to /home/hivetool2?

Install Desktop Background and Icons

Write Image

Copy the image to another computer:

1. Remove the SD card from the Pi and on another computer, copy the image to a file:

dd bs=4M if=/dev/sdb of=/home/downloads/hivetool073.img

2. Shrink the image:

3. Compress the image using zip:

zip hivetool073.img