rpi setup - SparkGrads2016/envmonitorSpark GitHub Wiki

Hardware

  • Raspberry Pi B+/2/3
  • Mouse
  • Keyboard
  • 8GB+ micro SD card, Class 10
  • HDMI cable
  • Ethernet cable
  • Wi-Pi dongle if RPi B+/2 used

Pull code onto Pi

Retreive SSH key

Method 1 (Currently used): One private key for every Pi

This method can be automated, though may cause security risks as all Pis will be sharing the same private SSH key.

Get the private SSH key from Richard.

Login to Pi.

Check for existing SSH keys:

ls ~/.ssh

If the directory ".ssh" does not exist, create it with:

sudo mkdir .ssh

Copy the private SSH key into the ~/.ssh/id_rsa file. If the id_rsa file does not exist, create it with:

sudo touch id_rsa

If you see files named id_rsa.pub or id_dsa.pub you have keys set up already.

Method 2 (To be used in future): One SSH key per Pi

This is the correct way to pull code onto each Pi, though we will need to figure out how to do this. There is currently no way to automate this method.

Generate a SSH key

Login to Pi.

Open command line and generate key with command:

ssh-keygen -t rsa
Enter file in which to save the key (/home/pi/.ssh/id_rsa): Press Enter  
Created directory '/home/pi/.ssh'.
Enter passphrase (empty for no passphrase): Press Enter
Enter same passphrase again: Press Enter
Your identification has been saved in /home/pi/.ssh/id_rsa.
Your public key has been saved in /home/pi/.ssh/id_rsa.pub.

A key fingerprint and the key's randomart image will also be generated.

Add SSH key to GitLab

http://doc.gitlab.com/ce/gitlab-basics/create-your-ssh-keys.html

Clone envmonitor repo

cd to where the repo is to be placed.

Make sure you are connected to Spark's internal network:

ping gitlab.telecom.tcnz.net

If packets cannot be received, connect to the internal network before continuing.

Clone the repo:

git clone [email protected]:automation/envmonitor.git

If the line comes up:

The authenticity of host 'gitlab.telecom.tcnz.net (10.XXX.XXX.XXX)' can't be established.

Continue by typing 'yes'

The repo will then be cloned.

Dependencies

Configure I2C

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

Test I2C:

sudo i2cdetect -y 1

Other stuff

sudo apt-get install libffi-dev  
sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev  
sudo pip install cffi  
sudo pip install smbus-cffi  

TSL2591 Light Sensor

sudo apt-get update

https://github.com/maxlklaxl/python-tsl2591

git clone https://github.com/maxlklaxl/python-tsl2591.git

cd to python-tsl2591 directory then enter:

sudo python setup.py install  

DHT22 Temperature and Humidity Sensor

sudo apt-get update

https://github.com/adafruit/Adafruit_Python_DHT

git clone https://github.com/adafruit/Adafruit_Python_DHT.git

cd to Adafruit_Python_DHT directory then enter:

sudo python setup.py install

BMP180 Barometric Pressure, Altitude and Temperature Sensor

sudo apt-get update

https://github.com/adafruit/Adafruit_Python_BMP

git clone https://github.com/adafruit/Adafruit_Python_BMP.git

cd to Adafruit_Python_BMP directory then enter:

sudo python setup.py install

SI1145 UV Sensor

sudo apt-get update

https://github.com/THP-JOE/Python_SI1145

git clone https://github.com/THP-JOE/Python_SI1145.git

cd to Python_SI1145 directory then enter:

sudo python setup.py install

LSM303 Triple-axis Accerometer and Magnetometer

sudo apt-get update

https://github.com/adafruit/Adafruit_Python_LSM303

git clone https://github.com/adafruit/Adafruit_Python_LSM303.git

cd to Adafruit_Python_LSM303 directory then enter:

sudo python setup.py install

Run the program

cd to ~/envmonitor/sensors directory then enter:

sudo python main.py

To change how often the monitor gets information, change the timer in the main.py file

If PIR is to be tested, enter:

sudo python pirSensor.py

Run Pi headless through ethernet port

This will allow you to SSH into the Pi through the ethernet port

https://pihw.wordpress.com/guides/direct-network-connection/

Raspbian GUI on laptop through ethernet

This will allow you to run the Pi GUI through a laptop without the need of a monitor

http://diyhacking.com/connect-raspberry-pi-to-laptop-display/

_