@seb Hi sorry seb, because the upper part is only wifi configuration so i didnt show it. Here is the whole main.py from network import WLAN from mqtt import MQTTClient import machine import time import pycom #from machine import Pin #pin=Pin('P10',mode=Pin.IN, pull=Pin.PULL_UP) wlan = WLAN(mode=WLAN.STA) wlan.antenna(WLAN.EXT_ANT) wlan.connect("xxx", auth=(WLAN.WPA2, "xxx"), timeout=5000) while not wlan.isconnected(): machine.idle() print("Connected to Wifi\n") def settimeout(duration): pass def sub_cb(topic, msg): print(msg) client = MQTTClient(client_id="xxx", server="io.adafruit.com",user="vickyho", password="xxx", port=1883) client.settimeout=settimeout client.set_callback(sub_cb) client.connect() print("connected to broker\n") client.publish(topic="vickyho/feeds/lights",msg="False") print("Published!") time.sleep(10) client.subscribe(topic="vickyho/feeds/lights") print("Subscribed!") while True: client.check_msg() if client.subscribe(topic="vickyho/feeds/digital",msg="ON") pycom.rgbled(0xff00) print("Led ON") time.sleep(3) if client.subscribe(topic="vickyho/feeds/digital",msg="OFF") pycom.heartbeat(False) pycom.rgbled(0x0000) print("Led OFF") time.sleep(3) thanks for your reply btw!