Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MicroPython Cookbook

You're reading from   MicroPython Cookbook Over 110 practical recipes for programming embedded systems and microcontrollers with Python

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781838649951
Length 452 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Marwan Alsabbagh Marwan Alsabbagh
Author Profile Icon Marwan Alsabbagh
Marwan Alsabbagh
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Getting started with MicroPython 2. Controlling LEDs FREE CHAPTER 3. Creating Sound and Music 4. Interacting with Buttons 5. Reading Sensor Data 6. Button Bash Game 7. Fruity Tunes 8. Let's Move It, Move It 9. Coding on the micro:bit 10. Controlling the ESP8266 11. Interacting with the Filesystem 12. Networking 13. Interacting with the Adafruit FeatherWing OLED 14. Building an Internet of Things (IoT) Weather Machine 15. Coding on the Adafruit HalloWing Microcontroller 16. Other Books You May Enjoy

Updating the CircuitPython Library

In addition to updating the firmware, there is also a rich set of Python libraries called the CircuitPython Library that can also be updated with the latest supported features.

Getting ready

Any of themethods used in the previous recipes can be used hereto obtain a REPL.

How to do it...

Let's have a look at how to do this:

  1. Open the REPL through your preferred application.
  2. Download the latest CircuitPython Library Bundle release (https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest). The name of the bundle file is adafruit-circuitpython-bundle-3.x-mpy-20190212.zip. Since our firmware is using the 3.x release, we must select the bundle that is also for the 3.x release. Always use the mpy version, as this is optimized to use less disk space and has reduced memory usage.
We are using the latest auto-release version of the CircuitPython Library Bundle in this recipe, which is version 20190212 of the 3.x series.
  1. Extract the .zip file to a location on your computer.
  2. If the CIRCUITPY drive does not contain a lib folder, then create one now.
  3. Copy the contents of the extracted lib folder into the lib folder on the device.
  4. Perform a soft reboot in the REPL by pressing Ctrl + D.
  5. Run import simpleio in the REPL.
  6. If it has executed successfully, then the libraries have been successfully loaded, as the simpleio module is not part of the firmware and was imported from the library folder.

How it works...

The lib path that was created is one of the standard paths the CircuitPython will look in when importing Python packages. By adding Python packages to this folder, this makes it available for import by any scripts running on the device.

The mpy files are built from the original source py files and bundled all together in one package to make it easier to install.

There's more...

The CircuitPython Library is under constant development, so it's important to know how to update the library on the board so that you can get the latest features. As you experiment with code from projects you find on the internet, you might occasionally find examples that don't work on your board because you are running an outdated version of the CircuitPython Library. Keep your board to the latest version, as this can help prevent this from happening.

See also

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime