0

I am building a clock using rpi pico, max7219 and wiznet5k.

I am trying to incorporate mqtt functionality, in order to show important short messages to the max7219 every now and then.

I have run into some difficulties with the mqtt_client.loop() command meaning that as the pico is working-showing time most of the time- it is not available to collect feeds from the mqtt server. But also I get randomly errors like:

Traceback (most recent call last):
  File "code.py", line 334, in <module>
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 805, in loop
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 854, in _wait_for_msg
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 906, in _sock_exact_recv
MemoryError: memory allocation failed, allocating 4294967294 bytes

or:

MMQTTException PINGRESP not returned from broker.

Every 5 or 10 minutes there is an "intermission" of 5-10 seconds, when showing date and day of the week, and that is where I have placed the mqtt_client.loop() but if there is no message during this period I don't see any and I loose the rest.

Another idea could be to utilize (?) the second core to collect messages in the background. But circuitpython I think is not utilizing the multicore functionality of pico right now. Any ideas or comments? Thanks a lot!

4
  • what is your specific question?
    – jsotola
    Commented May 24, 2022 at 20:56
  • @jsotola how to receive mqtt feeds reliably while showing time on pico
    – thermike
    Commented May 25, 2022 at 14:33
  • I think that there is no solution with the setup I have described. At least for the time being. I will try some other mcu solution and cpp.
    – thermike
    Commented Jun 1, 2022 at 10:13
  • We used to use single-processor chips for multiple activities all the time. I would use a busy loop and use a timer for the clock display. If you look at embedded systems books several years old, they should explain how to do this.
    – NomadMaker
    Commented Jul 3, 2022 at 19:41

1 Answer 1

0

I agree that you may wish to use the second core. I do this with a GPS receiver hooked to one of the UARTs, and radio hooked to another UART. core0 runs the radio loop and core1 runs the GPS evaluation loop. They play very nicely with one another.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.