No internet connection
  1. Home
  2. General

Comments for https://wellys.com/posts/rp2040_micropython_debugging/

By System @system
    2025-09-26 20:31:53.296Z
    • 1 comments
    1. D
      Dave Harper @DaveHarper
        2025-09-26 20:31:53.527Z

        I have recently developed a helpful solution for debugging a project I'm working on (a whole-house audio system that has 18 zones with each zone having 6 separate source inputs) and thought I'd share it with anyone interested. I'm using Raspberry Pi boards to implement the main section of the system with the 18 remote keypads, one in each audio zone, being implemented using a Pico W board, providing wireless connectivity. For the communications protocol between the main system and each of the keypads I'm using MQTT (with the Pico W implementation using the excellent micropython mqtt_as.py package by Peter Hinch). I needed a way to collect debugging information from each of the components and, obviously, hooking up something like Thonny to all parts of the system was out of the question. The solution for me turned out to be installing Mosquitto on my main development computer which provided me with the program called mosquitto_sub which monitors MQTT communication for specific or all MQTT topics and can print out the messages being sent in a terminal window or can redirect them to a log file. With this approach I can see all messages being sent in real time which may include all messages or only messages with a topic of "debug" (subscribed to only by my main development system) where the message can include the source sending the message and perhaps the destination sending a debug message that it got it and was performing a specific action. This has allowed me to have a complete overview of all interactions going on in the system and, while not as ideal as setting breakpoints or being able to single-step through a program, it is making the debugging process much easier by allowing me to see what each part of the system is doing at any given time (as all entries are timestamped).

        Dave