Difference between revisions of "Setup camera and such"

From Kandos Digital Embassy
Jump to: navigation, search
(Connect to server)
Line 1: Line 1:
 
== Connect to server ==
 
== Connect to server ==
  
 +
=== Set up general ==
 +
# change host name = basestation-01, edit in /etc/hosts, and /etc/hostname then "sudo /etc/init.d/hostname.sh"
 
# eth0 connect inet DHCP
 
# eth0 connect inet DHCP
 +
 +
=== Temp/Humidity Sensor ==
 +
 
# get pigpio library, install.
 
# get pigpio library, install.
 +
<nowiki>
 +
cd ~
 +
wget abyz.co.uk/rpi/pigpio/pigpio.zip
 +
unzip pigpio.zip
 +
cd PIGPIO
 +
make
 +
make install
 +
</nowiki>
 
# get dht22 example
 
# get dht22 example
 
# [http://www.raspberrypi.org/forums/viewtopic.php?p=515575 set up  pigpiod at boot]
 
# [http://www.raspberrypi.org/forums/viewtopic.php?p=515575 set up  pigpiod at boot]
 +
# if using DHT11 the set up different file for DHT11!  [https://www.dropbox.com/s/326si04qiheqfw1/DHT22.py here is replacement to modify call to include (true) for DHT11)]
 
# make sensor script file and change chmod 755 for executable
 
# make sensor script file and change chmod 755 for executable
 
  <nowiki>
 
  <nowiki>
Line 45: Line 59:
 
sudo service cron restart
 
sudo service cron restart
 
</nowiki>
 
</nowiki>
# change host name = basestation-01, edit in /etc/hosts, and /etc/hostname then "sudo /etc/init.d/hostname.sh"
+
 
 +
=== Camera sending image to Server ===
 +
 
 +
# install sshpass
 +
<nowiki>
 +
sudo apt-get install sshpass
 +
</nowiki>
 +
# add cron command to take image and upload to server
 +
<nowiki>
 +
*/5 * * * * raspistill -o ~/image.jpg && sshpass -p '<password>' scp ~/image.jpg pi@digitalembassy.mesh:/var/www/data/sensors/images/1.jpg
 +
</nowiki>
 +
# restart cron "sudo service cron restart"

Revision as of 08:52, 2 April 2015

Connect to server

= Set up general

  1. change host name = basestation-01, edit in /etc/hosts, and /etc/hostname then "sudo /etc/init.d/hostname.sh"
  2. eth0 connect inet DHCP

= Temp/Humidity Sensor

  1. get pigpio library, install.
cd ~
wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
make install

  1. get dht22 example
  2. set up pigpiod at boot
  3. if using DHT11 the set up different file for DHT11! here is replacement to modify call to include (true) for DHT11)
  4. make sensor script file and change chmod 755 for executable
#!/usr/bin/python
#senddata.py
# get basestation
import sys
import time
id = str(sys.argv[1])
# set up pi and sensors
import os
import urllib
os.chdir('pigpio_dht22')
import pigpio
pi = pigpio.pi()
import DHT22
s = DHT22.sensor(pi, 4)
# get data 
s.trigger()
time.sleep(1)
print('{:3.2f}'.format(s.temperature() / 1.))
print('{:3.2f}'.format(s.humidity() / 1.))
# send data, (download results to nowhere)
urllib.urlretrieve("http://digitalembassy.mesh/data/sensors/logData.php?basestation="+id+"&type=temp&value="+('%.2f' % s.temperature()), filename="/dev/null")
time.sleep(1)
urllib.urlretrieve("http://digitalembassy.mesh/data/sensors/logData.php?basestation="+id+"&type=humidity&value="+('%.2f' % s.humidity()), filename="/dev/null")
# close
#s.cancel()
#pi.stop()
#exit()

  1. set up crontab -e
crontab -e


* * * * * /home/pi/senddata.py 1 >> /home/pi/cron_out.log


sudo service cron restart

Camera sending image to Server

  1. install sshpass
 
sudo apt-get install sshpass

  1. add cron command to take image and upload to server
*/5 * * * * raspistill -o ~/image.jpg && sshpass -p '<password>' scp ~/image.jpg pi@digitalembassy.mesh:/var/www/data/sensors/images/1.jpg

  1. restart cron "sudo service cron restart"