#-------------MQTT vars Device_ID = 'ESP32_02' Alert_msg = 0x400200 # need replacement & over temperature MQTT_Server = 'iot.eclipse.org' MQTT_Server2 = 'test.mosquitto.org' #Topic_ID = 'stsmd/+/+' Data_ava_flag = 0b1000111 import wifiCfg #MQTT lib auto did wifi connections #wifiCfg.screenShow() #wifiCfg.doConnect('TC', 'sthz@2020') #wifiCfg.autoConnect(lcdShow=True) wait(0.1) m5mqtt = M5mqtt(Device_ID, MQTT_Server, 1883, '', '', 300) #m5mqtt = M5mqtt('M5_SMD01', 'test.mosquitto.org', 1883, '', '', 300) wait(0.1) #global control flags Alarm_flag = 0 MQTT_data_send_flag = 0 MQTT_Alert_send_flag = 0 run_cnt = 0 Msg_cnt_R = 0 Msg_cnt_T = 0 kk = [] data_payload = 0x00 Alert_payload = 0x010101 setScreenColor(0x000000) title = M5Title(title=" Smart Device ESP32 MQTT demo V3.4", x=3,
wifiCfg.reconnect() label0.setText('Wifi connected') data = Noneial #rfid init rfid0 = unit.get(unit.RFID, unit.PORTA) uart = None t1 = None t2 = None student_checkag=[] #存人数的列表 #mqtt initial m5mqtt = M5mqtt('random', 'industrial.api.ubidots.com', 1883, 'BBFF-HXOoqxfhftjZSub2lDqbK019M3KHFg', '', 300) #Label and tile set setScreenColor(0x000000) label0 = M5TextBox(69, 33, "Running System", lcd.FONT_Comic,0x89eee1, rotate=0) label1 = M5TextBox(40, 86, "Name :", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label2 = M5TextBox(76, 124, "ID :", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label3 = M5TextBox(40, 165, "Count :", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label4 = M5TextBox(135, 86, "", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label5 = M5TextBox(135, 124, "", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label6 = M5TextBox(135, 165, "", lcd.FONT_DejaVu18,0xff66d2, rotate=0) label7 = M5TextBox(30, 188, "", lcd.FONT_DejaVu18,0xffd400, rotate=0) label10 = M5TextBox(20, 35, "123", lcd.FONT_Default,0xFFFFFF, rotate=0) label10.hide() title10 = M5Title(title="Today runner list:", x=3 , fgcolor=0xFFFFFF, bgcolor=0x0000FF) title10.hide()
#------------------------------script code starts here:------------- gc.collect() IIC_Address_ENV = 0x5C setScreenColor(0x222222) lcd.setBrightness(25) LCD_EN = 20 res_tmp = 0 import wifiCfg #MQTT lib auto did wifi connections #wifiCfg.screenShow() #wifiCfg.doConnect('TC', 'sthz@2020') #wifiCfg.autoConnect(lcdShow=True) wait(0.1) m5mqtt = M5mqtt('M5_SMD01', 'test.mosquitto.org', 1883, '', '', 300) #m5mqtt = M5mqtt('M5_SMD01', 'test.mosquitto.org', 1883, '', '', 300) wait(0.1) #global control flags Alarm_flag = 0 MQTT_data_send_flag = 0 MQTT_Alert_send_flag = 0 run_cnt = 0 Msg_cnt_R = 0 Msg_cnt_T = 0 Alert_payload = 0x010101 setScreenColor(0x000000) title = M5Title(title=" Smart Device ESP32 MQTT demo V3.1", x=3, fgcolor=0xff9900, bgcolor=0x1F1F1F)
def init_mqtt(self): self.m5mqtt = M5mqtt(self.config['core_id'], self.config['broker_ip'], 1883, '', '', 300)
from m5stack import * from m5ui import * from uiflow import * import wifiCfg from m5mqtt import M5mqtt setScreenColor(0x111111) m5mqtt = M5mqtt('m5stick', 'io.adafruit.com', 1883, 'USER_NAME', 'YOUR_ACCESS_KEY', 300) image0 = M5Img(0, 0, "res/humi3.jpg", True) temperature = None humidity = None ticks = None def fun_PATH_TO_TEMPERATURE_FEED_(topic_data): global temperature, humidity, ticks temperature = topic_data pass m5mqtt.subscribe(str('PATH_TO_TEMPERATURE_FEED'), fun_PATH_TO_TEMPERATURE_FEED_) def fun_PATH_TO_HUMIDITY_FEED_(topic_data): global temperature, humidity, ticks humidity = topic_data
#-------------MQTT vars Device_ID = 'ESP32_02' Alert_msg=0x800200 # need replacement & over temperature MQTT_Server = 'iot.eclipse.org' Topic_ID = 'stsmd/+/+' Data_ava_flag= 0b10000111 import wifiCfg #MQTT lib auto did wifi connections #wifiCfg.screenShow() #wifiCfg.doConnect('TC', 'sthz@2020') #wifiCfg.autoConnect(lcdShow=True) wait(0.1) m5mqtt = M5mqtt('M5_SMD01', MQTT_Server, 1883, '', '', 300) #m5mqtt = M5mqtt('M5_SMD01', 'test.mosquitto.org', 1883, '', '', 300) wait(0.1) #global control flags Alarm_flag = 0 MQTT_data_send_flag = 0 MQTT_Alert_send_flag = 0 run_cnt = 0 Msg_cnt_R =0 Msg_cnt_T =0 kk=[] data_payload= 0x00 Alert_payload= 0x010101 setScreenColor(0x000000) title = M5Title(title=" Smart Device ESP32 MQTT demo V3.4", x=3 , fgcolor=0xff9900, bgcolor=0x1F1F1F) label_info = M5TextBox(15, 30, "<-->"+MQTT_Server+":1883 as "+Device_ID, lcd.FONT_Default,0xDDDDDD, rotate=0)
# Xmas Fever control # ver 1.0 #by gian luigi perrella from m5stack import * from m5ui import * from uiflow import * from m5mqtt import M5mqtt import wifiCfg import time import unit #initialize string to publish body temp a = None # Using HIVEMQ mqtt broker, point your browser at http://www.hivemq.com/demos/websocket-client/ # and fill the field ADD NEW TOPIC SUBSCRIPTION with the topic m5s/fever m5mqtt = M5mqtt('m5Fever', 'broker.mqttdashboard.com', 1883, '', '', 300) lcd.clear() setScreenColor(0x111111) image1 = M5Img(0, 0, "res/xmas_party.jpg", True) label6 = M5TextBox(30, 10, "XMas Fever control", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0) wait_ms(10000) label6 = M5TextBox(30, 10, "XMas Fever control",
#------------------------------script code starts here:------------- gc.collect() IIC_Address_ENV = 0x5C setScreenColor(0x222222) lcd.setBrightness(25) LCD_EN = 20 res_tmp = 0 import wifiCfg #MQTT lib auto did wifi connections #wifiCfg.screenShow() #wifiCfg.doConnect('TC', 'sthz@2020') #wifiCfg.autoConnect(lcdShow=True) wait(0.1) m5mqtt = M5mqtt('M5_SMD01', 'iot.eclipse.org', 1883, '', '', 300) #m5mqtt = M5mqtt('M5_SMD01', 'test.mosquitto.org', 1883, '', '', 300) wait(0.1) #global control flags MQTT_Server = 'iot.eclipse.org' Topic_ID = 'stsmd/+/+' Alarm_flag = 0 MQTT_data_send_flag = 0 MQTT_Alert_send_flag = 0 run_cnt = 0 Msg_cnt_R =0 Msg_cnt_T =0 Alert_payload= 0x010101 setScreenColor(0x000000) title = M5Title(title=" Smart Device ESP32 MQTT demo V3.1", x=3 , fgcolor=0xff9900, bgcolor=0x1F1F1F) label_info = M5TextBox(15, 30, "<-->"+MQTT_Server+":1883 as M5_SMD01", lcd.FONT_Default,0xDDDDDD, rotate=0)
import ujson from m5stack import * from m5ui import * import wifiCfg from m5mqtt import M5mqtt fichier = open('config.json') config = ujson.load(fichier) if not wifiCfg.is_connected(): lcd.text(10, 10, 'connection au wifi') wifiCfg.doConnect(config['ssid'], config['passwd']) def callback(topic_donnees): print((topic_donnees)) m5qtt = M5mqtt("M5stack", "test.mosquitto.org", 1883) m5qtt.("tuto_topic", callback) m5qtt.start() while True: pass
waiting = True timerSch.run('wait', 1000, 0x00) neopixel_0.setBrightness(intensity) pass @timerSch.event('wait') def twait(): global waitSeconds, fade, color, intensity, waiting, waitShorterTime, waitLongTime, i waitSeconds = (waitSeconds if isinstance(waitSeconds, Number) else 0) + -1 if waitSeconds == 0: waiting = False pass m5mqtt = M5mqtt('', 'mwtt.nextservices.dk', 0, '', '', 300, ssl=True) m5mqtt.subscribe(str('K2Light'), fun_K2Light_) m5mqtt.subscribe(str('stick-1001'), fun_stick_1001_) m5mqtt.start() color = [255, 255, 255] fade = False intensity = 0 waitLongTime = 600 waitShorterTime = 100 waiting = False timerSch.run('fade', 124, 0x00) while True: for i in range(11, 85): neopixel_0.setColorFrom(11, 84, (color[-1] << 16) | (color[0] << 8) | color[1]) neopixel_0.setColor(i, 0x000000)