Commit 6faeba73 authored by Daniel Kolibár's avatar Daniel Kolibár
Browse files

updated code

parent b4baa375
......@@ -11,19 +11,19 @@ def on_connect(client, userdata, flags, rc):
else:
print(f"Connecting to MQTT broker failed with code {rc}")
def on_message(client, userdata, msg):
#print(f"{msg.topic} {msg.payload}")
def on_message(client, userdata, msg):
if str(msg.payload.decode("utf-8")) == 'TAKE_PHOTO':
print('taking photo!')
photo = open('/tmp/photo.jpg', 'wb')
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.start_preview()
photo = io.BytesIO()
with picamera.PiCamera() as camera:
camera.resolution = (320, 200)
camera.start_preview()
time.sleep(2)
camera.capture(photo)
photo.close()
camera.capture(photo, 'jpeg')
print('took photo!')
print(photo.read())
base64_bytes = base64.b64encode(my_stream.getvalue())
base64_message = base64_bytes.decode('ascii')
client.publish('birdie/rxtxfile', payload=base64_message, qos=0, retain=False)
client = mqtt.Client()
client.on_connect = on_connect
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment