Search found 5956 matches

by pythoncoder
Tue Aug 16, 2022 8:39 am
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 566507

Re: Pico W Micro Python MQTT of data to a RP4B

The msg parameter for publish should be a bytes object:

Code: Select all

msg = f"{tpm7},{tpm8},{tpm9}".encode()
client.publish(topic_pub, msg)
This will send the values separated by commas, as per

Code: Select all

>>> a = 101
>>> b = 77
>>> c = 88
>>> f"{a},{b},{c}".encode()
b'101,77,88'
by pythoncoder
Mon Aug 15, 2022 7:36 am
Forum: Pyboard D-series
Topic: CAN bus heartbeat receive using asyncio is slow
Replies: 5
Views: 23689

Re: CAN bus heartbeat receive using asyncio is slow

To provide a general answer to this question, say you have an asynchronous function foo that calls a synchronous function bar . The function bar might call other synchronous functions. The scheduler will be blocked for the duration while bar runs. This can be measured as follows: from time import ti...
by pythoncoder
Sun Aug 14, 2022 8:28 am
Forum: Raspberry Pi microcontroller boards
Topic: Memory allocation error with nanogui and Waveshare 2.8 Pico Res
Replies: 1
Views: 2076

Re: Memory allocation error with nanogui and Waveshare 2.8 Pico Res

I assume you're using the ws_pico_res_touch.py setup, renamed to color_setup.py on the target. I have just run the color15.py test and it runs to completion. I modified it to display free RAM after each test and in each case it reported > 100KiB free. So I'm baffled how we can run the same test on t...
by pythoncoder
Sun Aug 14, 2022 7:44 am
Forum: General Discussion and Questions
Topic: Using mqtt_as on ESP vs PicoW?
Replies: 3
Views: 2755

Re: Using mqtt_as on ESP vs PicoW?

Please see the docs re use on ESP8266. I have not tested on ESP8266 versions with < 4MiB of Flash: it is possible that it is not usable on the 1MiB versions.

It is much easier to use platforms with more RAM such as a Pico W, ESP32 or Pyboard D.
by pythoncoder
Sat Aug 13, 2022 8:37 am
Forum: General Discussion and Questions
Topic: Maximum timeout period for uasyncio.sleep()?
Replies: 4
Views: 21372

Re: Maximum timeout period for uasyncio.sleep()?

The code for uasyncio.sleep multiplies by 1000 and calls uasyncio.sleep_ms , with uasyncio using ticks_add and ticks_diff for timing. These will wrap round, with the exact modulo dependent on platform but typically 149 hours (less than a week). The answer is simply to await (say) a day in a loop. In...
by pythoncoder
Fri Aug 12, 2022 8:57 am
Forum: Programs, Libraries and Tools
Topic: __init__confusion
Replies: 1
Views: 2491

Re: __init__confusion

These are really basic questions on the Python language. I suggest you do an online course in Python on your PC to learn basic syntax before venturing into MicroPython on microcontrollers.
by pythoncoder
Fri Aug 12, 2022 8:26 am
Forum: Pyboard D-series
Topic: CAN bus heartbeat receive using asyncio is slow
Replies: 5
Views: 23689

Re: CAN bus heartbeat receive using asyncio is slow

Your comments on uasyncio scheduling are correct. It is a classic problem with asynchronous systems: figuring out where the CPU time is being used. You can use timestamps but you soon get bogged down in reams of data. You really can't beat a logic analyser for doing this kind of work. You can get ve...
by pythoncoder
Thu Aug 11, 2022 10:32 am
Forum: Pyboard D-series
Topic: CAN bus heartbeat receive using asyncio is slow
Replies: 5
Views: 23689

Re: CAN bus heartbeat receive using asyncio is slow

It's hard to answer these kind of queries without a detailed trawl through the code, and even then it can be difficult. If you have access to a logic analyser you might want to consider micropython-monitpr which uses a Raspberry Pico to monitor asynchronous systems in real time. It is specifically d...