-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
#!/usr/bin/python | ||
from picamera import PiCamera | ||
from time import sleep | ||
import sys | ||
from sendimage import * | ||
|
||
|
||
ip = sys.argv[1] | ||
dev = sys.argv[2] | ||
|
||
import RPi.GPIO as GPIO | ||
import time | ||
|
||
GPIO.setmode(GPIO.BOARD) | ||
GPIO.setup(7,GPIO.IN) | ||
GPIO.setup(31,GPIO.OUT) | ||
GPIO.output(31,0) | ||
camera = PiCamera() | ||
|
||
while True: | ||
while GPIO.input(7) != 0: | ||
if GPIO.input(7) == 0: | ||
GPIO.output(31,1) | ||
time.sleep(3) | ||
|
||
camera.start_preview() | ||
sleep(3) | ||
camera.capture('./image.jpg') | ||
camera.stop_preview() | ||
|
||
print('immagine fatta') | ||
sleep(3) | ||
|
||
print('invio immagine') | ||
send(ip,dev) | ||
print('immagine inviata') | ||
GPIO.output(31,0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import requests | ||
|
||
|
||
def send(ip, dev): | ||
url = 'http://'+str(ip)+'/sendImage' | ||
files = {'image': open('image.jpg', 'rb'), 'device': dev} | ||
requests.post(url, files=files) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# only run if there's no current wifi connection | ||
sudo wpa_supplicant -Dnl80211 -iwlan0 -C/var/run/wpa_supplicant/ -c/etc/wpa_supplicant/wpa_supplicant.conf -dd | ||
ssid_name='NOT_A_NETOWORK' | ||
while ! cat /etc/wpa_supplicant/wpa_supplicant.conf | grep -q "$ssid_name"; do | ||
# grab AP's that support WPS, sort by strength and select the strongest | ||
sleep 3s | ||
wpa_cli scan | wpa_cli scan_results | grep WPS | sort -r -k3 | awk 'END{print $1}' >/tmp/wifi | ||
read ssid < /tmp/wifi | ||
wpa_cli wps_pbc $ssid | ||
wpa_cli scan | wpa_cli scan_results | grep WPS | sort -r -k3 | awk 'END{print $NF}' >/tmp/wifi_name | ||
read ssid_name < /tmp/wifi_name | ||
sleep 3s | ||
done | ||
rm /tmp/wifi | ||
rm /tmp/wifi_name | ||
wpa_cli -i wlan0 reconfigure | ||
sleep 3s | ||
python /home/pi/camera.py 192.168.43.99:8000 $DEV_NAME & |