Installing uasyncio

As you may recall from earlier chapters, uasyncio is a cooperative scheduling module that is very useful for creating concurrent tasks. By default, the MicroPython port for the ESP32 does not have the uasyncio library built into the MicroPython kernel. It's up to us to install it ourselves.

Now, there are several ways that we can go about installing it, which are documented at https://github.com/peterhinch/micropython-async/blob/master/TUTORIAL.md. I highly recommend that you review the tutorial there. In case you are in a hurry, I'll provide the basic steps on how to install uasyncio on the ESP32 here:

  1. Download uasyncio from https://github.com/micropython/micropython-lib. You can do this by either downloading the .zip file or by cloning the repository using the following command:
git clone https://github.com/micropython/micropython-lib.git
  1. Navigate to the folder that you are working out of in Anaconda and create a directory named uasyncio.
  2. Within the micropython-lib download, copy the following files to the new usyncio folder:
  • uasyncio/uasyncio/__init__.py
  • uasyncio.core/uasyncio/core.py
  • uasyncio.synchro/uasyncio/synchro.py
  • asyncio.queues/uasyncio/queues.py
  1. In the Anaconda prompt, issue the following command to install the uasyncio directory:
ampy --port COM3 --baud 115200 put asyncio

The preceding command will copy the asyncio directory and all of its contents to the ESP32.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.141