From 091d24a263571a28aea02f5fb1aa11ec7933f896 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 29 May 2021 14:59:36 +1200 Subject: [PATCH] Renamed to main.py --- uP/mqtt.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 uP/mqtt.py diff --git a/uP/mqtt.py b/uP/mqtt.py deleted file mode 100644 index c76b32b..0000000 --- a/uP/mqtt.py +++ /dev/null @@ -1,37 +0,0 @@ -from machine import Pin -from time import sleep -import machine -import dht -from umqtt.robust import MQTTClient -import json -import gc - -with open("config.json", 'r') as f: - config = json.load(f) - -print(config) - -led = Pin(2, Pin.OUT) -d = dht.DHT11(Pin(12)) -adc = machine.ADC(0) - -c = MQTTClient("umqtt_client", config["mqtt"]["server"],ssl=True, user=config["mqtt"]["user"], password=config["mqtt"]["password"]) -gc.enable() - -while True: - led(0) - d.measure() - data = {'temp': d.temperature(), 'humid': d.humidity(),'light': adc.read(), 'id': config["id"]} - print(data) - led(1) - c.connect() - c.publish(b"sensors", json.dumps(data)) - c.disconnect() - gc.collect() - # wdt.feed() - #sleep(1) - - - - -