light sensor data mqtt transmitter script
This commit is contained in:
parent
a07d62de10
commit
745315020b
20
src/light.py
Normal file
20
src/light.py
Normal file
@ -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())
|
Loading…
Reference in New Issue
Block a user