The Tree MQTT service program provides an MQTT interface for controlling our tree's APA102 LED strip and servo by publishing MQTT messages to MQTT topics. You can find the Tree MQTT service program in the chapter14/tree_mqtt_service folder, and it contains the following files:
- README.md: A full list of MQTT topics and message formats for controlling your IoTree.
- main.py: This is the program's main entry point.
- config.py: Program configuration.
- apa102.py: This is an exact copy of the chapter14/tree_api_service/apa102.py. file
- servo.py: This is an exact copy of the chapter14/tree_api_service/servo.py file.
- mqtt_listener_client.py: This is a class that connects to an MQTT broker and subscribes to a topic that will receive messages to control the APA102 and servo. When MQTT messages are received, they are turned into a PubSub message and published using the PyPubSub library, which we discussed...