Reader small image

You're reading from  MicroPython Projects

Product typeBook
Published inApr 2020
Reading LevelExpert
PublisherPackt
ISBN-139781789958034
Edition1st Edition
Languages
Right arrow
Author (1)
Jacob Beningo
Jacob Beningo
author image
Jacob Beningo

Jacob Beningo is an independent consultant who specializes in microcontroller-based embedded systems. He has advised, coached, and developed systems across multiple industries, including the automotive, defense, industrial, medical, and space sectors. Jacob enjoys working with companies to help them develop and improve their processes and skill sets. He publishes a monthly newsletter, Embedded Bytes, and blogs for publications about embedded system design techniques and challenges. Jacob holds bachelor's degrees in electrical engineering, physics, and mathematics from Central Michigan University and a master's degree in space systems engineering from the University of Michigan.
Read more about Jacob Beningo

Right arrow

Down the Rabbit Hole with MicroPython

The C programming language has dominated the embedded systems industry for half a century! C has been extraordinarily successful, but it is no longer meeting the needs of embedded software developers. In this chapter, we will begin to explore the programming language landscape for embedded systems and how Python, particularly MicroPython, is quickly becoming a good fit for a wide range of applications.

The following topics will be covered in this chapter:

  • The embedded software language menagerie
  • The case for MicroPython
  • Use cases for MicroPython
  • Evaluating whether MicroPython is right for you
  • Selecting the right development platform
  • MicroPython development processes and strategies
  • Useful resources

The embedded software language menagerie

In the history of the embedded software industries, for the most part, developers writing software for microcontroller-based systems have had very few software languages to choose from. At the dawn of the computer age, developers were stuck using low-level assembly language that forced them to learn the instruction set for each microcontroller device that they used. While highly effective and efficient, reading, maintaining, or even understanding assembly language was quite difficult and cumbersome.

Between 1969 and 1973, Dennis Ritchie developed the C programming language while working at Bell Labs and forever changed the way that software was developed. The C programming language caught on, and while general-purpose computing systems have moved on to other object-oriented languages, C has been the dominant language to use with microcontrollers...

The case for MicroPython

As developers have started to look for alternative programming languages, the opportunity for Python to become a popular embedded language has dramatically risen. Python has several characteristics that make it an interesting choice for an embedded language. These include, but certainly aren't limited to, the following:

  • It is taught at many universities around the world.
  • It is easy to learn (I've seen elementary students write Python code).
  • It is object-oriented.
  • It is an interpreted scripting language that removes compilation.
  • It is supported by a robust community, including many add-on libraries that minimize reinventing the wheel.
  • It includes error handling (something that C didn't get the memo on).
  • It is easily extensible.

Python has actually become the go-to language for developers working on popular application processors such...

Evaluating whether MicroPython is right for you

So far, we have discussed several use cases for MicroPython and when using it could be a big problem. Even if a project we are working on falls within the sanctioned use cases, MicroPython may still not be the best fit. Just like with any project, we need to objectively evaluate whether MicroPython is the right language to use. Let's examine how we can evaluate whether MicroPython is right for us.

There are several steps that can be followed to evaluate whether a programming language meets the needs of a development team or developer:

  1. Identify the key language features needed
  2. Evaluate the team's programming skills
  3. Ascertain the business results the language might achieve

Let's discuss each of these in more detail.

First, it's important to identify the language features that are needed and will be utilized by...

Selecting the right development platform

There are quite a few options available to developers who are interested in working with MicroPython. To date, MicroPython has been ported to approximately a dozen different microcontroller architectures. Each architecture then supports a range of development boards, putting the options for developers at nearly 50 different development boards. With so many different options, it can be a bit challenging to decide which one makes the most sense for your project.

While there are many different ways to go about selecting a development platform, we are going to walk through a simple process that includes this:

  1. Surveying the available architectures
  2. Identifying boards of interests within those architectures
  3. Creating a Kepner-Tregoe (KT) matrix to objectively evaluate the best board for the application

This simple process will ensure that you...

MicroPython development processes and strategies

Developing embedded software using MicroPython can be quite a bit different than developing software using C/C++; however, at the same time, there are many tried and true development techniques and processes that still carry through. For example, when developing a MicroPython application, the software development life cycle doesn't change just because a different programming language is being used.

The Software Development Life Cycle, which is sometimes referred to as SDLC, defines best practices that developers should follow when developing software. These processes are usually grouped into five main categories:

  1. Requirements
  2. Design
  3. Implementation
  4. Testing
  5. Maintenance

There are two really good resources that you can review, which provide a great overview of how software should be developed. It can be found and downloaded for...

Useful development resources

There are several resources that you will want to make sure that you have on hand to develop your MicroPython-based projects. In many instances, these are the same tools that you would want to have whether you are a hobbyist or a professional developer. At a minimum, I would recommend that you purchase or download the following:

I would highly recommend that you also pick-up a logic analyzer such as an 8-channel Saleae Logic. I've also found that using an SPI/I2C bus tool such as a Total Phase Aardvark can be a...

Summary

Python has taken the software world by storm due to its elegant simplicity, ease to learn, but also its ability to easily scale and adapt to changing industry conditions. Python has found its way into the resource-constrained environment of microcontroller applications through MicroPython. In the rest of this book, we will explore how we can learn and leverage MicroPython for DIY and product development projects through several hands-on projects.

The projects in this book vary in terms of the skill level required to complete and understand them. Whether you are new to programming or a skilled professional, I will walk you through the design process that's required to complete projects successfully. In order to make sure that no reader is left behind, I will periodically point out useful resources to get up to speed on topics that might otherwise be outside the scope...

Questions

    1. What Python features make it a competing choice for use in embedded systems?
    2. What three use cases does MicroPython match well with?
    3. What business ramifications should be evaluated for using MicroPython?
    4. What microcontroller architecture is supported the most by MicroPython?
    5. What decision-making tool can be used to remove human bias?
    6. What five categories make up the SDLC?
    7. What key combination in the REPL will produce a soft reset?
    8. What workbench resources do you need to develop a MicroPython project? Are you currently missing any?

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
MicroPython Projects
Published in: Apr 2020Publisher: PacktISBN-13: 9781789958034
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Jacob Beningo

Jacob Beningo is an independent consultant who specializes in microcontroller-based embedded systems. He has advised, coached, and developed systems across multiple industries, including the automotive, defense, industrial, medical, and space sectors. Jacob enjoys working with companies to help them develop and improve their processes and skill sets. He publishes a monthly newsletter, Embedded Bytes, and blogs for publications about embedded system design techniques and challenges. Jacob holds bachelor's degrees in electrical engineering, physics, and mathematics from Central Michigan University and a master's degree in space systems engineering from the University of Michigan.
Read more about Jacob Beningo