Difference between revisions of "Setup camera and such"

From Kandos Digital Embassy
Jump to: navigation, search
(Connect to server)
Line 37: Line 37:
 
# set up crontab -e
 
# set up crontab -e
 
  <nowiki>
 
  <nowiki>
sudo crontab -e
+
crontab -e
 
</nowiki>
 
</nowiki>
 
  <nowiki>
 
  <nowiki>
Line 45: Line 45:
 
sudo service cron restart
 
sudo service cron restart
 
</nowiki>
 
</nowiki>
 
  
 
== Old approach for hosting data (now using server) ==
 
== Old approach for hosting data (now using server) ==

Revision as of 04:24, 1 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

Old approach for hosting data (now using server)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vlc
sudo apt-get install hostapd
sudo apt-get install dnsmasq

edit the file /etc/network/interfaces and replace the line "iface wlan0 inet ..." with:

iface wlan0 inet static
  address 192.168.42.1
  netmask 255.255.255.0

Edit the file /etc/default/hostapd and change the line:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

edit the file /etc/hostapd/hostapd.conf

interface=wlan0
ssid=TacticalSpaceLab
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0

Change IP and start hostapd

sudo ifconfig wlan0 192.168.42.1
sudo service hostapd start

Maybe it doesn't work. Using EDIMAX interface? Try this version of hostapd (via Dave Conroy)

wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip 
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax 
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd 
sudo chown root.root /usr/sbin/hostapd 
sudo chmod 755 /usr/sbin/hostapd

Set up dnsmasq to give clients DHCP-based IP addresses configure /etc/dnsmasq.conf

interface=wlan0
dhcp-range=192.168.42.50,192.168.42.150,12h

restart dnsmasq

sudo /etc/init.d/dnsmasq restart

Start video share

sudo modprobe bcm2835-v4l2
cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:12345}'