Initial commit

master
Ian Mancini 5 years ago
commit 6a6df5cb89

@ -0,0 +1,14 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
picamera = "*"
gpiozero = "*"
[requires]
python_version = "3.8"

79
Pipfile.lock generated

@ -0,0 +1,79 @@
{
"_meta": {
"hash": {
"sha256": "f3d3cd97be07a1db357fe38ddf60c7adb2bed644eb15c1fc939a776ffd97cf11"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"certifi": {
"hashes": [
"sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
"sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
],
"version": "==2019.11.28"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"colorzero": {
"hashes": [
"sha256:acba47119b5d8555680d3cda9afe6ccc5481385ccc3c00084dd973f7aa184599",
"sha256:e3c36d15b293de2b2f77ff54a5bd243fffac941ed0a5332d0697a6612a26a0a3"
],
"version": "==1.1"
},
"gpiozero": {
"hashes": [
"sha256:101044038e71cec8be2fa841d4cea9e50e7962e9fb0287f465298b59e3f06594",
"sha256:ae1a8dc4e6e793ffd8f900968f3290d218052c46347fa0c0503c65fabe422e4d"
],
"index": "pypi",
"version": "==1.5.1"
},
"idna": {
"hashes": [
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
"sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"
],
"version": "==2.9"
},
"picamera": {
"hashes": [
"sha256:890815aa01e4d855a6a95dd3ad0953b872a6b954982106407df0c5a31a163e50"
],
"index": "pypi",
"version": "==1.13"
},
"requests": {
"hashes": [
"sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee",
"sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"
],
"index": "pypi",
"version": "==2.23.0"
},
"urllib3": {
"hashes": [
"sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc",
"sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
],
"version": "==1.25.8"
}
},
"develop": {}
}

@ -0,0 +1,69 @@
import requests
from gpiozero import Button, LED
from picamera import PiCamera
from time import sleep, strftime
url = 'http://192.168.1.108:3000/upload-photo'
camera = PiCamera()
camera.resolution = (2560, 1920)
greenLed = LED(16)
greenLed.on()
redLed = LED(20)
redLed.off()
button = Button(21)
buttonLastState = False
def errorBlink():
greenLed.off()
redLed.on()
sleep(1)
redLed.off()
sleep(1)
redLed.on()
sleep(1)
redLed.off()
sleep(1)
greenLed.on()
def successBlink():
greenLed.on()
redLed.off()
sleep(1)
greenLed.off()
sleep(1)
greenLed.on()
sleep(1)
greenLed.off()
sleep(1)
greenLed.on()
def takePhotoAndUpload():
time = strftime("%H-%M-%S")
filename = f"{time}.jpg"
camera.capture(filename)
files = {'photo': open(filename, 'rb')}
try :
r = requests.post(url, files=files, timeout=30)
print(r.status_code)
if (r.status_code == 200):
errorSuccess()
else:
errorBlink()
except:
errorBlink()
while True:
if(buttonLastState != button.is_pressed):
if button.is_pressed:
buttonLastState = True
takePhotoAndUpload()
else:
buttonLastState = False
Loading…
Cancel
Save