XXX: Load Hivetool on the Pi

From HiveTool
Revision as of 06:21, 5 October 2014 by Paul (talk | contribs) (Install the HX711 scale software)
Jump to: navigation, search

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: 2013-12-20-wheezy-raspbian.zip

  1. Download the zipped image (approximately 800 MB)
  2. Calculate the SHA-1 checksum. On Unix/Linux, the command line is:
    sha1sum 2012-12-16-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 the image, with
    unzip 2012-12-20-wheezy-raspbian.zip

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=2013-05-25-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 timezone and hostname

  1. Boot Pi and login
  2. Expand file system, set timezone and hostname
    sudo raspi-config
    Raspberry Pi Software Configuration Tool (raspi-config)
1 Expand Filesystem              Ensures that all of the SD card s
4 Internationalisation Options   Set up language and regional sett 
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

Install required packages

Note: The Pi must be connected to the internet to update or add packages!
  1. Update before trying to add packages
    sudo apt-get -y update
Note: Running apt-get update does not fix the shellshock bash vulnerability. You must also run:
      sudo apt-get -y dist-upgrade
  1. Get gawk, bc for shell scripts, apache for webserver, libusb to read TEMPerHUMs, graphics library.
    sudo apt-get install gawk bc apache2 libusb-dev libgd2-xpm-dev
  2. Now get Graphics for perl. Force the install. Get XML::Simple for commands.
    sudo cpan -f GD
    sudo cpan GD::Text GD::Graph Date::Format XML::Simple
  3. Make hivetool and htdocs directories.
    sudo mkdir /home/hivetool /var/www/htdocs /home/downloads
  4. 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/htdocs
  5. 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
  6. get the crontab file
    sudo git clone https://github.com/hivetools/cron

Done installing hivetool files

Set the ethernet parameters and DNS servers

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.

  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 apache

  1. set up apache to listen on port 8080
    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 and add .pl so it looks like:
    AddHandler cgi-script .cgi .pl
  3. add Includes 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
  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 includes.load to enable it
    sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
  6. Restart Apache
/etc/rc4.d/S02apache2 restart


Install the HX711 scale software

  1. Download the software from gitHub
    git clone https://github.com/ggurov/hx711
  2. Change the GPIO pins in hx711.c from 30 and 31
  3. If using P5, change to 28 and 30. This way they are all on one side of P5:
#define CLOCK_PIN       30
#define DATA_PIN        28
  1. If using P1, pick two unused GPIO pins such as:
#define CLOCK_PIN       24
#define DATA_PIN        23
  1. Compile:
 gcc  -o hx711 h711.c gb_common.o

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
    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)
    sudo ldconfig

Install from source

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

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

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