From 745315020ba1ac560007f6ae422cf9552f0cda63 Mon Sep 17 00:00:00 2001 From: tkl Date: Sat, 24 Dec 2016 13:15:42 +0100 Subject: [PATCH] light sensor data mqtt transmitter script --- src/light.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/light.py diff --git a/src/light.py b/src/light.py new file mode 100644 index 0000000..9e27d89 --- /dev/null +++ b/src/light.py @@ -0,0 +1,20 @@ +''' +Created on Dec 24, 2016 + +@author: tkl +''' +import sys +from time import time +import paho.mqtt.client as mqtt +from light_sensor.light_sensor import light_sensor + +def main(): + client = mqtt.Client() + client.connect("192.168.178.37", 1883, 60) + client.loop_start() + light = light_sensor(1, 0x23) + client.publish("chickenhouse/sensors/light", str(int(time())) + " " + \ + str(light.read()) + " lx") + +if __name__ == "__main__": + sys.exit(main())