Difference between revisions of "Setup camera and such"

From Kandos Digital Embassy
Jump to: navigation, search
(Connect to server)
Line 45: Line 45:
 
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"

Revision as of 08:23, 2 April 2015

Connect to server

  1. eth0 connect inet DHCP
  2. get pigpio library, install.
  3. get dht22 example
  4. set up pigpiod at boot
  5. 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

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