|
|
Line 44: |
Line 44: |
| <nowiki> | | <nowiki> |
| sudo service cron restart | | sudo service cron restart |
− | </nowiki>
| |
− |
| |
− | == Old approach for hosting data (now using server) ==
| |
− | <nowiki>
| |
− | sudo apt-get update
| |
− | sudo apt-get upgrade
| |
− | sudo apt-get install vlc
| |
− | sudo apt-get install hostapd
| |
− | sudo apt-get install dnsmasq
| |
− | </nowiki>
| |
− | edit the file /etc/network/interfaces and replace the line "iface wlan0 inet ..." with:
| |
− | <nowiki>
| |
− | iface wlan0 inet static
| |
− | address 192.168.42.1
| |
− | netmask 255.255.255.0
| |
− | </nowiki>
| |
− | Edit the file /etc/default/hostapd and change the line:
| |
− | <nowiki>
| |
− | DAEMON_CONF="/etc/hostapd/hostapd.conf"
| |
− | </nowiki>
| |
− | edit the file /etc/hostapd/hostapd.conf
| |
− | <nowiki>
| |
− | interface=wlan0
| |
− | ssid=TacticalSpaceLab
| |
− | hw_mode=g
| |
− | channel=6
| |
− | auth_algs=1
| |
− | wmm_enabled=0
| |
− | </nowiki>
| |
− | Change IP and start hostapd
| |
− | <nowiki>
| |
− | sudo ifconfig wlan0 192.168.42.1
| |
− | sudo service hostapd start
| |
− | </nowiki>
| |
− | Maybe it doesn't work. Using EDIMAX interface? Try this version of hostapd (via [http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/ Dave Conroy])
| |
− | <nowiki>
| |
− | 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
| |
− | </nowiki>
| |
− | Set up dnsmasq to give clients DHCP-based IP addresses
| |
− | configure /etc/dnsmasq.conf
| |
− | <nowiki>
| |
− | interface=wlan0
| |
− | dhcp-range=192.168.42.50,192.168.42.150,12h
| |
− | </nowiki>
| |
− | restart dnsmasq
| |
− | <nowiki>
| |
− | sudo /etc/init.d/dnsmasq restart
| |
− | </nowiki>
| |
− | Start video share
| |
− | <nowiki>
| |
− | 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}'
| |
| </nowiki> | | </nowiki> |
Revision as of 05:26, 2 April 2015
Connect to server
- eth0 connect inet DHCP
- get pigpio library, install.
- get dht22 example
- set up pigpiod at boot
- 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()
- set up crontab -e
crontab -e
* * * * * /home/pi/senddata.py 1 >> /home/pi/cron_out.log
sudo service cron restart