from umqtt.simple import MQTTClient # Define the callback function that will be called when a message is received def sub_cb(topic, msg): print((topic, msg)) # Set up the MQTT client client = MQTTClient("client_id", "mqtt_broker_ip") client.set_callback(sub_cb) client.connect() client.subscribe(b"my_topic") # Wait for messages to be received while True: client.check_msg()In this example, the MQTTClient is created with a unique client ID and the IP address of the MQTT broker. A callback function is defined to handle incoming messages. The client connects to the broker and subscribes to a topic called "my_topic". The `while True` loop is used to continuously check for new messages. The umqtt.simple library is a lightweight MQTT client implementation for MicroPython and other resource-constrained environments.