Created
July 10, 2018 05:50
-
-
Save yodakohl/d0c4025b5f91aa215ab99910a4dec45f to your computer and use it in GitHub Desktop.
Octolapse timelapse with a Nikon D3300 triggered by MQTT messages via USB
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import paho.mqtt.client as mqtt | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code " + str(rc)) | |
client.subscribe("octoprint/#") | |
def on_message(client, userdata, msg): | |
print(msg.topic + " " + str(msg.payload)) | |
if (msg.topic == "octoprint/event/PositionUpdate"): | |
print("Taking image") | |
os.system("gphoto2 --camera 'Nikon DSC D3300' --capture-image-and-download --filename '%Y%m%d%H%M%S.jpg'") | |
print("Image Taken") | |
client = mqtt.Client() | |
client.on_connect = on_connect | |
client.on_message = on_message | |
client.connect("localhost", 1883, 60) | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment