Summary
Learning to program can be a frustrating process, because even the simplest code relies on a complex stack of other moving pieces to function. When working with a microcontroller you are in full control of everything so there are fewer concepts that need to be understood in order to build a functioning project. CircuitPython is a platform for beginner developers that provides easy to use abstractions for working with hardware devices. In this episode Scott Shawcroft explains how the project got started, how it relates to MicroPython, some of the cool ways that it is being used, and how you can get started with it today. If you are interested in playing with low cost devices without having to learn and use C then give this a listen and start tinkering!
Announcements
- Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
- When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With 200 Gbit/s private networking, scalable shared block storage, node balancers, and a 40 Gbit/s public network, all controlled by a brand new API you’ve got everything you need to scale up. And for your tasks that need fast computation, such as training machine learning models, they just launched dedicated CPU instances. Go to pythonpodcast.com/linode to get a $20 credit and launch a new server in under a minute. And don’t forget to thank them for their continued support of this show!
- You listen to this show to learn and stay up to date with the ways that Python is being used, including the latest in machine learning and data analysis. For even more opportunities to meet, listen, and learn from your peers you don’t want to miss out on this year’s conference season. We have partnered with organizations such as O’Reilly Media, Dataversity, and the Open Data Science Conference. Go to pythonpodcast.com/conferences to learn more and take advantage of our partner discounts when you register.
- Visit the site to subscribe to the show, sign up for the newsletter, and read the show notes. And if you have any questions, comments, or suggestions I would love to hear them. You can reach me on Twitter at @Podcast__init__ or email hosts@podcastinit.com)
- To help other people find the show please leave a review on iTunes and tell your friends and co-workers
- Join the community in the new Zulip chat workspace at pythonpodcast.com/chat
- Your host as usual is Tobias Macey and today I’m interviewing Scott Shawcroft about CircuitPython, the easiest way to program microcontrollers
Interview
- Introductions
- How did you get introduced to Python?
- Can you start by explaining what CircuitPython is and how the project got started?
- I understand that you work at Adafruit and I know that a number of their products support CircuitPython. What other runtimes do you support?
- Microcontrollers have typically been the domain of C because of the resource and performance constraints. What are the benefits of using Python to program hardware devices?
- With the wide availability of powerful computing platforms, what are the benefits of experimenting with microcontrollers and their peripherals?
- I understand that CircuitPython is a friendly fork of MicroPython. What have you changed in your version?
- How do you structure your development to avoid conflicts with the upstream project?
- What are some changes that you have contributed back to MicroPython?
- What are some of the features of CircuitPython that make it easier for users to interact with sensors, motors, etc.?
- CircuitPython provides an easy on-ramp for experimenting with hardware projects. Is there a point where a user will outgrow it and need to move to a different language or framework?
- What are some of the most interesting/innovative/unexpected projects that you have seen people build using CircuitPython?
- Are there any cases of someone building and shipping a production grade project in CircuitPython?
- What have been some of the most interesting/challenging/unexpected aspects of building and maintaining CircuitPython?
- What is in store for the future of the project?
Keep In Touch
Picks
- Tobias
- Wings Of Fire book series
- Scott
Links
- Adafruit
- CircuitPython
- MicroPython
- Microcontroller
- Arduino
- Microsoft MakeCode
- NodeBots
- Espruino
- I2C
- Hackspace Magazine
- Adafruit Blinka
- learn.adafruit.com
- Scott Hanselman Blog Post
- Reflow Oven
- Adafruit Crickit – Creative Robotics Platform
- Adabox
- Moore’s Law
- SparkFun
- DigiKey
The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA
Hello, and welcome to Podcast Dot in It, the podcast about Python and the people who make it great. When you're ready to launch your next app or want to try a project you hear about on the show, you'll need somewhere to deploy it. So take a look at our friends over at Linode. With 200 gigabit private networking, scalable shared block storage, node balancers, and a 40 gigabit public network, all controlled by a brand new API, you get everything you need to scale up. And for your tasks that need fast computation, such as training machine learning models or building your CI pipeline, they just launched dedicated CPU instances. Go to python podcast.com/linode.
That's l I n o d e, today to get a $20 credit and launch a new server in under a minute. And don't forget to thank them for their continued support of this show. And you listen to this show to learn and stay up to date with the ways that Python is being used, including the latest in machine learning and data analysis. For even more opportunities to meet, listen, and learn from your peers, you don't want to miss out on this year's conference season. We have partnered with organizations such as O'Reilly Media, Dataversity, and the Open Data Science Conference. Go to python podcast.com/conferences to learn more and take advantage of our partner discounts when you register.
And visit the site at python podcast.com to subscribe to the show, sign up for the newsletter, and read the show notes. And to help other people find the show, please leave a review on Itunes and tell your friends and coworkers. Your host as usual is Tobias Macy. And today, I'm interviewing Scott Shawcroft about circuit Python, the easiest way to program microcontrollers.
[00:01:44] Unknown:
So, Scott, could you start by introducing yourself? Yeah. I'm Scott as you said, and I go by Tan Newt online if you ever see me, on the web. I've worked at Google before. I went I went to the University of Washington, and now I work for Adafruit full time on circuit Python.
[00:02:01] Unknown:
And do you remember how you first got introduced to Python?
[00:02:03] Unknown:
Oh, yeah. I was thinking back. It was definitely, like, 2, 004. So my first programming language was PHP, and that was because I was doing, HTML and website stuff. It was, like, kind of even like, 2, 002 was pre, like, JavaScript and CSS popularity. So, like, if you wanted a dynamic website, PHP was a thing. So I did that for a while. I learned, like, what an if statement it was. I learned recursion that way. And then I finally got to the point where I wanted to make a desktop app. And I went to the store and because I had learned PHP from a book. And I I remember being in the store with a Perl book and a Python book and, like, just ended up picking the Python 1 for some reason and, never looked back from that.
[00:02:52] Unknown:
Good choice in retrospect. Yeah. For sure. For sure. Particularly considering the sort of fates of Perl in comparison to Python, where Perl has gone on a steady decline in terms of popularity and usage. I mean, it's still a useful language, and people are still, you know, making valuable software out of it. But Python is definitely on a steeper incline up as far as the, range of uses that it's being applied to. Yeah. For sure. And I don't even
[00:03:19] Unknown:
really remember why I picked 1 over the other, but I definitely, like, Python has served to me well since then. And so,
[00:03:27] Unknown:
on that path, you have started the circuit Python project. So I'm wondering if you could just start by explaining a bit about what it is and how it got started.
[00:03:35] Unknown:
Yeah. So first and foremost, circuit Python is a reimplementation of Python that's designed to run on microcontrollers, and microcontrollers are, like, super basic, low power, low cost computers. Like, when I say low cost, I mean, like, a dollar. Like, they're little itty bitty chips, and they've got, like, 32 k RAM or 256 k RAM. So, like, much less RAM and much slower than you would typically expect a a computer to be. Whereas, like, our our slowest 1 is 48 megahertz. So it's it's very different from what you have in your phone or on your laptop, but it's still can run Python. So that's at the very high level what circuit Python is.
The way the project got started was Adafruit had been looking at MicroPython, which, CircuitPython is based on. And we can talk about MicroPython's history if you like to. But I had been working at Google in the cloud, and I left and I was because I wasn't enjoying it anymore. And so I did my own thing and I was doing flight controller, microcontroller stuff. And then I went to Adafruit and I had been on their show and tell a bunch and I I decided I didn't wanna do the drone stuff anymore. And so I went to them and I said, hey. Like, do you have any work?
And then they came back to me and they said, well, we think micropython is really interesting. Would you be willing to port it? Meaning, support a different chip family, to the Sam d 21, which they had already built a bunch of hardware with that particular microcontroller. And so they asked me to port it there. So that was kind of the point where we we did our basic fork for MicroPython so we were adding a lot of code for this Andy 21, and just adding and tweaking and building stuff there. And then at some point, we decided that it wasn't it was gonna be very difficult to move all those changes back into MicroPython, partly because our audiences were different and our goals were different. So MicroPython wants to be a replacement for C on microcontrollers.
It wants to be for technical people who already understand the underlying systems of a microcontroller. Whereas our goal is coming the opposite direction of like, we wanna get beginners who have people who have never programmed in their life programming and making physical things with computers in them and code in them. So that was kind of the genesis for circuit Python as as a separate project.
[00:05:58] Unknown:
Yeah. For anybody who does want to learn a bit more about MicroPython itself, I'll add a link to the show notes to the interview that I did with Damien George a while back. Definitely worth a listen. And it's it's definitely great having another option for being able to target microcontrollers because when I was in school, I I definitely went the route of programming c to control the different aspects of the microcontroller. And, you know, you could definitely get a lot done, but it requires a lot more upfront understanding of the programming environment and the capabilities of the hardware versus being able to use circuit Python or MicroPython and have this high level language where you don't have to understand all of the aspects of memory management just to be able to get an LED to start blinking.
And so as you mentioned, you're working at Adafruit now, and I know that a number of the products that you sell support circuit Python. But I'm curious, what are some of the other language run times that you support at Adafruit and in your community? Right. So me personally, my time is spent on circuit Python, but Adafruit as a
[00:07:04] Unknown:
whole, tends to support both Arduino, which is kind of the the history of Adafruit. Right? Like that before circuit Python, that was the easiest way to program microcontrollers. So we do still support Arduino on the platforms that we have, which for those of you who don't know is c c plus plus with a a few changes and additions. So Arduino is a big 1. And then 1 of the other platforms that we're starting to see support our boards, we don't necessarily do a lot of the work ourselves, but Microsoft has a product called MakeCode, which is just a website with blocks that you can drag and snap together and then load them onto our Sandy devices. So, it's very cool and it's very good for maybe particularly folks who can't type very quickly,
[00:07:53] Unknown:
because it is block block based rather than text based. Yeah. Another language run time that I've seen target microcontrollers at least, in past years. I don't know what their current level of popularity is. Are things like node bots or think there's another couple of other JavaScript oriented run times for building on microcontrollers.
[00:08:13] Unknown:
I don't know if you've had much experience or many encounters with them. I know 1 of the people that does the NodeBot stuff, which I think is tethered, where you're controlling the microcontroller via JavaScript over the USB link. I think that's how that works, but there's also Espirito, I believe, which is actually a JavaScript run time on the hardware. But, I've never I've never looked into it, so I can't say too much about it. And I I think we do sell at least 1 Esprito board, but that's it. And so as we discussed, microcontrollers
[00:08:44] Unknown:
have higher level language simplifies the on ramp. But I'm wondering if you can talk a bit more about the trade offs of using Python versus c as far as the, onboarding capabilities and the reach and appeal of the devices, but also in terms of the limitations that you're, sort of accepting just by virtue of using this higher level language.
[00:09:14] Unknown:
Yeah. Well, it's it's interesting because circuit Python is c under the hood. Right? So just like c Python is, it is actually c under under the hood as well. So our goal and, like, most of the development that I actually do is in c with the goal of doing the things that are time sensitive in a faster compiled language. The trade off with that is that anything that I write in C so that you can use it for Python has to be baked into the image that everyone loads. The advantage of Python is that you can dynamically load it and that means that your resources aren't used for Python code until you actually know you need them. Now the on ramp there, like, the dynamic loading is the part of the on ramp. Right? So you flash a device with circuit Python. It shows up as a drive called Circuitpy on your computer. It's got a code dotpy file on it or if you just flashed it it will be empty and you can place a code dotpy on file on it. You simply open that file, you type some Python code, and you save, and then it auto reloads and your code is running. Right? You're like, it's that easy. I'd I'd like to do lightning talks. They take me about 3 minutes of just take a device that has circuit Python in it, plug it in, change of change a, like, brightness of the LED so that people could see it and just show, like, it's super quick, to get going. And the iteration cycle on your drivers or whatever you're working on is way faster than anything where you're doing that compilation
[00:10:40] Unknown:
erase of the whole chip and then upload it like you would in Arduino, for example. Yeah. Having that fast development cycle as has been discussed just for Python in general, but specifically for hardware, I'm sure helps keep people engaged rather than fighting with the compiler and trying to figure out with their, you know, GDB what's going wrong in their program, just being able to open up a REPL, but also with the sort of wide availability of powerful computing platforms, such as the cloud or smartphones or laptops and desktops, what do you find as being the benefits of experimenting with and enabling the experimentation of microcontrollers and their peripherals, both for people who are new to programming and computing entirely, but also people who have been doing it as their career for years. Well, I think the core of it is that being bare metal, meaning there's no operating system underneath circuit Python, like, that's all it is. That simplicity
[00:11:37] Unknown:
is awesome. Before we started, we were alluding to the simplicity of, like, past systems, like the Commodore 64, for example, where the there's very limited OS and basically you're just you have 1 program you're writing or running, and it's in control of the hardware at that point. Having that much more limited scope of what software is running on your device means it's much easier to understand completely what's going on. Now I said earlier, it's our devices are like 48 megahertz, but there's a lot you can do with that because you are the only thing running. Right? Like, it's just your code that's running on that CPU. So I think that is really good for beginners because there's no having to set up Linux and get permission, like, worry about permissions or any of this stuff. It's just you flash it, you plug it in, it shows up as a drive, you edit the file, and you're off and going. So that means it's great for beginners, but it also means that it's great for folks who have done a lot of software, but may so are coming from the software world into the hardware world. Right? Like, they may know Linux and that's fine, but the fact that they don't have to use it or or manage an SD card, for example, means that it's much much faster to get going, and it's easier to understand what's going on because the complexity of the system is so much less. You can focus on understanding
[00:12:56] Unknown:
how you attach things to to the device you're using rather than some esoteric software that happens to be included in what you're using already. And I think too that it reduces the element of fear that can crop up when somebody is being faced with 1 of these projects, particularly when you're dealing with maybe, like, a network environment of, you know, having to interface with other computers or understanding why is this bug happening, and it's because of some esoteric aspect of the kernel that you're running. And also, too, if you're working with a computer, if it's the only computer that you have for doing your work and you're trying to experiment and tinker, then you might inadvertently damage it or make it unusable for being able to be productive at your job. Whereas with these hardware devices, if you screw something up, well, you just reflash it, no harm done. And so there's a lot fewer things that can go wrong and a lot fewer things, like you said, that you have to keep in your head to be able to understand absolutely everything that's happening. Right. And and cost is a factor too. Right? Like, least expensive board that runs circuit Python is
[00:14:00] Unknown:
probably $10. If I can think of it like a trinket or a Gemma from Adafruit is about $10 if I remember right. And that will that scales up, of course, but, like, you can get like, it's really inexpensive and and that the fact that it's inexpensive means everybody can get 1, and it means that it's not the end of the world if something does happen to it, which I think is very powerful. And so up to now, we've been talking about just the idea of the microcontroller
[00:14:26] Unknown:
itself. But 1 of the great things about dealing with these hardware platforms is the fact that you can add in a number of different peripherals for being able to interact with the real world via sensors or motors and servos and, you know, maybe even get involved in things like robotics. So I'm curious what your experience has been as far as people starting with just, you know, flashing some of the onboard LEDs and then moving into some of these more complex and complicated platforms and projects.
[00:14:55] Unknown:
Yeah. It's that's what it's all about. Right? There are not many projects that people wanna do that are self contained in the device that they buy depending on what like, we are Adafruit is experimenting with more, like, consumer or, like, all in 1 sorts of things, but there are also this class of devices that are totally meant to just hook up to other things. That is very much what, like, makes it a platform. Right? Like, prior to CircuitPython, Adafruit's primary platform was Arduino, and they spent a lot a lot of time writing drivers for all of the different devices that you could connect to your Arduino.
And going into circuit Python, we knew that that was gonna be the approach as well where, you know, CircuitPython we can talk about in terms of just the c code that you drag over and and use, but, the project's way more than just that. It's also the documentation. It's all of the drivers and how people download drivers and the guides that teach you how to build things out of it. I think we've done a great job with our focus on that to the degree that the API that we kind of, again, set us apart from MicroPython has has brought us into the Raspberry Pi world as well. So the same the same Python drivers that you use for a temperature sensor, I squared c temperature sensor, for example, that you use with a really inexpensive circuit Python device, you can also use with a single board computer that's running CPython as well, which is super powerful as a way to start with something simple but get the complexity when you need it without having to relearn a whole new language and a whole new library set. And as you mentioned earlier,
[00:16:30] Unknown:
circuit Python itself is based off of the work of MicroPython. And I'm wondering if you can talk a bit about some of the ways that you have changed your version
[00:16:40] Unknown:
and how you structure the development to be able to track the upstream project and be able to take advantage of the work that they're doing as far as any optimizations or updates? Right. So I alluded to kind of the major 1, which is we have a different hardware API. And the reason for that was we knew going into it that we were gonna need a strong API to build all of our drivers on. I didn't at the time we were discussing being a friendly fork, I didn't think that there was such a concrete uniform API in micropython land. And so we decided to internally, we restructured the API so that all of the Python APIs, the the c code that defines those are all shared across all of the different ports. So a port is like different chip families, like the nRF versus the sandy.
And that structure really makes it rigid, to, be very exact across all of the ports, which means the drivers will work across them, which is great. So that's a major thing that that also has a consequence that means, you may not be able to take a micro Python driver and use it in circuit Python or vice versa. The conversion is not that hard, but it is kind of not easy as well. So that's a major thing. Another major thing is actually the auto reload. So MicroPython does show up as a drive when you plug it in, but if you save the file, it will not reload it. You actually have to be connected to the serial link and, trigger it yourself. Whereas circuit Python, we basically implement watch, like a a watch program that, like, the JavaScript world really likes, where it just watches for file changes. And then if we see a write, we'll just wait a little bit so that we don't restart a lot, but then we'll restart. And that means it's just way quicker to get going and you can get going even if you don't see the your serial output. And that second change is more in the vein of our focus on the beginner and, like, what is your first 5 minutes experience with coding? Right? Because our our target is people who've never coded before. So how can we make that absolutely as easy as possible? Couple other things that we've done more recently, we're about to launch our stable 4 o release. So these 2 features will be in there. 1 is we now support translations.
So the messages about, like, auto reload and welcome to circuit Python are translated into, I think, 10 languages now. And then we actually also translate all of the well, we could translate all of the error messages that Python can throw. So if you get like a a syntax error and then there's a string after the syntax error, we'll we could actually have that translated depending on the quality of the translation or the coverage of the translation. 0 division is another example of an error where you'll get that like translated message. So those are a couple additional things that we've done differently from what MicroPython's done. Now circling back to the about how we structure our development. When we decided to be a Friendly Fork, I committed us to pulling released versions of micropython every time we kind of reset on a major version. That is getting harder and harder as time goes by as things change between the 2. But a lot of the changes that happen in micropython are specific to a particular chip family, the STM 32, which is the original port and also, what Damien, he sells hardware with that chip on it. So most of the changes will happen there or they'll happen in the Python directory, which is like the VM parts of of MicroPython. So and we've I've done a few changes in there. So the merge definitely is not super easy, but in general, because we're separated by chip families, we don't overlap too, too much. But yeah, it is getting harder and harder as we go on. And our approach after we do this 4 0 c release is we're actually not planning on taking a dump from MicroPython, like, updating to their 1.10 release immediately because that will make us kind of unstable for a while. And we actually wanna do multiple feature releases in our stable branch before we take, that instability into our repo. So, yeah, it's a tricky it's a tricky problem,
[00:20:42] Unknown:
but it's possible we can do it for sure. And have you had any conversations with Damien about maybe ways to restructure or refactor the upstream project to make it easier to maintain your changes and have this sort of friendly division of circuit Python versus MicroPython?
[00:20:59] Unknown:
Specifically for that goal, we there there were some discussions when we first forked about how to restructure. I think Damien's mental model for it is basically Linux distributions. In practice, like, the he was kicking around the idea of actually splitting out the VM parts from the port specific stuff or chip specific stuff. That hasn't happened. But, yeah, we did we did talk a little bit about it because we weren't we're not actually the only fork of MicroPython. We're 1 of the few that actually maybe the only 1 that actually renamed though, which is why we get a lot of attention is because we're we don't call ourselves micropython directly anymore. But, yeah, I do I do talk with Damien on a regular basis, but that topic hasn't come up recently in terms of, like, just making it easier to to merge changes in. We did have a discussion with him the last time we merged changes in, because there was some feature that we wanted. And so he was kind enough to say, like, hey. This particular Git commit is pretty stable.
And that's actually what we're based on right now. So we're not actually our 4 o release is not based on a a major version or or a re a released version of micropython, but it was a version or or a commit that Damien recommended to us. So we appreciate that for sure. And given the amount of
[00:22:18] Unknown:
I've is that is working on circuit Python, both within Adafruit and sort of within the community as far as the course course out of maintainers, but also I'm wondering which changes you have submitted back up to the MicroPython
[00:22:35] Unknown:
upstream project. Right. So I'll just tackle that first. The question is how many changes have we moved up to micro Python? And the answer is very few. I think there were a couple bugs that we found in, like, the core VM bits that we may have just told Damien about, but that's just about it. I'm also currently kind of consulting with them about or or at least just chatting with them about adding CMD support back into MicroPython itself. So I I've offered up, you know, my expertise in that chip family to them, but, that's kind of the extent of of the contributions. Like, if you look at actual poll requests up, there are very few. But we do have open discussions about what we're doing and and outstanding offer to Damien to work with him on anything that he feels is interesting enough to pull up in the micropython.
And then do you have any questions about that before I talk about team? Okay. So for team size, I was the original kind of full time c side person on the project for Adafruit in 2016. That was August of 2016 when I came on, and I wasn't working at all then. So it was really I just jumped in and dove in and and never looked back. The next year in 2017, we added our second kind of full time core sea person, Dan Halbert. He's awesome. He's the original author of the morgue man, which is kind of his claim to fame. And so Dan and I are are the very 2 core people now. We've added another person, Katnie, to the team. She is a a jack of all trades. She started doing, writing guides for us, but has now like officially is master of all of our libraries and and wrangling. We have like a 150 different Python libraries. So there's a a lot of maintenance that happens there that she helps out with too. So those 3 are kind of like full time core circuit Python project folks. And then we have, maybe 10 community folks. We have 1 who just is getting ramped up right now into full time for drivers, including our general drivers. That's Melissa who you may have met at PyCon as well.
So that's kind of the core team that's paid and then we do have a number of contractors that we do on a project by project basis, for different things. For example, we've paid somebody to add STM 32 F4 support to our underlying USB library. So that's an example of just a, like, a 1 off project that we'll pay somebody else to do. But our we have a weekly meeting that everybody's welcome to join that happens on Mondays at 11 AM Pacific, 2 PM Eastern. You can go on to the Adafruit YouTube and see the previous ones as well. But we typically have about a dozen, maybe up to 2 dozen folks, who join in the meeting and we do a couple round robins in that meeting where everybody gets a chance to talk about what they're working on. And we have a number of regulars there that that participate as well. So I would say like 4 core paid people and then maybe a dozen or 2 pretty regular contributors, both not just the c code, but in the, like, broader project contributions,
[00:25:34] Unknown:
for sure. And as far as the user facing APIs for circuit Python, particularly the ones to expose different capabilities of the underlying hardware, I'm wondering what the sort of overall discovery capabilities are for making it easy for somebody to start working with the LEDs or running motors or dealing with sensors and just how you think about the overall API design to make it easy, but also provide the full set of capabilities so that people aren't limited by using my, by using circuit Python. Right. Right. So we kinda split it into 2 categories. The the APIs
[00:26:15] Unknown:
that we present from the raw c code, which are the APIs everybody has access to, those are designed to be complete and consistent but not necessarily easy to use. So they're the ones that are trying to expose all the functionality to the Python land. And then we can then build Python libraries on top of those complete APIs for simplicity. So Catney actually came on board finishing a library that I had done to simplify using the Circuit Playground Express, which is an all in 1 board that we gave everybody at PyCon. And that's just an example. So, like, that library will initialize the underlying driver all of the LEDs for you so you don't have to worry about it, for example. So the ease of use we've decided to put into Python land where we can and then the complete stuff is the the underlying APIs. For our libraries to make them more discoverable, either, like, I think people tend to come in into circuit Python with a project in mind. If they have a project in mind, they'll either find a tutorial on learn.adafruit.com or they'll find 1 in, Hackspace Magazine, for example. And then they'll they'll find libraries that way. And our library distribution process is pretty simple.
We zip them all up in a file. We we have a 150 of them, but they're all pretty small because they need to be small to fit in the RAM. And so we just have a zip file where you can just download them all. And for a while you were able to download the all those onto the drive itself so you just have to import it and use it. Everything would be available to import. I don't know if that's still true. We encourage people to just drag over the ones that they need at that point as well. But, yeah, we want our general philosophy in API design is to be very Pythonic, which is not necessarily something that the MicroPython APIs try to be. They choose they trade off some Pythonic stuff like properties in favor of things that are faster to implement, because they're really speed focused. And we try to be very Pythonic at which means it runs in CPython which is great. But then we also try to have lots of small libraries because we don't like if it if your library is 1 giant Python file, that's really hard for us to import into RAM. So like we have a an image loading library where the first file you import will open the file and try to figure out what type of image it is. And then once it figures out what kind of image it is, it'll import another thing for you, just for that specific file type. So it's a challenge to to make small complete libraries that work that way but it's worth it, in the end because the smaller your libraries and, like, better your boundary your API boundaries are on what you're trying to do, the more that you can do in the the amount of RAM that you have for sure. Yeah. It's tricky, but I think we've done a pretty good job with it.
[00:28:59] Unknown:
And having the ease of use is definitely great for people getting started, but is there a point where they will outgrow circuit Python and need to move to either the upstream micro Python or just using c directly for being able to get certain aspects of performance or feature completeness as far as being able to, access all the different aspects of the hardware? Or is circuit Python full featured enough that somebody can ship a production grade application using the,
[00:29:31] Unknown:
circuit Python library and and the underlying hardware? So we're not shooting to be production grade. So MicroPython is because of the nature of the products that Damien sells. So so that is 1 route to go of if you've proven out your idea, but need reliability or battery life, MicroPython's a great option kind of as an on ramp into like, CircuitPython could on ramp you into MicroPython if that's what you're going for. If you need more speed well, 1st and foremost, you should start with CircuitPython because it's easiest to to get going with. Right? Like, there's this notion of premature optimization and jumping straight into c or something else or like a Linux single board computer. Like, that's premature optimization to me. It's really impressive the things that you can do with circuit Python. And so I would recommend people start there. But and if that works, but you need, like, more reliability or battery life or, like, multi threading, well, yeah, multi threading, like, MicroPython's a great option. If you just need more grunt or better connectivity, abstraction library called Blinke. So that works on CPython, and that's a really easy way to onboard into something more complex or more powerful than a circuit Python board as well. In terms of things that run circuit Python in production, I don't know of any, like, consumer grade thing that does.
Although there are a couple really interesting crowd supply projects that are, coming up. 1 is a USB hub. So it has a CMD 51 which is supported by CircuitPython. You can use that to control the USB hub itself, which is pretty neat. That's by Capable Robot. And the other 1 is a robo hat. So it's for it's for, circuit Python or it's for Raspberry Pi and I think it just I'm not sure if it runs Circuit Python or whether they're just using our libraries. I think it runs Circuit Python, on the hat itself. So you would have the challenge with a Raspberry Pi is and and Linux in general is that it's you have so much going on that it it's not necessarily real time anymore. You you at at any point, your code could stop running for a little while and then come back. And that makes anything that's timing critical really hard to do. So typically with a Raspberry Pi, what you do is you'll you'll have some, like, high level code that needs to do a lot, but then you'll also communicate with a microcontroller that can do all the real time stuff for you. So I think there's a the Robohat has circuit Python on that side,
[00:32:06] Unknown:
for the the more real time stuff, as well. And going back to the community that you've built up around circuit Python, I'm wondering if you can just talk about some of the ways that you, attract people to the project and engage with them both at the code level and the hardware level and just, providing
[00:32:26] Unknown:
project ideas and feedback on people's existing projects? Yeah. So I Adafruit had a huge leg up on this already where Adafruit already had this the learn system, which is their system for guides and tutorials and stuff. They already had existing live streams that they do. They do 2 live streams, at least 2 2 live streams every week. 1 is called show and tell, and that's a half an hour on Wednesdays where anybody can join into a Google Hangout to show the project they've made. That's how I got the job. So I recommend people doing it. It's a great great exposure. There's a really friendly audience. And then Ask an Engineer is right after that, and that's more like company news and goings ons and things. But around both of those we have chats and then, Adafruit is always it's a woman owned electronics company and that does attract some not so great people. So they've already always been very deliberate with their community that they behave in a friendly way. And when we forked off with CircuitPython, 1 thing we did is we made sure that to to embody that and make sure our community reflected those values as well.
We had a code of conduct on all of our GitHub repos that was, that's a backstop if you do have somebody that is just not fun to interact with and we've done a great job at that. At some point, our livestream chats transitioned into a Discord server, which is kind of kind of like Slack, but it's easier to jump into the server. It there's no account like the account making is very lightweight and stuff like that and it's getting more and more popular. So we have about we have 12, 000 or so registrations on that server. So that and that server, once we had it, is where we kind of hold all of our development discussion as well. So I already mentioned the weekly meeting. We do that on our Discord channel and then we post it on their YouTube, as well. We manage our priorities and GitHub issues.
That's a great way for people to just stumble on things that need to be done. We try our best to be responsive to pull requests and issues that people have. It can be a lot of work, right? Like there's a lot to running a project that's not writing c code. It is a lot of work, but it's something that we've focused on from the get go to to spend the time. Because in my view, spending the time on ramping people up and getting people doing it is time that you'll get back in the in the end. And that's been true. Right? Like Dan and Catney, we hired in 2017.
Both of those folks just found our project and started working with us even before we paid them. So like, imagine, like, I don't know how you anyone's company hires, but imagine if you could actually work with somebody and then just start paying them to do this the exact same thing. It's a great way to find really strong contributors and people that match your work style. So putting time into a community, an open source community and making sure that standards are kept in terms of behavior means that the some people that you may have lost before will stick around and actually speak up, which has been the case. And we've gotten lots of great people that way as well. So, I encourage folks to to spend time on their community, realize that it does pay off. Like having new contributors come in and then be consistent contributors in any way whether it's code or tutorials or testing, like, that's all super valuable,
[00:35:46] Unknown:
and it's well worth it. So it's hard, but it's well worth it. And in terms of the actual projects that you have worked on or that you've seen people build with circuit Python and the Adafruit hardware?
[00:35:58] Unknown:
What are some of the most interesting or innovative or unexpected ones that you've seen? 1 that really surprised me was the not PyCon this year, but the previous PyCon we gave everybody these Gemma boards and they're very small. There are only about 6 pins that are broken out and there's just 1 LED on it. So there's not a ton you can do with it, but Katherine, who has kind of been in our community, she came up with a project to do interpret tapping 1 of the pads as Morse code, and then circuit Python can act as a keyboard so she can Morse code into her computer and then tweet it out, which I thought was super cool. Sophie Wong is here in Seattle, and she just does these amazing costume projects. She's in Hackspace Magazine regularly, and they just have a book. So she always does really impressive projects. I'm definitely not doing its service, like, in terms of pea what people have done with it.
I was really happy, like, Linux or it was either LinuxConf Australia or PyCon AU had 2 talks and both of them were they they included CircuitPython, but the primary part of the talk was not CircuitPython. Right? Like like you can have talks about a tool or you can have talks that use the tool, and most of the things that I've seen with CircuitPython are the latter. They're they're like, yeah, CircuitPython's great. It's a great tool because I wanted to monitor my workspace for environmental variables or that was 1 of them. The other 1 was making an LED ring light for the camera, for a macro camera, Right? Like, I love that people are using circuit Python to do other cool things rather than just talking about circuit Python itself. Unfortunately, my life is very much the the opposite.
[00:37:38] Unknown:
And 1 of the high profile uses that I've seen recently is Scott Hanselman posted a blog post about using the pie portal and circuit Python for being able to build a dashboard for his glucose monitoring for keeping track of his diabetes. And so it's definitely great to see the variety of ways that people will think of when you give them sort of some simple tools and, you know, some constraints as far as the hardware, but no constraints as far as their creativity.
[00:38:06] Unknown:
Right. And if you do run into those constraints, like, there are options. But there are so many projects that you can do within those constraints that it's and it's so easy to get started that it's well worth just starting with circuit Python for sure. And as far as your own experience of building projects on hardware, what are your favorite device platforms to target and what are some of the projects that you enjoy tinkering with? Oh, yeah. Forms to target, and what are some of the projects that you enjoy tinkering with? Oh, yeah. So I kinda have a reputation for wanting to put circuit Python in everything. I mean, I I work on circuit Python be because it's great. I, like, I didn't know about MicroPython when when Adafruit asked me to look into it. But the moment I I heard about it, it was sold. Right? I had already done microcontrollers and I already knew Python was great. So, like, combining the 2 made so much sense to me. So I think we've done a great job with CircuitPython making it even easier. And so my kind of hobby time is spent trying to put Python well, circuit Python and things that you wouldn't typically expect. A couple examples I've done is I have a mechanical keyboard that runs circuit Python, and and I was just chatting with another Adafruit person who's gonna make a keyboard as well. And there's some development there that other folks have done as well to have really rich mechanical keyboard software written in circuit Python. Another thing, I have a toaster oven that I wanna use as a reflow oven that I've put, a new samd in and tried to, like, make make it run circuit Python.
It's got some hardware challenges right now, but I'm working well, I'll work on it at at some point. And then the project that has a lot of my focus right now is custom Game Boy cartridge that I've designed. It's basically the same chip that is in a lot of these Adafruit boards and runs circuit Python, but, it's in a Game Boy cartridge form factor. So you simply can put it into a Game Boy, and I've written some special code to actually issue instructions to the Game Boy so that you can program it from Python. I'm still, like, working out the kinks so it's, like, fully playable, but I've proven out kind of all of the challenges already. Like, I can I can make the Nintendo logo not be the Nintendo logo? I can make it say Adafruit. I can play sounds. Like, I I can play sounds and I can change the screen on the Game Boy, and I can read the button presses and stuff back into. So gaming is what my focus is on in general right now, both for work and kind of hobby. So that's where my brain's
[00:40:27] Unknown:
at in the in the hardware side as well as the as the software side. And when I was getting ready for this show, 1 of the things that I came across on the Adafruit site was the creative robotics platform that you've built that interfaces with the Circuit Playground Express, which is what you gave out at PyCon this year. So I'm wondering if you can talk a bit about what that platform adds and the capabilities of it and maybe some of the ways that it's being used or that it could be used. Right. So I think you're referring to Cricket,
[00:40:57] Unknown:
our Cricket board. And it actually supports There's variants of it for Feathers and, micro:bit as well as the Circuit Playground Express, and that basically only changes the way that you connect the other board to it. 1 of the main challenges with robotics is power because both motors and servos can take a lot of juice basically that the boards themselves like the circuit playground aren't designed to do. So 1 thing that Cricket does is it makes it possible to control a lot of power to peripherals like motors and servos, with the kind of dinky quote unquote signals from the micro controller itself. And then on top of that, it's in a there are connectors and stuff that make it easier to hook those things up to it as well versus kind of like the the standard 1 mill 0.1 millimeter pitch pin headers. We have an Aida box that Cricut was originally designed for, and there's a number of projects in the learn system that show you what you can do with it. I've seen a person at Adafruit's been working on, some kind of boats that are that are powered via Cricket, I think, where it was like can, like, like, motor around a bathtub and stuff. Dan, who works with us, did a Bluetooth demo where he actually used like a servo to move, like animate a character in a in a kind of circus scene. It's called circus Python, I think, which is funny. And then there's kind of the more traditional round robot stuff, which I think the ADA there's an ADA box for, which is all about driving in a robot around. And and you can do things like to try to sense objects in front of it and things like that. So, yeah, it's it's interesting. And I've I've not actually done a lot of, like, really mechanical stuff. That's not my strong suit. And in terms of your overall experience
[00:42:42] Unknown:
of starting the circuit Python project and helping to grow and maintain it and use it for your own purposes and see other people use it, I'm wondering what you have found to be some of the most interesting or challenging or unexpected lessons that you've learned in the process. Yeah. I think the most challenging bit there's kind of 2 parts to it. 1 is RAM. Straight up like how much memory you have to load code. The s m d 21 has 32 kilobytes,
[00:43:08] Unknown:
and that has to be shared between the C code that's running and the Python code. I've done some work in terms of how we actually allocate the Python objects in the heap there. There's a couple videos of that on my YouTube channel where I the nice thing about it is that I you can actually it's it's so small that you can capture every time you do an allocation to, like, your laptop and then, like, post process and analyze it later. So there's some, pie graph vis charts that I designed based on the heap layout and stuff that can show how I've tried to evolve, the way that we allocate to memory in a more efficient way. So, like, trying to reduce fragmentation in particular. So that was, like, kind of unexpected but really fun. Like, I like those sorts of challenges. Kind of in the world of, like, speed challenges right now because we're doing gaming and we wanna be really, really fast. So very deep in the weeds of learning how to shuffle bytes around quickly and and and realism quickly. That's the, like, nitty gritty, like, really low level stuff. The other side of it is the human side, which is discovering challenges for beginners of of the bootloader didn't work or we had some boards ship out that didn't protect the bootloader and we actually have a bug that will overwrite the start of the bootloader which means that you, like, you can't easily load code anymore and that's that's really challenging. And once you figure that bug out, how do you teach people to update, for example? So it goes both ways, and making it easy for everyone on every platform can be quite a challenge.
And Dan in particular has done a a great amount of work to to make sure that the USB side, for example, works across all of the different, like, Windows platform, Windows and Linux and Mac and stuff. And that's some of the most exciting work I'm looking forward to in the coming year is really pushing the that ease of use boundary again. I really wanna unlock, people who don't own a laptop as as beginners via by programming these devices from Bluetooth from their phone or tablet. And, that's gonna be a huge focus for me after all of this gaming stuff. And I'm I'm very excited about it because usability is really challenging, but something like that is hugely rewarding because it impacts basically all of your users. Right? Like, if I can make writing code on circuit Python easier, I can base I basically benefit everybody versus if I'm, like, adding support for 1 thing or I'm adding gaming support. Like, it only impacts the people that wanna do that specific task with circuit Python. So yeah. Those are a couple things. It's it continues to be challenging and as the project grows, the management side is a challenge too.
But it's super rewarding. It's awesome to see it's awesome to see newcomers really light up when they when they try circuit Python and then wanna participate as well. So, yeah, it's it's fun. It's hard, but it's fun. And is there anything else that you wanna call out that you're looking forward to for the future of the project? The Bluetooth thing is the main thing that I'm really looking forward to. The other thing I guess I should comment on is there's a hardware geek within me, and we're this class of microcontroller is still kind of, like, very much in Moore's Law where, like, our first 1 I did was 48 megahertz. The next 1, the Sam d 51 is a 120 megahertz. So there is this very interesting kind of longer term question for us of, like, what are the next platforms that we support, and how fast are they, and how much RAM do they have, and what things can you do with those platforms that you can't do today? So in that same vein of, like, Bluetooth is great because it it makes it easier for people to use. 1 thing that we've really relied on is, like, standard USB devices and and functionality. So we we do human interface device, which is mouse and keyboard. We do midi, so you can control midi on your computer from the custom input device or vice versa. You can play MIDI back like I was I've played back MIDI songs on Gameboys ingesting midi. So I'm very interested in that next gen platform. Whatever we settle on, I'm hoping it will also have USB high speed, which is 400 megabits per second versus 12.
Or if we go crazy and we go super speed as well, like, why not? Right? Like, why not skip to the fastest thing? But what I'm excited for that is is it'll actually unlock the ability to do audio and video up and down that link, which should be really cool, particularly for the gaming stuff. Like, if you have a gaming handheld, you could plug in your USB to it and then stream what's on the screen straight away over the USB link. What what would be very cool to me. I've chatted with some of the FPGA folks as well. So an FPGA is is a chip that's reconfigurable, and you can do custom CPU and and system on the chip sort of stuff with that. And it's very early days and it's not super easy, but I think that's another place to keep an eye out for.
It's gonna become easier to design your own your own chip essentially. So for example, like, if you wanna run a dozen NeoPixel strips in parallel, there's not really a great way to do that right now. We top out at 8 currently. But if you can reconfigure a chip on the fly, it should be really easy to do. So yeah. It's it's potentially really exciting. It's still early days, and they're kind of expensive. So it's tricky to hit the price points that you want with those. But those are some of the, like, longer term things that I'm personally excited about. It will definitely evolve as we have more people come into our community and wanna do different things. Because at the end of the day, like, our development should be driven by the the projects that people wanna build and can't build today, but wanna build with circuit Python in the future. And are there any other aspects
[00:49:01] Unknown:
of the circuit Python project itself or the, sort of hardware
[00:49:06] Unknown:
enablement that you're doing with Adafruit and circuit Python or anything else that we didn't discuss yet that you'd like to cover before we close out the show? I'm I'm very excited to see other people adopting it as a platform. Platform. I guess I didn't talk about that, but I really would like to see circuit Python become bigger than Adafruit. Adafruit's put a lot of money into it, and been very, very supportive of the project. But I think in in order to become even bigger, we've gotta kind of grow out of that and include, other devices. So the the 2 crowd supply things I talked about, I'm very excited about.
SparkFun is another kind of hobby level electronic store, and they have a few devices that run circuit Python as well. So that that's another tricky aspect that is community building as well, but kind of a different take on community building. It's not driver writing or guide writing. It's actually, like, more people to make devices that ship with it. That can be quite challenging. For 1 reason is that Adafruit sells devices as well. So, some of those folks can actually be, like, direct competition, which makes it tricky to push a platform that is so heavily funded by 1 of those partners. But I'm excited to see it grow. I mean, all all signs are pointing it to being on more devices by more companies and that that'll be good for everybody, I think, which is cool. And for anybody who wants to keep up to date with what you're doing or get in touch, I'll have you add your preferred contact information to the show notes. And so with that, I'll move us into the picks. And so this week, I'm going to choose the book series Wings of Fire, which is a,
[00:50:39] Unknown:
sort of young adult fantasy series that I've been listening to on audiobook with my family for a few weeks now, because there are quite a number of them. And they're just a lot of fun. They're very imaginative. The entire world is oriented around sentient dragons and the different adventures that they have. Lots of great sort of societal aspects to it. It's just a a lot of good fun. So definitely recommend checking that out if you're looking for a new book series to check out, particularly if you're doing it with your kids or even just if you're doing it for yourself. And so with that, I'll pass it to you, Scott. Do you have any picks this week? Yeah. I'll I'll stick with the theme. 1 thing I always recommend,
[00:51:20] Unknown:
folks is Brandon Sanderson. You may have read his books, But Brandon Sanderson is a fantasy fantasy author. He finished the Wheel of Time series, has some young adult adult books I haven't actually read. But the series I would suggest people start with is called Mistborn, m I s t b o r n. There's a trilogy at the start and then there's some more ones that come after in the same universe, but he is an excellent writer. I have 2 cats and I named them after the main characters of Mistborn. So I'm I'm clearly a fan of of his writing. So if if folks don't know Brandon Sanderson, he can't go wrong with any of his books, but what I would suggest starting with is the Mistborn trilogy.
[00:52:08] Unknown:
Yeah. The Wheel of Time series is a pretty big lift at this point because I I don't even know how many dozens of books there are now.
[00:52:15] Unknown:
Well, I think I think Robert Jordan, the original off author wrote 12, and then passed away. And the widow of Robert Jordan chose Brandon Sanderson to finish the last 2. I think it was supposed to be 1, but he he decided to do it in 2 books. And it's either that or 2 or 3. But, yeah, it's it's quite the read, and that's what I started with. And then I I found Brandon Sanderson. I was like, wow. Those books were much better than some of the other Wheel of Time ones. So, yeah, highly recommend Brandon Sanderson. He's got an epic fantasy series of his own that's not complete yet, so beware of that. The the the biggest ones are are still in in the works. I think it's supposed to be 10 books altogether, and there's, like, 3 out.
I forget what that series is actually called, but 1 of the books is Way of Kings. Anyway, they're great books, but it's definitely they're not done yet.
[00:53:11] Unknown:
Well, I'll I'll find it and add a link to the show notes. I want to thank you very much for taking the time today to join me and discuss the work that you're doing with circuit Python. It's definitely
[00:53:21] Unknown:
a great effort and 1 that I look forward to sharing with my kids. And so I appreciate your work on that, and I hope you enjoy the rest of your day. Thank you so much for having me. I really appreciate it. And I'd love to see you come on Adafruit show and tell with your kids and show us what you've been making.
Introduction to Scott Shawcroft and CircuitPython
Origins and Development of CircuitPython
Comparison with Other Microcontroller Languages
Trade-offs of Using Python for Microcontrollers
Expanding Projects with Peripherals and Sensors
Differences Between CircuitPython and MicroPython
Collaboration and Contributions to MicroPython
User-Friendly APIs and Project Discoverability
Limitations and Production Use of CircuitPython
Community Engagement and Support
Innovative Projects Using CircuitPython
Challenges and Lessons Learned
Future Developments and Exciting Prospects
Expanding CircuitPython Beyond Adafruit
Book Recommendations and Closing Remarks