Difference between revisions of "Create SD Image Version 0.71"

From HiveTool
Jump to: navigation, search
(crontab)
(Video)
 
(65 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
 +
The 0.7.1-rc2 image is available for download from Google Drive.  See 1. Download the Image below for the link.  Section 4. Create New Image details the steps used to create the image.  To request new features, add them to the [[Create SD Image Version 0.8]] page.
 +
 +
==Download the Image==
 +
 +
The Wheezy-Hivetool-2015-05-05 image (1 Gig) is available on Google Drive:
 +
 +
https://drive.google.com/file/d/0B_3xqxGS2psWOC02WllXMW9MbXM/view?usp=sharing
 +
 
== Feature Request ==
 
== Feature Request ==
  
  
 
#Most recent raspbian distro
 
#Most recent raspbian distro
#Removal of bloatware from Raspbian (games, educational as discussed)
+
#Removal of bloatware from Raspbian (games, educational, etc.)
 
#Hivetool Support Pi & Pi2 (auto detect preferred)
 
#Hivetool Support Pi & Pi2 (auto detect preferred)
 
#Automatic removal of erroneous data from sensors
 
#Automatic removal of erroneous data from sensors
Line 21: Line 30:
  
 
#Add timeout to crontab so hive.sh can't hang.
 
#Add timeout to crontab so hive.sh can't hang.
 +
#Fix HX711 code addressing and timing to work on Pi2.
 +
#Fix tempered code to work with new TEMPerHUMs.
 +
#Improve Wi-Fi auto reconnect.
  
==Create new image==
+
==Create New Image==
 
=== Get latest Wheezy image ===
 
=== Get latest Wheezy image ===
 
#Download, unzip, burn image.
 
#Download, unzip, burn image.
Line 30: Line 42:
 
=== Set up Wi-Fi ===
 
=== 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:
  
Add to /etc/wpa_supplicant/wpa_supplicant.conf:
+
vi /etc/wpa_supplicant/wpa_supplicant.conf
                                                                                                                                                                                 
+
                                                                                                                                                                               
 
  network={                                                                                                                                                                           
 
  network={                                                                                                                                                                           
 
         ssid="dlink"                                                                                                                                                                 
 
         ssid="dlink"                                                                                                                                                                 
Line 39: Line 52:
 
  }                                                                                                                                                                                   
 
  }                                                                                                                                                                                   
  
 +
2. Wi-Fi auto reconnect to AP
  
====Wi-Fi auto reconnect to AP====
+
Go to /etc/ifplugd/action.d/ and copy the ifupdown file to ifupdown.org
 
+
cp /etc/ifplugd/action.d/ifupdown /etc/ifplugd/action.d/ifupdown.org
#Go to /etc/ifplugd/action.d/ and rename the ifupdown file to ifupdown.original
+
Then copy the ifupdown.sh script provided with wpa supplicant to  /etc/ifplugd/action.d/
#Then do:
+
  cp /etc/wpa_supplicant/ifupdown.sh /etc/ifplugd/action.d/ifupdown
  cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown
 
  
 
http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi
 
http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi
Line 55: Line 68:
 
  sudo apt-get clean
 
  sudo apt-get clean
 
  rm -rf /home/pi/python_games
 
  rm -rf /home/pi/python_games
  sudo rm -rf /opt/vc
+
  sudo rm -rf /opt/minecraft-pi
  
 
https://project.altservice.com/issues/418
 
https://project.altservice.com/issues/418
 +
NO!  Don't do this if you want to use the video camera: sudo rm -rf /opt/vc
  
 
=== Install packages we need ===
 
=== Install packages we need ===
Line 65: Line 79:
 
  sudo cpan GD::Text GD::Graph Date::Format XML::Simple DBI DBD::SQLite
 
  sudo cpan GD::Text GD::Graph Date::Format XML::Simple DBI DBD::SQLite
  
===Configure apache===
+
===Patch perl module GD::Graph===
# Set up apache to listen on port 8080 if using port forwarding:
+
 
#:sudo vi /etc/apache2/ports.conf
+
The Perl Module, GD::Graph needs a patch to correctly draw a graph with two y axes.
#:add Listen 8080
+
 
 +
/usr/local/share/perl/5.14.2/GD/Graph/axestype.pm
 +
 
 +
===Web Server===
 +
====Configure apache====
 
#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
Line 88: Line 106:
 
#Copy the include.load module to enable it
 
#Copy the include.load module to enable it
 
#:sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
 
#:sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
 +
# Set up apache to listen on port 8080 if using port forwarding:
 +
#:sudo vi /etc/apache2/ports.conf
 +
#:add Listen 8080
 
#Restart Apache
 
#Restart Apache
 
  sudo apachectl restart  or      sudo/etc/rc4.d/S02apache2 restart
 
  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 this line in the "User privilege specification" section:
 +
 +
www-data ALL=NOPASSWD: /usr/local/bin/2591, /usr/bin/nice, /home/hivetool/temperhum.sh, /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 config.pl 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
 +
so hive_stats.pl and hive_graphX.pl can access the database:
 +
sudo ln -s /home/hivetool/hivetool_raw.db /var/www
 +
 +
===phpLiteAdmin===
 +
Install SQLite database administration tools.
 +
 +
apt-get install php5 php5-sqlite
 +
cd /var/www
 +
mkdir admin
 +
cd admin
 +
 +
http://www.raspitux.de/en/using-phpliteadmin-with-raspberry-pi/#respond
 +
 +
===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://github.com/signal11/hidapi
 +
cd hidapi
 +
sudo ./bootstrap
 +
sudo ./configure
 +
sudo make
 +
sudo make install
 +
 +
cd ..
 +
 +
#sudo git clone git://github.com/edorfaus/TEMPered
 +
#cd TEMPered
 +
 +
sudo git clone https://github.com/rcrum003/TEMPered-v6-2015
 +
cd TEMPered-v6-2015
 +
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/ld.so.conf
 +
sudo vi /etc/ld.so.conf
 +
 +
So it looks like this:
 +
include /etc/ld.so.conf.d/*.conf
 +
/usr/local/lib/arm-linux-gnueabihf/
 +
 +
 +
Run ldconfig to pick up the new libraries
 +
sudo ldconfig
  
 
===Install Broadcom 2835 Library===
 
===Install Broadcom 2835 Library===
Install bcm2835 library
+
Download and install the bcm2835 library:
 +
cd /home/downloads
 +
curl -o bcm2835-1.42.tar.gz http://www.airspayce.com/mikem/bcm2835/bcm2835-1.42.tar.gz
 +
tar xvf bcm2835-1.42.tar.gz
 +
cd bcm2835-1.42
 +
./configure
 +
make
 +
sudo make check
 +
sudo make install
 +
 
 
http://www.airspayce.com/mikem/bcm2835/
 
http://www.airspayce.com/mikem/bcm2835/
  
=== Install wiringPi library===
+
=== Install i2c support===
 
 
#add i2c-dev to  /etc/modules (?)
 
 
#Install i2c tools
 
#Install i2c tools
apt-get install i2c-tools
+
#: apt-get install i2c-tools
#run raspi-config and turn on i2c or in /etc/modprobe.d/raspi-blacklist.conf comment out:
+
#add i2c-dev to /etc/modules
blacklist i2c-bcm2708 (?)
+
#run raspi-config and turn on i2c
#reboot or run:
 
modprobe -a i2c-bcm2708
 
  
sudo apt-get install git-core
+
=== Install wiringPi library===
git clone git://git.drogon.net/wiringPi
+
#get wiringPi code from github and compile it
cd wiringPi
+
#: cd /home/downloads
./build
+
#: git clone git://git.drogon.net/wiringPi
 +
#: cd wiringPi
 +
#: ./build
 +
#Test
 +
#: gpio -v
 +
#: gpio readall
  
http://wiringpi.com/download-and-install/wiringPi
+
http://wiringpi.com/download-and-install/
  
 
===DHT22 Temperature/Humidity Sensor===
 
===DHT22 Temperature/Humidity Sensor===
Groove Seeed - DHT22 with modified code
+
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".
 +
 
 +
#Install wiringPi libraries
 +
#Get the DHT22 software
 +
#: cd /home/downloads
 +
#: 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
  
 
===HX711 weight ADC===
 
===HX711 weight ADC===
 
hx711wp
 
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 hx711 /usr/local/bin
  
 
===TLS2591 Lux Sensor===
 
===TLS2591 Lux Sensor===
 
2591 Adafruit with modified code.
 
2591 Adafruit with modified code.
  
=== crontab ===
+
-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:
 
Edit crontab:
 
  sudo crontab -e
 
  sudo crontab -e
Line 130: Line 257:
 
  # Check the server status. Kill process after 1 minute.
 
  # 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/server_status.sh > /var/www/server_status.txt
 
  0,5,10,15,20,25,30,35,40,45,50,55 * * * * timeout -s KILL 1m /home/hivetool/server_status.sh > /var/www/server_status.txt
 +
 +
===Video===
 +
Install VLC media software. Note that for the camera to work, it must be enabled by running raspi-config.
 +
apt-get install vlc
 +
 +
Start the video streaming using Real Time Streaming Protocol to port 8554:
 +
raspivid -o - -t 0 -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264 &
 +
 +
===Access Point===
 +
 +
apt-get install hostapd isc-dhcp-server
 +
 +
https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software
 +
 +
==Write Image==
 +
Copy the image to another computer:
 +
dd bs=4M count=1000 of=2015-05-05-raspbian-hivetool.img if=/dev/mmcblk0
 +
 +
Compress the image using zip:
 +
zip 2015-05-05-raspbian-hivetool.zip 2015-05-05-raspbian-hivetool.img

Latest revision as of 17:27, 24 August 2015

The 0.7.1-rc2 image is available for download from Google Drive. See 1. Download the Image below for the link. Section 4. Create New Image details the steps used to create the image. To request new features, add them to the Create SD Image Version 0.8 page.

Download the Image

The Wheezy-Hivetool-2015-05-05 image (1 Gig) is available on Google Drive:

https://drive.google.com/file/d/0B_3xqxGS2psWOC02WllXMW9MbXM/view?usp=sharing

Feature Request

  1. Most recent raspbian distro
  2. Removal of bloatware from Raspbian (games, educational, etc.)
  3. Hivetool Support Pi & Pi2 (auto detect preferred)
  4. Automatic removal of erroneous data from sensors
  5. Basic navigation from webserver index.html, especially config.pl 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. 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. Enable i2c & serial.

Bug Fixes

  1. Add timeout to crontab so hive.sh can't hang.
  2. Fix HX711 code addressing and timing to work on Pi2.
  3. Fix tempered code to work with new TEMPerHUMs.
  4. Improve Wi-Fi auto reconnect.

Create New Image

Get latest Wheezy image

  1. Download, unzip, burn image.
  2. Boot
  3. DO NOT EXPAND file syatem!

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
                                                                                                                                                                               
network={                                                                                                                                                                           
       ssid="dlink"                                                                                                                                                                
       key_mgmt=NONE                                                                                                                                                               
       auth_alg=OPEN                                                                                                                                                               
}                                                                                                                                                                                   

2. Wi-Fi auto reconnect to AP

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

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

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

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

http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi

Remove packages we don't need

This will make room for software without expanding the image.

sudo apt-get remove --purge wolfram-engine penguinspuzzle scratch dillo squeak-vm squeak-plugins-scratch sonic-pi idle idle3 netsurf-gtk netsurf-common
sudo apt-get autoremove
sudo apt-get clean
rm -rf /home/pi/python_games
sudo rm -rf /opt/minecraft-pi

https://project.altservice.com/issues/418 NO! Don't do this if you want to use the video camera: sudo rm -rf /opt/vc

Install packages we need

sudo apt-get -y update
sudo apt-get -y install gawk bc apache2 libusb-dev libgd-graph-perl libexpat1-dev sqlite3
sudo cpan GD::Text GD::Graph Date::Format XML::Simple DBI DBD::SQLite

Patch perl module GD::Graph

The Perl Module, GD::Graph needs a patch to correctly draw a graph with two y axes.

/usr/local/share/perl/5.14.2/GD/Graph/axestype.pm

Web Server

Configure apache

  1. 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
  2. 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
  3. 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
  4. Copy the include.load module to enable it
    sudo cp /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/
  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 config.pl 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/temperhum.sh, /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 config.pl 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 so hive_stats.pl and hive_graphX.pl can access the database:

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

phpLiteAdmin

Install SQLite database administration tools.

apt-get install php5 php5-sqlite
cd /var/www
mkdir admin
cd admin

http://www.raspitux.de/en/using-phpliteadmin-with-raspberry-pi/#respond

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://github.com/signal11/hidapi
cd hidapi
sudo ./bootstrap
sudo ./configure
sudo make
sudo make install
cd ..
#sudo git clone git://github.com/edorfaus/TEMPered
#cd TEMPered
sudo git clone https://github.com/rcrum003/TEMPered-v6-2015
cd TEMPered-v6-2015
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/ld.so.conf

sudo vi /etc/ld.so.conf

So it looks like this:

include /etc/ld.so.conf.d/*.conf
/usr/local/lib/arm-linux-gnueabihf/


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 http://www.airspayce.com/mikem/bcm2835/bcm2835-1.42.tar.gz
tar xvf bcm2835-1.42.tar.gz
cd bcm2835-1.42
./configure
make
sudo make check
sudo make install

http://www.airspayce.com/mikem/bcm2835/

Install i2c support

  1. Install i2c tools
    apt-get install i2c-tools
  2. add i2c-dev to /etc/modules
  3. 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://git.drogon.net/wiringPi
    cd wiringPi
    ./build
  2. Test
    gpio -v
    gpio readall

http://wiringpi.com/download-and-install/

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

HX711 weight ADC

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 hx711 /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:

# 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
#
# 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/server_status.sh > /var/www/server_status.txt

Video

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

apt-get install vlc

Start the video streaming using Real Time Streaming Protocol to port 8554:

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

Access Point

apt-get install hostapd isc-dhcp-server

https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software

Write Image

Copy the image to another computer:

dd bs=4M count=1000 of=2015-05-05-raspbian-hivetool.img if=/dev/mmcblk0

Compress the image using zip:

zip 2015-05-05-raspbian-hivetool.zip 2015-05-05-raspbian-hivetool.img