The Pico In MicroPython: Asyncio Client |
Written by Mike James & Harry Fairhead | ||||
Wednesday, 30 July 2025 | ||||
Page 1 of 3 Implementing a web client is a basic task for anyone wanting to make use of the internet and the best way to do it is to use asyncio. This is an extract from our book all about the Raspberry Pi Pico 2/2W in MicroPython. Programming the Raspberry Pi Pico/W In MicroPython Third EditionBy Harry Fairhead & Mike JamesBuy from Amazon. Contents
Also of interest: **** articles from the second edition not yet updated. <ASIN:B0BR8LWYMZ> <ASIN:B0BL1HS3QD> MicroPython has a basic implementation of the Python asyncio module. The asyncio module is very useful in providing asynchronous programming in Python and you might think that it would be exceptionally useful in low-level hardware applications as an alternative to polling or event driven approaches. In fact it isn’t quite as useful as you might expect as there are few existing asynchronous subsystems. In full Python we have a complete filing system and network connections and this means that asynchronous programming can improve efficiency by putting the processor to work while waiting for I/O operations to complete. As the Pico doesn’t have either an operating system or a filing system, there isn’t much opportunity to make use of idle processor time. However, now that the Pico has a network connection via WiFi the asyncio module is suddenly much more useful. In this chapter we first look at the basic idea of asynchronous programming as implemented by uasyncio, the MicroPython version of asyncio, and then at how to use it to implement a server asynchronously. If you want to know more about asynchronous programming in general and asyncio in particular see Programmer’s Python: Async, ISBN:9781871962765. In chapter but not in this extract
|
||||
Last Updated ( Wednesday, 30 July 2025 ) |