Skip to content

Commit

Permalink
last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mellifluo committed May 27, 2018
1 parent 8e4d634 commit 0c7fc10
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
Binary file added Documents/FridgePi.pdf
Binary file not shown.
Binary file added Documents/FridgePi.pptx
Binary file not shown.
Binary file added Documents/MCPS-poster.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documents/MCPS-poster.pdf
Binary file not shown.
39 changes: 39 additions & 0 deletions PiCode/camera.py
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)

14 changes: 14 additions & 0 deletions PiCode/sendimages.py
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)






19 changes: 19 additions & 0 deletions PiCode/wps.sh
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 &

0 comments on commit 0c7fc10

Please sign in to comment.