diff options
author | Joe Robinson <joe@lc8n.com> | 2019-02-17 21:02:40 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2019-02-17 21:02:40 +0000 |
commit | b06d4a4ce0f81d03c77f81a5efa1fde243a9497f (patch) | |
tree | 0b8fa5a86f967f14d32f47ae7fe1e0a89be1a6ad |
Initial commit
-rw-r--r-- | fruitfly.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fruitfly.py b/fruitfly.py new file mode 100644 index 0000000..bf4a534 --- /dev/null +++ b/fruitfly.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +import sys +import time +import paho.mqtt.client as paho +import Adafruit_DHT + +broker = "192.168.0.59" +client_id = "mercury" +sensor_type = Adafruit_DHT.DHT22 +sensor_pin = 17 + +client = paho.Client(client_id) + +print("connecting to broker " + broker) +client.connect(broker) +client.loop_start() + +while True { + humidity, temperature = Adafruit_DHT.read_retry(sensor_type, sensor_pin) + + client.publish(client_id+"/temperature", temperature) + client.publish(client_id+"/humidity", humidity) + + time.sleep(2) +} |