Difference between revisions of "XXX: Load Hivetool on the Pi"

From HiveTool
Jump to: navigation, search
(Get the latest operating system image)
m (Paul moved page Load Hivetool on the Pi to XXX: Load Hivetool on the Pi without leaving a redirect)
 
(118 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
'''This page is old and should probably be deleted.  Please click on the Discussion tab for changes.'''
 +
 +
For a system overview and software flow diagrams see the [[Software]] page.  It is easier to [[Install_Hivetool_SD_image|download an image]] that already has Hivetool installed.  The steps below will load hivetool on a Debian based system.  Some of this software (hx711, dht22, 2591) uses hardware specific to the Pi. Also see [[Create SD Image Version 0.71]] for notes on creating an image for the Pi.
 +
 
==Get the latest operating system image==
 
==Get the latest operating system image==
 
Raspbian Wheezy is currently used, although others should work.   
 
Raspbian Wheezy is currently used, although others should work.   
  
 
The latest image  available from http://www.raspberrypi.org/downloads is:  
 
The latest image  available from http://www.raspberrypi.org/downloads is:  
2013-12-20-wheezy-raspbian.zip  
+
2014-09-09-wheezy-raspbian.zip
  
#Download the zipped image (approximately 500 MB)
+
#Download the zipped image (approximately 900 MB)
#Calculate the SHA-1 checksum. On Unix/Linux, the command line is:
+
#Calculate the SHA-1 checksum. On Linux, the command line is:
#:sha1sum 2012-12-16-wheezy-raspbian.zip  
+
#:sha1sum 2014-09-09-wheezy-raspbian.zip  
 
#: This will print out a long hex number which should match the "SHA-1 Checksum" line for the SD image you have downloaded  
 
#: This will print out a long hex number which should match the "SHA-1 Checksum" line for the SD image you have downloaded  
#Extract the image, with
+
#Extract (unzip) the image. On Linux the command line is:
#:unzip 2012-12-20-wheezy-raspbian.zip
+
#:unzip 2014-09-09-wheezy-raspbian.zip
 +
 
 +
When unzipped, 2014-09-09-wheezy-raspbian.img is about 3.3 GB.
  
 
==Copy the image to the SD card==
 
==Copy the image to the SD card==
Line 18: Line 24:
 
# Determine the device for the card reader (/dev/mmcblk0 on my laptop).
 
# Determine the device for the card reader (/dev/mmcblk0 on my laptop).
 
# Copy the image to the SD card:
 
# Copy the image to the SD card:
#: dd bs=4M if=2013-05-25-wheezy-raspbian.img of=/dev/mmcblk0
+
#: dd bs=4M if=2014-09-09-wheezy-raspbian.img of=/dev/mmcblk0
  
 
===Make SD card on Windows system===
 
===Make SD card on Windows system===
Line 26: Line 32:
 
Detailed instructions: http://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Windows
 
Detailed instructions: http://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Windows
  
==Boot Pi, expand file system, set timezone and hostname==
+
==Boot Pi, expand file system, set locale, timezone and host name==
 +
Access to the Pi's console is needed.  A USB keyboard and either a HDMI or composite video monitor can be used.  I prefer to use a USB to TTL Serial conversion cable that is connected to pins 4,6,8,10 on P1.  The other end is plugged into a USB port on my laptop.  A terminal emulator is required(on Linux I use MiniCom, on Microsoft Windows hyperterm or PuTTY can be used.)  The advantage of connecting this way is the command lines can be cut from the instructions below and pasted into the terminal.
 +
 
 
# Boot Pi and login
 
# Boot Pi and login
# Expand file system, set timezone and hostname
+
# Expand file system, set locale, timezone and hostname using the Raspberry Pi Software Configuration Tool (raspi-config)
 
#: sudo raspi-config
 
#: sudo raspi-config
#: (need details of menu options)
+
# Reboot the Pi
 +
 
 +
1 Expand Filesystem              Ensures that all of the SD card s
 +
4 Internationalisation Options  Set up language and regional sett
 +
I1 Change Locale                Set up language and regional sett  (See Note 1)
 +
I2 Change Timezone                Set up timezone to match your loc
 +
8 Advanced Options                Configure advanced settings
 +
A2 Hostname                      Set the visible name for this Pi (See Note 2)
 +
 
 +
Note 1: down arrow to:  [*] en_GB.UTF-8 UTF-8  Press the space bar to uncheck. 
 +
Down arrow to: [ ] en_US.UTF-8 UTF-8  and press the space bar to check.
 +
Press Tab to move to [OK] and press Enter.
 +
Set the default locale for the system environment to en_US.UTF-8 UTF-8 and select OK.
 +
This will take a few minutes.
 +
 
 +
Note 2: Set the hostname to what  you want to call your hive.
 +
 
 +
Note 3: When you exit the Raspberry Pi Software Configuration Tool after expanding the file system, it will ask you if you want to reboot. You will need to reboot for the expanded file system to take effect, so reboot now.
  
 
==Install required packages==
 
==Install required packages==
# Update before trying to add packages
+
 
#: sudo apt-get update
+
<span style="color: red;"> '''Note the obvious: '''</span><br>
#Get gawk, bc for shell scripts, apache for webserver, and libusb to read TEMPerHUMs.
+
<span style="color: red;">1. The Pi must be connected to the internet to update or add packages!'''</span><br>
#: sudo apt-get install gawk bc apache2
+
<span style="color: red;">2. <u><b>Always</b></u> update before trying to add packages'''</span>
#: sudo apt-get libusb-dev
+
sudo apt-get -y update
#Get the graphics library
+
 
#: sudo apt-get -y install libgd2-xpm-dev build-essential
+
Note: Running apt-get update does not fix the shellshock bash vulnerability.
# Now get Graphics for perl.  Force the install.
+
      Test by running: env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
#: sudo cpan -f GD
+
      If it prints "vulnerable", you should also run:
#: sudo cpan GD::Text GD::Graph Date::Format
+
      sudo apt-get -y dist-upgrade
# Make hivetool and htdocs directories.
+
 
#: sudo mkdir /home/hivetool
+
#Get gawk, bc for shell scripts, apache for webserver, libusb to read TEMPerHUMs,  graphics library for GD::Graph, expat library for XML::Simple, mySQL if desired.
#: sudo mkdir /var/www/htdocs
+
#: Either for SQLite (suggested)
#Copy the patched pm
+
#: sudo apt-get -y install gawk bc apache2 libusb-dev libgd-graph-perl libexpat1-dev sqlite3
#: NOTE: These last two steps need to be changed to get the code from GitHub
+
#:Or for MySQL (deprecated)
#: sudo scp -P8022 paul@192.168.254.31:/usr/local/share/perl/5.14.2/GD/Graph/axestype.pm /usr/local/share/perl/5.14.2/GD/Graph/axestype.pm
+
#: sudo apt-get -y install gawk bc apache2  libusb-dev  libgd-graph-perl libexpat1-dev mysql-server
#Copy the hivetool files"
+
#:
#:  scp -P8022 pi@192.168.254.31:/home/hivetool/* /home/hivetool
+
#: '''Note:  You will be prompted for the MySQL root password.  Do not forget it.  You will need it later.'''
#: sudo scp -P8022 pi@192.168.254.31:/var/www/htdocs/* /var/www/htdocs
+
# Now get Graphics, XML and Database Interface for perl.  
 +
#: sudo cpan GD::Text GD::Graph Date::Format XML::Simple DBI DBD::SQLite
 +
 
 +
==Install Hivetool programs==
 +
# Make two directories: /home/hivetool and /home/downloads.
 +
#: sudo mkdir /home/hivetool   /home/downloads
 +
#Get the perl code, the shtml files and the patched pm and copy it to the perl module directory
 +
#: cd /home/downloads
 +
#: sudo git clone https://github.com/hivetools/perl
 +
#: sudo cp perl/axestype.pm /usr/local/share/perl/5.14.2/GD/Graph/axestype.pm
 +
#: sudo cp perl/*.pl perl/*.shtml /var/www/
 +
#Get the hivetool bash scripts and copy them to their proper directory
 +
#:  sudo git clone https://github.com/hivetools/bash
 +
#: sudo cp bash/*.sh /home/hivetool/
 +
#get the crontab file
 +
#: sudo git clone https://github.com/hivetools/cron
  
 
Done installing hivetool files
 
Done installing hivetool files
  
==Set the ethernet parameters and DNS servers==
+
==Set the Ethernet parameters and DNS servers==
 +
 
 +
If you do not intend to open a hole in the firewall to allow public access to the web server, skip this step and let the Pi obtain an IP from the DHCP server in the router.  Even if you configure port forwarding in the router (for WAN access to the web server, or to secure shell (SSH) in) a static IP may not be required.
 +
 
  
Note: A static IP is  only needed for port forwarding through the firewall. If you do not intend to open a hole in the firewall to allow public access to the web server, skip this step and let the Pi obtain an IP from the DHCP server in the router.
+
<span style="color: red;"> '''This section has changed. Please click on the Discussion tab at the top of this page for changes.''' </span>
  
 +
To set a static IP if needed for port forwarding through the firewall. 
 
#set static ip for port forwarding
 
#set static ip for port forwarding
 
#:sudo vi /etc/network/interfaces:
 
#:sudo vi /etc/network/interfaces:
Line 69: Line 113:
 
#:/etc/network/interfaces
 
#:/etc/network/interfaces
 
#:/etc/dhcp/dhclient.conf
 
#:/etc/dhcp/dhclient.conf
 +
 +
==Configure MySQL==
 +
Note: MySQL is still supported but SQLite is recommend instead of MySQL.
 +
Running an SQL database locally on the Pi is optional.  However, it is necessary to run the latest graphing software.
 +
This configuration was taken from [http://www.ducky-pond.com/posts/2014/Feb/how-to-install-and-optimize-mysql-on-raspberry-pi/ ducky-pond's how to install and optimize mysql on raspberry pi]
 +
#:sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
 +
#:sudo cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf
 +
 +
==Configure SQLite==
 +
Running an SQL database locally on the Pi is optional.  However, it is necessary to run the latest graphing software.  SQLite is used instead of MySQL to lower memory and CPU usage. Run the .sql scripts to set up the database:
 +
 +
sqlite3 hivetool_raw.db
 +
sqlite> .read create_hivetool_sqlite.sql
 +
sqlite> .quit
  
 
==Configure apache==
 
==Configure apache==
# set up apache
+
# Set up apache to listen on port 8080 if using port forwarding:
 
#:sudo vi /etc/apache2/ports.conf
 
#:sudo vi /etc/apache2/ports.conf
#Listen 8080
+
#:add Listen 8080
#add .pl to AddHandler cgi-script
+
#Add .pl to AddHandler cgi-script
#sudo vi /etc/apache2/mods-enabled/mime.conf
+
#:sudo vi /etc/apache2/mods-enabled/mime.conf
#AddHandler cgi-script .cgi .pl
+
#:uncomment #AddHandler cgi-script .cgi (around line 219) and add .pl so it looks like:
#add Includes to Options:
+
#:AddHandler cgi-script .cgi .pl
#sudo vi /etc/apache2/sites-enabled/000-default
+
#add Includes and +ExecCGI to Options:
#Add index.shtml:
+
#:sudo vi /etc/apache2/sites-enabled/000-default
#sudo vi /etc/apache2/mods-enabled/dir.conf  
+
#:In stanza <Directory /var/www/>                                                                                                                                                     
#sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
+
#:change
 +
#: Options Indexes FollowSymLinks MultiViews                                                                                                                         
 +
#:to
 +
#: Options Indexes FollowSymLinks MultiViews 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                                                                                                 
 +
#Copy the include.load module to enable it
 +
#:sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
 +
#Restart Apache
 +
sudo apachectl restart  or      sudo/etc/rc4.d/S02apache2 restart
 +
 
 +
==Install the HX711 scale software==
 +
 
 +
Note: This software was written to talk to the HX711 board via two General Purpose Input Output (GPIO) pins found on header H5 on the A and B models of the Pi.  Neither H5 nor the GPIO signals associated with it are available on the A+ and B+ models.  Also, H5 was not populated.  To use it, pins must be soldered to the Pi. We are trying to standardize on GPIO pins found on all models (see  [[GPIO Pinout]] for a chart) and recommend using GPIO pins 23 and 24 (Step 3.1 below).
  
==Misc==
+
#Download the software from gitHub
#Set the local host name
+
#: cd /home/downloads
#:sudo vi /etc/hostname
+
#: sudo git clone https://github.com/ggurov/hx711
#and edit the local host name here, too:
+
# Edit hx711.c with nano or vi and change the GPIO pins from 30 and 31
#:sudo vi /etc/hosts
+
#: cd hx711
 +
#: nano hx711.c    ( or vi hx711.c )
 +
#Select the proper GPIO pins on lines 13 and 14 (select either step 1 or 2 below).
 +
##If using H1 (the header on the Model A or B) or J8 (the header on the A+ and B+), pick two unused GPIO pins but we recommend using 23 and 24:
 +
##: #define CLOCK_PIN      24
 +
##: #define DATA_PIN        23
 +
##If using H5 on the Model A or B (deprecated, not recommended and not available on the model A+ or B+), change to 28 and 30.  This way they are all on one side of P5:
 +
##: #define CLOCK_PIN      30
 +
##: #define DATA_PIN        28
 +
#Compile:
 +
#:  gcc  -o hx711 hx711.c gb_common.o
 +
#Copy hx711 command to /usr/local/bin:
 +
#: sudo cp hx711 /usr/local/bin
  
 
==Install the TEMPerHUM software==
 
==Install the TEMPerHUM software==
Install the binaries: http://hivetool.net/node/64<br>
+
tempered can be installed with just the binaries (quicker) or from source (you have the source code to fix bugs)
or<br>
+
 +
===Install binaries===
 +
#get the binaries and libraries
 +
#:  cd /home/downloads
 +
#:  sudo git clone https://github.com/hivetools/tempered_pi
 +
#copy the files to their directories
 +
#: cd tempered_pi
 +
#: sudo cp hid-query tempered /usr/local/bin/
 +
#: sudo cp libtempered-util.so  libtempered-util.so.0  libtempered.so  libtempered.so.0 /usr/lib/arm-linux-gnueabihf/
 +
#: sudo cp libhidapi-hidraw.so.0 /usr/local/lib/
 +
#: sudo cp tempered-util.h  tempered.h /usr/local/include/
 +
# run ldconfig (or reboot) to load the new library
 +
#: sudo ldconfig
 +
# Test by plugging in a TEMPerHUM and running:
 +
#: sudo tempered
 +
# It should return something like:
 +
#: /dev/hidraw1 0: temperature 20.69 °C, relative humidity 46.0%, dew point 8.6 °C
 +
 
 +
===Install from source===
 
Install from source: http://hivetool.net/node/59<br>
 
Install from source: http://hivetool.net/node/59<br>
 +
 +
==Install the DHT22 software==
 +
#Install wiringPi libraries
 +
#: cd /home/downoads
 +
#: git clone git://git.drogon.net/wiringPi
 +
#: cd wiringPi
 +
#: ./build
 +
#Test wiringPi ibraries with:
 +
#: gpio -v
 +
#: gpio readall
 +
#Get the DHT22 software
 +
#: sudo git clone https://github.com/Seeed-Studio/Grove-RaspberryPi.git<br>
 +
#: cd Grove-RaspberryPi/Grove\ -\ Temperature\ and\ Humidity\ Sensor\ Pro
 +
#: make
 +
#: sudo cp Seeed_DHT22 /usr/local/bin
 +
 +
==Install the TSL2591 software==
 +
#add i2c-dev to  /etc/modules
 +
#Install the i2c libraries
 +
#: apt-get install i2c-tools
 +
#run raspi-config and turn on i2c or in /etc/modprobe.d/raspi-blacklist.conf comment out: blacklist i2c-bcm2708
 +
#reboot or run:
 +
#: modprobe -a i2c-bcm2708
 +
#Install wiringPi libraries
 +
#: cd /home/downoads
 +
#: git clone git://git.drogon.net/wiringPi
 +
#: cd wiringPi
 +
#: ./build
 +
#Test wiringPi ibraries with:
 +
#: gpio -v
 +
#: gpio readall
 +
#Download 2591 software
 +
#Copy to /usr/local/bin
  
 
==Edit the cron table==
 
==Edit the cron table==
The scripts that read the sensors, log the data, and send it off site (if enabled) are run periodically by the scheduler, cron.  Cron setup is done with crontab.  For cron setup and examples, see [[Cron|Sample contab entries]]
+
The scripts that read the sensors, log the data, and send it off site (if enabled) are run periodically by the scheduler, cron.  Cron setup can be done from the command line with crontab.  For cron setup and examples, see [[Cron|Sample contab entries]]
 +
 
 +
sudo crontab -e
 +
 
 +
==Set or change hostname==
 +
If the hostname was not set above using raspi-config, set the hostname:
  
[[Cron]]
+
#Set the local host name
 +
#:sudo vi /etc/hostname
 +
#and edit the local host name here, too:
 +
#:sudo vi /etc/hosts

Latest revision as of 03:38, 9 March 2016

This page is old and should probably be deleted. Please click on the Discussion tab for changes.

For a system overview and software flow diagrams see the Software page. It is easier to download an image that already has Hivetool installed. The steps below will load hivetool on a Debian based system. Some of this software (hx711, dht22, 2591) uses hardware specific to the Pi. Also see Create SD Image Version 0.71 for notes on creating an image for the Pi.

Get the latest operating system image

Raspbian Wheezy is currently used, although others should work.

The latest image available from http://www.raspberrypi.org/downloads is: 2014-09-09-wheezy-raspbian.zip

  1. Download the zipped image (approximately 900 MB)
  2. Calculate the SHA-1 checksum. On Linux, the command line is:
    sha1sum 2014-09-09-wheezy-raspbian.zip
    This will print out a long hex number which should match the "SHA-1 Checksum" line for the SD image you have downloaded
  3. Extract (unzip) the image. On Linux the command line is:
    unzip 2014-09-09-wheezy-raspbian.zip

When unzipped, 2014-09-09-wheezy-raspbian.img is about 3.3 GB.

Copy the image to the SD card

Make SD card on Unix/Linux system

Detailed instructions: http://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Linux_.28including_on_a_Pi.21.29

  1. Determine the device for the card reader (/dev/mmcblk0 on my laptop).
  2. Copy the image to the SD card:
    dd bs=4M if=2014-09-09-wheezy-raspbian.img of=/dev/mmcblk0

Make SD card on Windows system

raspberrypi.org recommends using: http://sourceforge.net/projects/win32diskimager/ But be careful. REMOVE any other USB memory devices from your computer. Detailed instructions: http://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Windows

Boot Pi, expand file system, set locale, timezone and host name

Access to the Pi's console is needed. A USB keyboard and either a HDMI or composite video monitor can be used. I prefer to use a USB to TTL Serial conversion cable that is connected to pins 4,6,8,10 on P1. The other end is plugged into a USB port on my laptop. A terminal emulator is required(on Linux I use MiniCom, on Microsoft Windows hyperterm or PuTTY can be used.) The advantage of connecting this way is the command lines can be cut from the instructions below and pasted into the terminal.

  1. Boot Pi and login
  2. Expand file system, set locale, timezone and hostname using the Raspberry Pi Software Configuration Tool (raspi-config)
    sudo raspi-config
  3. Reboot the Pi
1 Expand Filesystem              Ensures that all of the SD card s
4 Internationalisation Options   Set up language and regional sett 
I1 Change Locale                 Set up language and regional sett  (See Note 1)
I2 Change Timezone                Set up timezone to match your loc 
8 Advanced Options                Configure advanced settings
A2 Hostname                       Set the visible name for this Pi (See Note 2)

Note 1: down arrow to: [*] en_GB.UTF-8 UTF-8 Press the space bar to uncheck. Down arrow to: [ ] en_US.UTF-8 UTF-8 and press the space bar to check. Press Tab to move to [OK] and press Enter. Set the default locale for the system environment to en_US.UTF-8 UTF-8 and select OK. This will take a few minutes.

Note 2: Set the hostname to what you want to call your hive.

Note 3: When you exit the Raspberry Pi Software Configuration Tool after expanding the file system, it will ask you if you want to reboot. You will need to reboot for the expanded file system to take effect, so reboot now.

Install required packages

Note the obvious:
1. The Pi must be connected to the internet to update or add packages!
2. Always update before trying to add packages

sudo apt-get -y update
Note: Running apt-get update does not fix the shellshock bash vulnerability. 
      Test by running: env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
      If it prints "vulnerable", you should also run:
      sudo apt-get -y dist-upgrade
  1. Get gawk, bc for shell scripts, apache for webserver, libusb to read TEMPerHUMs, graphics library for GD::Graph, expat library for XML::Simple, mySQL if desired.
    Either for SQLite (suggested)
    sudo apt-get -y install gawk bc apache2 libusb-dev libgd-graph-perl libexpat1-dev sqlite3
    Or for MySQL (deprecated)
    sudo apt-get -y install gawk bc apache2 libusb-dev libgd-graph-perl libexpat1-dev mysql-server
    Note: You will be prompted for the MySQL root password. Do not forget it. You will need it later.
  2. Now get Graphics, XML and Database Interface for perl.
    sudo cpan GD::Text GD::Graph Date::Format XML::Simple DBI DBD::SQLite

Install Hivetool programs

  1. Make two directories: /home/hivetool and /home/downloads.
    sudo mkdir /home/hivetool /home/downloads
  2. Get the perl code, the shtml files and the patched pm and copy it to the perl module directory
    cd /home/downloads
    sudo git clone https://github.com/hivetools/perl
    sudo cp perl/axestype.pm /usr/local/share/perl/5.14.2/GD/Graph/axestype.pm
    sudo cp perl/*.pl perl/*.shtml /var/www/
  3. Get the hivetool bash scripts and copy them to their proper directory
    sudo git clone https://github.com/hivetools/bash
    sudo cp bash/*.sh /home/hivetool/
  4. get the crontab file
    sudo git clone https://github.com/hivetools/cron

Done installing hivetool files

Set the Ethernet parameters and DNS servers

If you do not intend to open a hole in the firewall to allow public access to the web server, skip this step and let the Pi obtain an IP from the DHCP server in the router. Even if you configure port forwarding in the router (for WAN access to the web server, or to secure shell (SSH) in) a static IP may not be required.


This section has changed. Please click on the Discussion tab at the top of this page for changes.

To set a static IP if needed for port forwarding through the firewall.

  1. set static ip for port forwarding
    sudo vi /etc/network/interfaces:
    iface eth0 inet dhcp
    iface eth0 inet static
    address 192.168.254.31
    netmask 255.255.255.0
    gateway 192.168.254.254
  2. Set the dns Servers
    /etc/network/interfaces
    /etc/dhcp/dhclient.conf

Configure MySQL

Note: MySQL is still supported but SQLite is recommend instead of MySQL. Running an SQL database locally on the Pi is optional. However, it is necessary to run the latest graphing software. This configuration was taken from ducky-pond's how to install and optimize mysql on raspberry pi

  1. sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
    sudo cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf

Configure SQLite

Running an SQL database locally on the Pi is optional. However, it is necessary to run the latest graphing software. SQLite is used instead of MySQL to lower memory and CPU usage. Run the .sql scripts to set up the database:

sqlite3 hivetool_raw.db
sqlite> .read create_hivetool_sqlite.sql
sqlite> .quit

Configure apache

  1. Set up apache to listen on port 8080 if using port forwarding:
    sudo vi /etc/apache2/ports.conf
    add Listen 8080
  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/sites-enabled/000-default
    In stanza <Directory /var/www/>
    change
    Options Indexes FollowSymLinks MultiViews
    to
    Options Indexes FollowSymLinks MultiViews 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. Copy the include.load module to enable it
    sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
  6. Restart Apache
sudo apachectl restart   or      sudo/etc/rc4.d/S02apache2 restart

Install the HX711 scale software

Note: This software was written to talk to the HX711 board via two General Purpose Input Output (GPIO) pins found on header H5 on the A and B models of the Pi. Neither H5 nor the GPIO signals associated with it are available on the A+ and B+ models. Also, H5 was not populated. To use it, pins must be soldered to the Pi. We are trying to standardize on GPIO pins found on all models (see GPIO Pinout for a chart) and recommend using GPIO pins 23 and 24 (Step 3.1 below).

  1. Download the software from gitHub
    cd /home/downloads
    sudo git clone https://github.com/ggurov/hx711
  2. Edit hx711.c with nano or vi and change the GPIO pins from 30 and 31
    cd hx711
    nano hx711.c ( or vi hx711.c )
  3. Select the proper GPIO pins on lines 13 and 14 (select either step 1 or 2 below).
    1. If using H1 (the header on the Model A or B) or J8 (the header on the A+ and B+), pick two unused GPIO pins but we recommend using 23 and 24:
      #define CLOCK_PIN 24
      #define DATA_PIN 23
    2. If using H5 on the Model A or B (deprecated, not recommended and not available on the model A+ or B+), change to 28 and 30. This way they are all on one side of P5:
      #define CLOCK_PIN 30
      #define DATA_PIN 28
  4. Compile:
    gcc -o hx711 hx711.c gb_common.o
  5. Copy hx711 command to /usr/local/bin:
    sudo cp hx711 /usr/local/bin

Install the TEMPerHUM software

tempered can be installed with just the binaries (quicker) or from source (you have the source code to fix bugs)

Install binaries

  1. get the binaries and libraries
    cd /home/downloads
    sudo git clone https://github.com/hivetools/tempered_pi
  2. copy the files to their directories
    cd tempered_pi
    sudo cp hid-query tempered /usr/local/bin/
    sudo cp libtempered-util.so libtempered-util.so.0 libtempered.so libtempered.so.0 /usr/lib/arm-linux-gnueabihf/
    sudo cp libhidapi-hidraw.so.0 /usr/local/lib/
    sudo cp tempered-util.h tempered.h /usr/local/include/
  3. run ldconfig (or reboot) to load the new library
    sudo ldconfig
  4. Test by plugging in a TEMPerHUM and running:
    sudo tempered
  5. It should return something like:
    /dev/hidraw1 0: temperature 20.69 °C, relative humidity 46.0%, dew point 8.6 °C

Install from source

Install from source: http://hivetool.net/node/59

Install the DHT22 software

  1. Install wiringPi libraries
    cd /home/downoads
    git clone git://git.drogon.net/wiringPi
    cd wiringPi
    ./build
  2. Test wiringPi ibraries with:
    gpio -v
    gpio readall
  3. Get the DHT22 software
    sudo git clone https://github.com/Seeed-Studio/Grove-RaspberryPi.git
    cd Grove-RaspberryPi/Grove\ -\ Temperature\ and\ Humidity\ Sensor\ Pro
    make
    sudo cp Seeed_DHT22 /usr/local/bin

Install the TSL2591 software

  1. add i2c-dev to /etc/modules
  2. Install the i2c libraries
    apt-get install i2c-tools
  3. run raspi-config and turn on i2c or in /etc/modprobe.d/raspi-blacklist.conf comment out: blacklist i2c-bcm2708
  4. reboot or run:
    modprobe -a i2c-bcm2708
  5. Install wiringPi libraries
    cd /home/downoads
    git clone git://git.drogon.net/wiringPi
    cd wiringPi
    ./build
  6. Test wiringPi ibraries with:
    gpio -v
    gpio readall
  7. Download 2591 software
  8. Copy to /usr/local/bin

Edit the cron table

The scripts that read the sensors, log the data, and send it off site (if enabled) are run periodically by the scheduler, cron. Cron setup can be done from the command line with crontab. For cron setup and examples, see Sample contab entries

sudo crontab -e

Set or change hostname

If the hostname was not set above using raspi-config, set the hostname:

  1. Set the local host name
    sudo vi /etc/hostname
  2. and edit the local host name here, too:
    sudo vi /etc/hosts