Want to learn how to build an Ironman-like arc reactor accessory or maybe a solar charging backpack?
What if you could program these devices with Python? Now that would be cool.
In this episode, we're going to be talking about a project and a company combining to make this possible.
This week, you'll meet Tony DeCola, who works at Adafruit, a company making hardware programming accessible to everyone.
And we'll also be talking about MicroPython, which lets you program these cool devices in Python.
This is Talk Python to me, episode 108, recorded April 18th, 2017.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm.
And follow the show on Twitter via at Talk Python.
This episode is brought to you by Advanced Digital and the Strange Loop Conference.
Be sure to check out what they're offering during their segments. It helps support the show.
Tony, welcome to Talk Python.
Hey, it's great to be here. Thanks a lot.
Yeah, I'm really excited to talk about hardware and MicroPython and all the stuff that we got on deck today.
So that's going to be really fun. But before we do, let's start with your story.
How do you get into programming in Python?
Yeah, so I think like a lot of people that you've had on the show, I got into programming just as a kid.
So when I was 13 or 14, I remember at the time we had a 486 and I was using QBasic to learn how to do programming.
Or it was just a fascinating thing to me to understand like, wow, I can actually make something that controls the computer.
And of course, I wanted to make video games. And that seemed like the coolest thing for me.
But it was just a really interesting passion that I followed as a kid.
Just took me all the way through college, studied computer science.
And Python is interesting. So I remember in college, this was around maybe the early 2000s or so,
I'd started to hear about Python and it had been around for quite a while.
But I played around with it. I think I'd learned like the basic syntax and then put it away and didn't use it for a long time.
And I went on and worked a lot in industry with like some of the managed languages like C#.
And I did a lot with like C++ originally. But I kind of came back to Python maybe about 10 years ago.
I was working for an online service, SkyDrive, like what used to be called SkyDrive, a big file store service.
And we had to do a lot of data processing. So things like looking at log files and analyzing data.
And that stuff is not so fun to do in some of the languages like C++.
So Python was like a perfect fit for that. So I started to use a lot of that for things like manipulating data.
And just really kind of fell in love with the language.
You know, it's turned into something that becomes kind of the first thing I reach for now when I have some problem of,
you know, whether it's even just like doing something on the desktop, like manipulating files, manipulating data.
It's what I really like and enjoy using. So it's become kind of, I'd say, the primary language that I use.
And then as I've worked with Adafruit, it's been something that's been interesting to explore of how you take Python and use it to control hardware,
because that's been something that's been a little bit difficult.
You know, hardware has typically been a lot of low level languages and direct access to the hardware.
Right. That's the domain of C, right?
Exactly. Yeah. So having like the C and C++ knowledge, that's what your bread and butter was.
But nowadays, things have kind of changed a little bit.
So there are a lot of new processors and, you know, it's Moore's law.
Everything is getting faster, even at the low end.
So these little processors can actually start to run things like Python code.
And so that's super exciting to me to start to see that kind of crossover there.
I think that's really cool.
Like a couple of questions.
One, coming from like static languages that are based on C with curly braces,
like how did you feel about coming into Python with the white space and the dynamic types and whatnot?
Oh, sure. Yeah, yeah, yeah.
I think everyone maybe goes through like a phase of like it feels weird and you maybe push back against it
and think like, oh, wow, this is horrible.
Like I don't understand what's happening.
And the biggest thing for me was losing the destructor.
Like, you know, in C++, I love having that knowledge of when some object goes in and out of scope,
you can do certain things.
Then in Python and some of these managed languages, you just don't have that control anymore.
So, yeah, your first reaction is kind of to push back.
But then after a few years and using it for a while, you get into that zen of Python of just kind of understanding.
And like nowadays, I love how Python, it almost feels like clay.
Like you can just model it into whatever paradigm of programming you like,
like whether you want to do object oriented or functional or some combination of those.
So it's, yeah, it was a little bit of an adjustment period, but you kind of have to think more, I guess, Pythonically,
which was another thing that took a while to kind of figure out and understand what that means.
But yeah, really not try to do things that you would do in the C and C++ world.
Look more at, okay, how do you do that in the Python world and just adjust to that.
So, yeah, there's a definite period of changing.
Yeah, that's interesting.
I still remember that it seemed really odd to me, like using white space for managing structure and stuff.
And then I got really comfortable.
It really took a few hours to actually get comfortable.
But then a week or so later, I went back and I'm like, whoa, what are all these symbols?
And why is all this stuff here?
This is so not fun anymore.
And like a week ago, I really loved it.
It was so weird.
Oh, yeah, exactly.
And the problem is, unfortunately, with a lot of the curly braces, everyone has a different style.
So you might read some code that looks completely different from a different style of code.
And so it is nice that it makes things a little bit more uniform with the spacing.
Yeah, yeah, for sure.
For sure.
And then an article that just came out recently, it was, I don't remember the title exactly,
but it was something like Python slow and I don't care.
And the idea was, we should be optimizing for the programmer in a lot of cases, much more
than we should be optimizing for high performance or close to the metal.
Do you think that's kind of happening in like small hardware type stuff?
Like Python is making it more accessible and that's way better than making it, you know,
10% faster or something?
Yeah, I totally agree.
And it's definitely a big priority, I think, of, yeah, making things easier to create and
understand, especially with a lot of devices and things that are coming out today.
You know, the big buzzword is the Internet of Things, IoT, where every device has to be connected
to the Internet for better or worse, unfortunately, in some cases.
But, you know, in those cases, you're usually talking to like web services and dealing with
like parsing a lot of data.
And so writing that kind of code in C and C++, it's doable, but, you know, it's almost like
a field of landmines where it's very easy to have like buffer issues or it's sometimes
just really cumbersome to like parse JSON data, for example.
But that's where a language like Python is great because you've got a lot of libraries that
you can use or just the syntax can be a little bit simpler.
So I think that's where we'll start to see Python really shine is that when you have these
more complex applications where, yeah, you don't really care about sending, like controlling
some signal at some super high speed and when you do care about that, you know, there are
ways that you can say, oh, well, we'll just write that code in C or C++, put the performance
critical code in a language that makes sense for that.
But then all of your business logic, all of the things that you care about, all of how
your application wants to work, do that in a higher level language so that it's a little
easier to understand, easier to change.
You know, you can build your minimum viable product or whatever.
You can iterate on it a little bit faster with it.
So, yeah, I think it's definitely an important thing to consider with Python is that you have
that simplicity that helps you do things faster when you don't necessarily need like that
super critical hardware speed.
Right.
The speed of innovation might be more important than how fast your nest can report the temperature
or whatever.
Exactly.
Yeah.
So what do you do day to day?
You work at Adafruit, right?
Yeah, exactly.
Right.
So I work for Adafruit and basically I, so my title is engineer, but I do a lot of things from
the software side.
So I have a background in software, but I did a little bit of hardware also in college.
I have a computer science degree, but did kind of a mixed computer engineering.
And basically I do a lot of the software and I originally started doing things with Raspberry
Pi.
So Adafruit builds a lot of hardware, a lot of educational hardware and sensors and boards
and, you know, things like lights that you can control or motors that you can move around.
But a lot of that stuff wasn't, well, it was originally written or created to work with platforms
like Arduino, which are these little microcontrollers that you program directly.
But then things like the Raspberry Pi came around and we'll talk more about that later,
I'm sure.
But the Raspberry Pi is a platform that's more of a Linux based system that you can run actual
CPython on, on that system.
And so maybe three or four years ago or so, I came around, I was doing a lot of stuff for
Adafruit and they brought me on to help port a lot of the drivers that they had in the
Arduino world to the Raspberry Pi.
So to convert that code from C and C++ to Python code.
So I did a lot of that and then just got a lot more involved in kind of the products that
Adafruit creates and, you know, helping to support them.
So yeah, the day-to-day for me is doing a lot of things like usually there's certain projects
that we're working on.
You know, there's maybe a lot of things in like the Raspberry Pi world, like drivers to
write or to support.
There are a lot of projects that we do also because a big thing that Adafruit does is teach
people how to use stuff.
So we show people, you know, it's not just good enough to sell you a board that lights up
and does things.
You have to understand how to use that and how to control it yourself.
And so we create a lot of different content, like guides and tutorials that walk you through
how to use a product, but they'll even walk through concepts of like, okay, here's how
temperature sensors work.
And here's how, you know, maybe you calibrate them.
And here's how the equations work to convert the raw data into temperature reading and things
like that.
So it's just a lot of interesting, you know, knowledge to share that helps people learn
and they can kind of build on that knowledge to build different things and do their own
projects.
So yeah, I'll do guides and things.
And then in recent years, we've gotten into video because that's kind of become the new
medium as far as like how people learn things.
You know, the internet started out just as a text thing.
And nowadays, you know, like Netflix, I think it's like 90% of all the bandwidth on the internet.
So video is such a critical thing that, you know, we're there on YouTube and actually Twitch
and some of these live streaming platforms too.
So I do some of those things too.
I do some videos.
I try to do like a video every week, just kind of showing off maybe things that I'm hacking
on.
Or if I did like a guide or tutorial, kind of walking through how to do that.
So yeah, it's a lot of kind of showing people how things work.
Yeah.
That sounds like a really fun job.
So I heard just the other day that YouTube is the second largest search engine on the
internet.
Oh, wow.
Bigger than Bing, bigger than Yahoo, bigger than, you know, a bunch of others, right?
There's Google and then there's YouTube.
And so, yeah, for the kind of stuff that you're doing, you definitely want to be putting your
guides there and whatnot, right?
Yep, exactly.
Yeah.
It sounds like a really fun job that you kind of get to see what people need to know
and then just like come up with these little projects for them, right?
Yeah, no, it definitely is.
I would definitely consider it maybe like a dream job in some ways because yeah, it is
really cool to have a lot of kind of freedom to build things that, you know, are interesting
to me.
And then, yeah, to show people how I build things.
You know, I kind of think of myself in some ways as like, if you remember Bob Ross, who did
the joy of painting, you know, do these instructional videos on PBS and he had the amazing
hair, the Afro.
I don't have the Afro, unfortunately, but I kind of think of myself and this is, you know,
I don't want to be too presumptuous, but, you know, I think of myself in some ways as a Bob
Ross, but more for code.
So like showing people, you know, how do you do this project?
Or for example, I'll do like videos maybe that show how I convert a driver to run on the
Raspberry Pi and how to write it in Python.
And I like to show kind of that process of creating that driver and show like even the
mistakes and things that happen as I code this up.
And, you know, I get some of the math wrong.
And so you can watch me fidget around and figure out like debug this thing.
Because, you know, I think back to when I was learning and it was so hard to just understand,
you know, to make that leap from beginner to more experienced programmer.
Because back in my day, you know, early days, the internet, it was like, you'd be lucky to find maybe a text file or something that explains how something works.
You know, you'd be going to the bookstore and reading these three, 400 page books and hoping to understand things.
You know, whereas now I'm hoping that maybe, you know, the 13 year old me kid out there could watch me and hopefully learn a little bit and kind of see like, okay, yeah, this is how I can get into programming or how things can work for this.
So, yeah.
Yeah.
It sounds super fun.
Super fun.
So let's talk a little bit about microcontrollers.
So you said that there's Arduino, which is a microcontroller.
And then there's Raspberry Pi, which is more like a computer on a board or something like that.
Right.
What's the difference?
Like when would I know to call which?
Because I didn't.
Yeah.
I didn't study hardware in college.
I studied, you know, math and programming, right?
So good question.
And the honest answer is it's kind of a gray area because, you know, when you get down to it, they're both really similar.
So like the computer that, you know, that people are using right now, like if you're listening to this on your phone or on your desktop computer, on your laptop, you know, that has a little CPU that just runs instructions.
And so a microcontroller is the exact same thing.
It's just a tiny little CPU that runs program instructions and it can do math.
It can do all kinds of processing.
But the big difference is usually that the microcontrollers are much more constrained.
So they have much less memory.
So your computer or even your phone, like I think the new phones these days have like four gigabytes of memory, which is kind of insane to me.
You know, you have a lot of resources like that, whereas a microcontroller, an Arduino has, for example, two kilobytes of RAM.
So that's a huge difference as far as just the amount of things that you can store, the program state you can have.
And then the processing speed is usually a lot different, too.
So an Arduino is usually like 16 or 8 megahertz or so, whereas, you know, your phone or your laptop, your computer is well into the multiple gigahertz, three, four gigahertz sometimes.
So there's a big difference there.
And there are some other differences as far as your computer is usually built to run an operating system, which is kind of a layer that does a lot of work for you.
So it can talk to your peripherals and it can control access to a lot of things.
Whereas on a microcontroller, you're usually doing things what they call bare metal, where you write your code and it might be in a higher level language like C or C++, but it gets compiled down into the raw assembly language that just controls that processor directly and has complete control over all the memory.
There's nothing stopping it to say, hey, stop your program for a little bit to let another program run.
You know, whereas on your desktop computer, you've got all kinds of programs running for that.
So it's kind of a spectrum.
Yeah.
And that, you know, the Raspberry Pi is maybe on one end where it's the more computer style where you have a full Linux operating system and it's running multiple programs and you have a little bit less direct access to the hardware.
You still do have pretty close control to the hardware.
But I mean, ultimately, there's maybe some control that you give up in that case.
Whereas with Arduino, yeah, you've got a much less powerful microcontroller.
Sometimes in a lot of cases, they're a little bit less expensive, though, because of that.
And so you've got less power, less memory, but more control over the hardware.
So your code runs directly on the CPU.
And you can know, for example, if you write a loop, how long it's going to run and, you know, that nothing's going to stop it or keep it from going.
Right.
Basically, your program, it's the whole thing, right?
It has access to the hardware.
It just runs and there's nothing.
There's no other preemptive multithreading or anything like that, right?
Exactly.
Yep.
It's the only thing that chip knows how to do is run your program.
Oh, very cool.
So which one would you say is easier to work with?
Ah, that's a great question.
So, you know, there are advantages to both.
In the microcontroller world, for the longest time, it was a little bit hard to get started,
especially before these platforms like Arduino came around.
Because in a lot of cases, those microcontrollers sometimes have very custom or specific tool chains
where you couldn't just pick up, you know, the GCC compiler years ago and use that to write code for the processor that Arduino uses.
You know, nowadays you can because they've added support to those platforms.
But for a while, you had to get these custom tool chains and you'd have to figure them out.
And they'd usually be more constrained and you'd have to know how to set those things up.
So it was a big barrier to entry.
And then platforms like Arduino came around and said, hey, let's simplify all that stuff.
And let's just give you this prepackaged environment, like a little IDE that you can download that does all that for you.
So you just write in your code and you still have to use kind of maybe those higher level or the C and C++ style languages, but we'll make it easier.
So it's not as hard to get started in microcontrollers, whereas something like the Raspberry Pi that runs Linux,
if you're already familiar with using Python on your desktop, just installing the Python, the CPython interpreter, it's really similar on those platforms.
And so it's just, you know, learning, OK, how to hook up this Raspberry Pi and maybe how to connect to it.
And then once you're connected, it's no different from your computer.
So, you know, if you have absolutely no hardware experience at all and you're used to Python on your desktop,
the Raspberry Pi might be a little bit easier to get started with, but Arduino and those systems aren't as bad.
The one difference with Arduino, though, is that the language is different.
So it's, you know, you have to use C and C++, but it's a little bit easier when you use some of the systems that give you,
you know, here is a development environment that's kind of ready to go for that.
So, you know, I'd say start with Raspberry Pi, but also look at things like Arduino and MicroPython also that I'm sure we'll talk about,
you know, how to get into Python on some of these little microcontrollers.
Yeah, absolutely. I mean, the devices are interesting, but to the Python audience, it's like, OK, well, how do I use Python on this device?
Right. So back on episode 17, almost two years ago, I talked to Damian George, who was one of the guys that created MicroPython.
Maybe tell us a little bit about what that is.
Yeah, totally right. So MicroPython, it's a really cool project.
And yeah, like you said, it was created by Damian George, I think maybe four years ago in 2013 or so.
And it's basically a Python interpreter that runs on these small memory constrained environments,
like little boards that might be used with Arduino.
Now, it doesn't run on what is typically the Arduino that everyone uses, the Arduino Uno.
That's a really low end. That's the one with two kilobytes of memory.
It runs on a little bit larger microcontrollers.
So microcontrollers that have around like 32 kilobytes of memory or so, or even much more in some cases.
But it is a Python interpreter. And the nice thing is, it's not the first Python interpreter that runs on hardware.
I think there have been a few other embedded Python projects, and there still are some other ones around.
But one of the big goals and things that kind of separates from other Python on hardware implementations is that it tries to be a very strict implementation of the Python 3.0 core language.
So basically, you know, all of the features that you would expect in Python as far as like classes and functions, you know, just the basic syntax.
Most pretty much all of that is there.
I think something like 90% of it is implemented and they're working on getting more support.
So that makes it really cool as a Python user because you can kind of dive in and there are less surprises.
You know, you do things that are a little more natural and it's, in most cases, works.
The one thing I should say, though, is that not all of the Python library is implemented, though.
So things like all the things that you've probably come to know and love on the Python world of just being able to import a JSON parser or, you know, import like a CSV parser or something like that.
Some of that stuff is there in the MicroPython world.
But again, these run on these tiny little microcontrollers that just have kilobytes of memory.
So you have to make some tradeoffs there, unfortunately.
Yeah, that's a pretty serious constrained environment compared to, you know, 16 gigs of RAM.
Exactly.
Yep.
And it's just different priorities, right?
So how do you get Python to work in that kind of a world with much less memory?
So you basically put this on one of the microcontrollers, you put your Python code there, and then your Python code basically is the only thing running on that chip, more or less, right?
Exactly.
Yep.
So there's not necessarily like an operating system that's running.
Your code is actually it's compiled into a bytecode internally by MicroPython, and then it executes that bytecode.
So it can be very dynamic and do all kinds of cool, fun kind of Python things.
Nice.
Can you pip install to it?
A lot of that stuff is being kind of figured out in the MicroPython world.
So like I said, MicroPython is still pretty new.
Like it's only maybe four years old, which is actually really new in the grand scheme of things.
And so there's not a super solid story yet on like libraries and modules.
So MicroPython does have a concept of it supports packages where you can have a folder structure within a init.py,
and you can have, you know, modules and things that you import based on that.
And you can actually do this pre-compilation step where you convert a Python file into what's called an MPY file,
which is just pre-compiling it into bytecode because, again, it's optimizing for the memory usage.
Because if you're just storing the raw Python source code of your program, that's pretty large.
You have, you know, big text files.
And so if you're trying to fit a bunch of Python code onto like 256 kilobytes of flash memory, you're going to run out at some point.
And so there are little optimizations you can make like pre-compiling some of the stuff into bytecode.
But yeah, there's no pip.
Well, there is a pip for MicroPython, but it's not the same pip that you might expect on the desktop.
So it's not like you connect to your board and run a pip command and it goes to the internet and downloads your package.
It's more on your desktop.
You can grab these MicroPython libraries and then you still have to kind of get them onto your board and import them yourself.
So it's, I think in the future, though, there'll probably be more of a story for how, you know, you get packages and things.
But again, in the MicroPython world, they're definitely, they're trying to follow the Python kind of paradigms and systems out there.
And so, you know, using things like PyPI and pip and the tools like that to make it work.
This portion of Talk Python is brought to you by Advanced Digital.
How would you like to build one of the most visited news sites in the U.S.?
That sounds fun.
The folks at Advanced Digital would love to talk to you.
They're primarily a Python shop located in beautiful Jersey City, just one subway stop from lower Manhattan.
Spend your time building an amazing web app with Python and do it with a small team of developers focused on agile development.
Are you going to miss PyCon this year because your company wouldn't fund the travel and expense?
If you join this team, they'll cover your conference and training initiatives.
It's time to take your Python to the next level.
Build an amazing web app.
Get started by visiting python.advance.net right now.
One of the things that Damian talked about was that you could basically hook a Lambda expression directly up to a hardware interrupt.
And that kind of blew my mind.
Yeah, it's really cool.
I love it too because, like I said, with Python, I love how you can make it work the way you want.
So if you want to do like really cool functional programming, you've got all of the constructs to do that in Python.
You've got like filter and map and all these cool functions you can chain together and stuff and do reactive programming, whatever.
And it's fascinating to transfer that over to the hardware world and start playing with it.
Because at the end of the day, I mean, hardware, it's just a different set of functions you're calling.
Like you're calling functions to control the voltage of an output or to read an analog input or something like that.
So having that core language and, yeah, doing Lambda expressions with hardware interrupts, I mean, it is a really cool thing.
And again, because it's so interesting to me because for the longest time, we really haven't had that in the hardware world.
You know, you've had the lower level languages like C and C++ that are very static and everything is done up front ahead of time because you need it optimized for memory and stuff like that.
So, yeah, it's kind of a brave new world in some ways of figuring out like because, yes, you can hook up a Lambda expression to a hardware interrupt.
But, you know, maybe we'll learn like, well, maybe you shouldn't.
You know, maybe there are reasons why it maybe doesn't make sense or it gets too complex or something.
But that'll be fun to figure out what works and what doesn't work.
Yeah, absolutely.
It's being new.
It really makes it exciting as well.
When would make a lot of sense to use MicroPython and when would you maybe pick something else?
MicroPython, it's good at some things and it's maybe not as good as at other things right now in the world, in the embedded world.
Because, again, you can't get away from the fact that you're running on a much more constrained environment.
So you have much less memory than your desktop computer.
So things that you might do in the Python world that you might not even realize take a lot of resources, you know, like having a tight loop that's creating a bunch of objects, which might just be a few lines of Python code.
You know, you might not even realize what's happening underneath the behind the scenes there.
That might not be great in MicroPython because, sure, it can run that code, but it's going to be allocating a lot of memory.
And then you're going to be having this garbage collector kicking in and things.
So MicroPython, it's really good at, like I said, doing the high-level business logic of, you know, I'm creating like an IoT device.
And I need to talk to a web service and get some data and process it and then maybe actuate some devices or maybe read some sensors and then send that reading up into the cloud.
So it's really good at being kind of that glue that goes between the low-level hardware and other different things that you're doing.
So it's great for that kind of thing.
It's also great for, like, when you want to update and change how something works.
Because, again, it's all interpreted code, so you can change the code on the fly.
You know, if you want to change how your program runs with, like, Arduino or C and C++ or older kind of embedded-style programming,
you have to, like, connect that board to your computer and just completely reprogram it.
Whereas with MicroPython, you know, if you can just change that Python file,
and it could even just be, like, downloading that file from the Internet itself.
You know, you could send new code to the board and it can start running it.
And actually, that's a cool use case that I heard about recently.
I think the European Space Agency, they've been looking at MicroPython and potentially going to use that on satellites
because they like that idea of being able to send new code up to the satellites and have it just run that code
instead of having to reprogram the satellite while it's in orbit.
Because sometimes things go wrong.
You know, you're writing a flash memory and something might get corrupted.
And so I think they like having that kind of capability.
And so you can do that with MicroPython.
And then the other cool thing, too, that you get because it's interpreted, you've got a REPL.
So you've got an ability to just connect and arbitrarily run Python code.
And so that's a really good case for, like, education and learning.
And something I think that we'll see a lot with MicroPython,
where it's a lot easier to learn about things like hardware
when you can just connect to your board and run a function that says turn on this LED
or turn off this LED or read this microphone value.
And you can get that result back directly and kind of play with it
and, you know, maybe build little programs from that.
So, you know, MicroPython is really good at that stuff.
Yeah, that sounds so much better than I'm going to recompile and ship a new binary
and restart the device and all that kind of stuff, right?
Exactly right.
There's just more steps, more complexity.
And especially for people that are learning things, it's, you know,
it's difficult enough to even just understand how the tools work and things like that.
And so just the less things that you have to learn, the easier it'll be
and the more it opens up to more people to use.
Oh, yeah, that's really great.
And could you have the device auto-update itself
or the Python auto-update its own code on MicroPython with over-the-air updates type things?
Yeah, you definitely could.
So, and there are a few different things you could do.
So kind of the way MicroPython works is there's an interpreter,
like a firmware that's written onto the chip that has the implementation of MicroPython.
So it has things like how it converts your Python code into bytecode and how it executes that
and how it turns your Python functions that might talk to hardware,
how those actually access the hardware.
And then there's actually a little file system that MicroPython adds,
which is one of the cool things that it does differently, you know,
or maybe that's an advantage over systems like Arduino.
In MicroPython, there's a little file system that all the boards have,
and it's just like a fat file system.
So you can put .py files on there, but you can also put like text and data files on there.
And so that's a case where, yeah, if you want to change your program code,
you just have to figure out a way to update that file system.
And you can usually write to that file system using all of the same Python functions,
like open, read, write.
So you could build a project where, you know, maybe it looks to a web service
to download its latest code and it can see, okay, what's the version of my code
and grab the latest code and update it.
And so that would update your Python code.
And then updating the MicroPython firmware itself, it's a little more challenging.
There are ways to do that.
Some boards and systems support this concept of, you know, doing an over-the-air update.
It's usually a little more complicated because when you're changing the firmware itself,
you sometimes have to have like two copies of it,
and then you tell the microcontroller to kind of swap over.
Yeah, I was thinking more of just your code, right, and just letting the MicroPython be.
Exactly, yeah.
And it's great for that because it's just a .py file.
And so if you've got a way to tell the board to update that file,
then it's, in a lot of cases, it's as easy as that.
I'm thrilled to hear that the European Space Agency might be using it.
How cool is that?
Yeah, Python in space.
That is just too cool, I think.
I think, yeah, really, really neat.
Yeah, you know, you hear about the thing is not responding,
this rover is lost because, you know, something went wrong with its software and whatnot.
This ability to go, we're going to ship you a few bytes of a new PY file,
and you're going to come back to life.
Like, that's pretty cool.
Yeah, oh yeah, totally.
And, you know, maybe not too far off in the future,
maybe it'll be something that we could even do ourselves.
You know, they've got cube satellites,
and maybe when, you know, you've got kind of private enterprises sending shuttles and rockets and things up.
And maybe one day there'll be a Raspberry Pi that I can send up and start, you know, controlling myself with Python.
That would be really fun.
Yeah, hook a little camera to it.
That'd be awesome.
Oh, yeah.
All right, so that's when you, when it's a good idea to use it,
maybe when would you say probably not the best option?
The one big thing, though, with MicroPython is, again, it's interpreted,
so you do pay a cost as far as performance goes with that.
And it's a significant cost in some cases because, yeah, these little microcontrollers,
they run at like, you know, maybe 80 megahertz, 40 megahertz or so.
It's like a 486DX.
Yeah, exactly right.
So the kind of computer, when I got started programming, I think it was a 486, it was 50 megahertz.
And even that's probably faster than some of the systems we have now.
So, yeah, for a lot of people today that maybe got into programming later,
they might not realize that computers back then were pretty slow.
So that could be a little bit of a shock to some people where,
especially if you've done things in Arduino, like blinking LED, you have a little loop,
you turn it on, you turn it off, you sleep in between there.
You try the same thing in Python and it might not work as well,
or at least it might not go as fast as Arduino.
So things that are timing critical, where like you're trying to generate a signal
that maybe tells some hardware, you know, like talking to a servo,
you need to generate a signal that has a very specific pulse width,
or talking to a lot of these RGB LEDs, these NeoPixel strands.
They need a very specific pulse train sent to them.
So that type of stuff is more difficult with MicroPython because you've got less speed because it's interpreted.
And so that just means that rather than your code running directly on the CPU,
you've got code on the CPU that has to load your code from memory and then figure out,
okay, what is it doing, and then actually convert that into CPU instructions.
So there's overhead with that.
And then there's also a little sometimes overhead with the memory management where,
you know, in the Python world, you don't worry about managing memory because Python does that for you.
But in the embedded world, when you're in this memory constrained environments,
it doesn't come for free.
Like there's no magic wand.
You know, just when MicroPython manages your memory, it might not manage it the best way.
You know, it might be creating and allocating memory,
and then it has to go clean things up.
And so that takes some time.
So anyways, long story short, things that are timing critical are more difficult in MicroPython.
Things that need that direct access to the hardware sometimes are more difficult.
But it doesn't have to always be the case.
I guess I say more difficult, but I don't really mean that it's impossible to do that stuff
because the really cool thing that MicroPython did is make itself very easily extensible
so that you can combine both C code and Python code in the MicroPython firmware
so that when you need to do that advanced signal generation,
you know, you can drop down to a C function that you implement that does that
and has very critical, you know, loop code and things like that
and very tight constraints on like how much memory it uses.
And then you can just expose that as a Python function.
And it's very similar syntax to how you do C extensions in desktop and CPython.
So yeah, that was my next question.
That sounds like, you know, there's your escape hatch for those little parts that are really critical.
Exactly. Yeah. And I think that kind of plays back to the really big advantage of MicroPython
of, you know, getting to that world where you do your low level interface logic
and all that performance critical code in C
and then do all of your business logic and all that interesting stuff.
You know, the things that make your smart device smart,
do all of that in Python and you get all the advantages.
You know, you get both advantages.
You get maybe easier, faster to iterate in the Python code,
but then all the low level and fast control in the C functions.
Nice. So let me run some examples by you.
And you tell me if like good or not good for MicroPython.
So if I was like a farmer and I wanted to have like an automated irrigation system
or something that managed, like watched the pH level of all my dirt around all my plants
and reported that back and maybe, you know, controlled valves for more water or whatever.
Right. It seems like something like that would be totally fine for MicroPython.
Yeah, I think that'd be great.
That's a good option because you're talking to little sensors.
And in a lot of cases, those sensors have kind of standard interfaces.
There are some protocols.
One's called I squared C or another one's called SPI.
And so MicroPython has a lot of good support for that.
And your hardware itself kind of generates those signals and knows how to talk those protocols.
So, yeah, it's easy to hook up external sensors in a lot of cases and just talk to those directly from MicroPython.
So, yeah, that's a great case.
And then when you want to report back to some central service, it's amazing because you've got, you know,
all of the great Python syntax and fun things you can do there.
So, yeah.
Okay.
That sounds really awesome.
What if I wanted to outfit the front of my drone with a camera?
I don't have a drone.
My brother has a drone, but I don't.
With a camera.
And when it saw like another drone, it would change color or something like that.
Like almost like an image recognition thing or, you know, something like that.
Would that make any sense?
Yeah.
Well, so that's a good case.
Drones are interesting because, yeah, with the drone case, you know, maybe that case of like recognizing a thing that you might be able to do that MicroPython.
That would probably be a little more challenging just because when you get into like advanced image recognition stuff,
you probably want to use something more like a Raspberry Pi where you can use like OpenCV and some of these really powerful and amazing image processing libraries.
Because you probably don't want to have to like, you know, hand code a neural network or something in MicroPython yourself.
Yeah, exactly.
But if I want to use like TensorFlow or something, like it obviously wouldn't make any sense, right?
Exactly.
Yeah.
So, you know, use, yeah, use the tool for that.
But then the other thing with the drone too, you might think like, well, could I have the drone, you know, the code that controls the motors?
Could that be in MicroPython?
Like that's controlling the actual flight of the drone.
And that might be a case where you wouldn't want to use MicroPython because that's a very critical control loop where you need a lot of speed.
You know, you need just milliseconds and microseconds of the sensor detected.
I'm tilting slightly.
So now I need to offset this motor and make it spin a little bit faster.
And if you've got a loop in Python that has all this interpreter overhead, that could be the difference between, you know, your drone crashing or it staying in the air there.
So, you know, that's maybe a case where you wouldn't want MicroPython to do that really timing critical control loop.
Right.
Okay.
But maybe if it was a Raspberry Pi, I could do like a C extension in there.
Right.
Something like that.
Some combo.
Exactly.
Yeah.
And actually, there's a board that's even better for drones these days.
The BeagleBone boards.
BeagleBone Black is one because they're kind of cool.
They're like the Raspberry Pi, but they add a little microcontroller that sits alongside the main processor that runs Linux.
So you can run code on there that the Linux operating system doesn't even touch at all.
And so that's where you put your little super critical control loops and things like that.
And then your Linux processor can communicate with it and send it instructions and things like that.
So, yeah, lots of options in that case.
That sounds really cool.
So what other hardware could I use MicroPython on?
Yeah.
So great question.
So, again, it's a little bit new.
So it's only four years old.
There's just maybe a handful of boards right now that support it.
The original board was called the PyBoard, and it's a pretty powerful microcontroller.
It's this STM.
I think it's an F4.
It's basically a fancy processor.
It runs at a couple, I think, like 70 or so megahertz, something like that.
That was kind of the first board.
It has a lot of peripherals and features.
And then the ESP8266 is another board that came around, and this is a really popular board.
It started out as the brains behind an internet-connected light bulb.
And then the company that created it, they released, I think, the developer tool chain.
It's a company called Espressif.
And they realized, like, oh, people kind of like hacking this thing.
And, like, this is cool.
Because it was just a little microcontroller with a Wi-Fi radio.
So, you know, it could run code that talks to your Wi-Fi network and web services.
And so people kind of ran with that, and they integrated it into Arduino, and, you know, people take a lot of control over it.
But that became a platform for MicroPython.
There was a big Kickstarter for it a few years ago.
And that became a really great platform for MicroPython because it's the ESP8266 has a good amount of memory and has that Wi-Fi chip, so you can do lots of cool stuff.
So that's a great chip.
And then let's see.
There are some other boards, the Wi-Fi and the Low-Py and some of these boards that Pycom creates that are basically similar to, like, the ESP8266, more Internet of Things oriented.
But they're also, you know, kind of moderate amounts of speed and performance and things like that for it.
And then I think the last board that's really interesting that we're probably going to see a lot more of these types of boards are the MicroBit.
So the BBC MicroBit was this really neat little board over in England that they gave to, I think, all of the seventh grade students in the country.
So, you know, they made, like, maybe millions of these boards or hundreds of thousands of them.
And they're little boards that have these tiny little microcontrollers that are a little more powerful than an Arduino, but not much more powerful.
I think they only have, like, 16 kilobytes of memory.
And there was a really nice effort to port MicroPython to run on those boards.
And the cool thing with the MicroBit is that it's not just the microprocessor.
It has a few peripherals.
So it has some LEDs.
It has some buttons and things.
And the idea with it was, you know, you give this to a kid who's learning programming and they can get started right away.
They don't have to learn, like, how to solder all this stuff together or how to install a tool chain.
They make the tools really nice and easy.
And that's a really cool fit with MicroPython because with things like the REPL where you can just connect to the board and start running Python code.
And the MicroBit, it's even cooler because you just literally pick up this board, plug it into your computer, connect to a terminal, and then you start typing Python code.
And you're turning on LEDs and you're, like, controlling a speaker and you're making it, like, say things and listening to microphone stuff.
That's really cool.
Yeah.
But does it ship with MicroPython?
It does not.
I don't think it ships with MicroPython, but it's really easy.
They have a web editor.
I think you, if you just search online for, like, the BBC web editor, you go to a web page and it will give you, like, you type in your Python code on the web page and you click a button.
It gives you a file and then you just drag that file onto the board.
Like, the board shows up as a USB drive and it programs itself based on that.
So it's really easy to get kind of MicroPython going on it.
This portion of Talk Python is brought to you by the Strangelube Conference.
Do you love to present technical topics?
Are you looking for your first major speaking event?
The Strangelube Conference just announced their call for proposals.
Whether you're interested in languages, web development, distributed systems, AI, security, or something else, be sure to submit a proposal to Strangelube by May 8th.
Their opportunity grant applications for developers in underrepresented groups.
Last year, they were able to grant travel, hotel, and admission for 115 attendees, and they're hoping to expand on that for 2017.
Don't just attend the Strangelube Conference.
Submit a talk and you'll be speaking at a beautiful venue in St. Louis, Missouri, September 28th to 30th.
Visit talkpython.fm/Strangelube to submit your proposal.
Hurry.
It closes May 8th.
So, one more hardware question for you.
One of my, well, I'd say my favorite smartwatch is the Pebble Time Round.
And, you know, really thin, really small, little lightweight smartwatch.
And those guys recently went out of business, which is a super sad story across the board.
But could you build something like that?
Like, could you build a smartwatch type thing with MicroPython?
Oh, yeah, definitely.
And I think that would be a great project with MicroPython.
So, you know, like, if you just think of the components of the smartwatch, it's pretty straightforward.
I mean, you've got your processor.
You have a display of some sort.
And most displays have a standard interface, like either this I2C or SPI protocol that most of the MicroPython boards support.
So, you could get, like, a little OLED, an organic LED display.
Or there even are e-paper displays, which are the really nice kind of, like, the Kindle style or what the original Pebbles used.
Yeah, the Pebble Time Round has, like, a color E-ing.
Exactly, yeah.
So, you could get one of those displays.
And that talks usually like an I2C or an SPI protocol.
You'd have to figure out from the data sheet, you know, like, what are the commands to send it and things like that.
But that would be perfect.
That's easy to connect to the board.
And then the actual clock part, you might want, like, a real-time clock connected to it where, you know,
these are little hardware peripherals that have, or basically little watches that just run off of a coin cell battery
so that, you know, your main watch might go to sleep just to save power.
But this thing will keep the time running so that it always knows what's happening.
And that's all you need for maybe a basic smartwatch or a basic watch.
And then, you know, if you use a board that has, like, a Bluetooth radio or a Wi-Fi radio,
then you can go crazy and add all kinds of things like, okay, you know,
I want my watch to connect to some internet service and pull down, you know, the weather or the time.
Or things like that from it.
So, yeah.
And that would be a great case for MicroPython, too.
Because it's, again, you know, you want to write all of that fun watch logic in, like, Python code.
But you don't want to write, you know, necessarily maybe, like, controlling the E-ink display.
Like, that's maybe not as interesting.
And so you'd maybe use a library or something like that or some C code, potentially, to talk to it.
Yeah.
And it would also have a great extensibility model.
You want to write apps for it?
Give a little Python file or something like that, right?
Oh, that would be too cool.
I mean, wouldn't that be amazing?
You just plug your watch into your computer and you just edit .py files on it?
That would be really cool.
Like, 13-year-old me would just be, you know, probably freaking out.
That would be so much easier than trying to figure out, like, I don't know.
It would be more interesting than, I guess, like, opening up QBasic and loading nibbles or Gorilla or something like that.
Yeah, for sure.
All right.
So let's move off of MicroPython just a little bit and sort of into the broader hardware world and talk about the company that you work for and what you guys are doing there with Adafruit.
So what is Adafruit?
Yeah.
So Adafruit, it is an electronics company that helps make electronics more accessible to people.
So it was founded about, I think, 11 years ago in 2005 by Lamore Fried.
And she goes by the handle Lady Ada.
Founded in her dorm room at MIT.
So she's a brilliant electrical engineer.
And really, the core DNA of Adafruit is showing people how things work, like, taking the mystery out of electronics.
So a lot of things that Adafruit did early on were things around, like, Arduino, or even before Arduino actually even existed, of, like, hey, I'm building, I'm an artist, and I'm making a really cool installation, and I need to control some of these lights.
I know how I want to animate them, but, like, I'm looking at all these wires, and what do I do now, and how do I make this stuff work?
And so Lamore did a lot of great stuff.
She had a website, LadyAda.net, where she would show tutorials that show, hey, here's how you program this little microcontroller.
Here's how you set up this crazy tool chain.
And, you know, make it as easy as just follow these steps, and you'll get this stuff working.
And it just built on top of that, because, you know, people realize, like, oh, okay, well, now I can program this microcontroller, but I want to connect it to things.
You know, I want to talk to this sensor.
And unfortunately, you know, for a while, it was difficult in that if you wanted to, you know, maybe use, like, a temperature sensor, well, you'd have to build a board that has all the supporting hardware for it.
Because you can buy the sensor, but when you read the data sheet for it, which, first of all, you have to figure out how to read data sheets, you know, then you realize, like, oh, man, I have to put this on a board, and I have to connect all these, like, components to it, maybe some capacitors or other things to it.
So then at that point, it's like, oh, uh-oh, now I have to learn how to make a circuit board.
So that's a little annoying and difficult.
And so Adafruit does a lot of things, like builds a lot of breakout boards, you know, to take some of those interesting sensors and things and give you a board that just does all that grunt work for you of, okay, I buy this board, and then it gives me these connections that I care about.
Like, you know, maybe the I2C or the SPI connection so that I can just run a few wires to my Raspberry Pi, and then you grab the code that we publish that knows how to talk to this device so that now you can just start running some Python code on your Raspberry Pi and dealing with it.
So, again, it's all in that pursuit of making electronics easier for people because we want to open it up and make it less of, you know, an electrical engineer's playground and more of a playground for anyone.
So that's the cool thing, and the thing that I get a lot of joy out of is just seeing what people do with this.
Like, you know, seeing someone who's an artist who's totally intimidated by, you know, hardware and circuits and thinking, you know, there's no way I can make this thing work.
And then building really cool interactive things or just, you know, things that blow your mind as far as, like, interesting art installations or even beyond that, like, things like students and learning and just hobbyists.
Like, I still love just the projects that people do of, like, hey, I have my barbecue grill and I want to build a temperature sensor to, you know, maybe control, like, the opening and closing the vents on it to, you know, smoke a brisket or something like that.
You know, just fun things that someone could do.
Like, sure, you could buy, like, probably a $4,000 or $5,000 barbecue that does that.
So I like the kind of do-it-yourself aspect of that, too.
And, again, Adafruit is all about helping people do things themselves and, you know, taking the mystery out of a lot of this electronic stuff.
Yeah, that's really cool.
That's a great mission.
You know, create more creators, right?
Exactly, yeah.
Limor was talking about open-source hardware at Adafruit.
And I can imagine what that means, but what do you guys think that means to you there?
Open-source hardware and open-source in general, again, is kind of a core of Adafruit because from the very beginning, you know, Adafruit was created to teach people how things work.
And so it wouldn't have been very successful if it's like, well, get this board, but, you know, if you want to know how it works, that's off-limits.
You know, we can't tell you that.
That's our secret sauce or whatever.
You know, we kind of realized early on that telling people how things work doesn't hurt.
You know, it helps you because people will just build on your thing and they'll use more of your stuff because of that.
But at the core, so open-source hardware, there is actually the Open-source Hardware Association, which has a concept.
I think there's like an official definition.
But the basic idea is, you know, you release the schematics and the build materials and how your device is built so that someone could replicate it themselves if they wanted to.
The same idea with software.
So, you know, something like the GCC compiler, you know, all of that source code is out there so that if you want to add a new language to it or whatever, you can take it and you can study it and you can extend it.
And all of that code is available for you to change.
Same thing with open-source hardware.
You know, if you want to build one of these little temperature sensor breakout boards, you can do that.
Like, you can get the design files.
You can see how all of the layout was routed and you can tweak it if you want or you could even just go and build it yourself.
You know, you're going to need like a big robot pick in place in a lot of cases to assemble the board.
That's, you know, maybe one of the advantages of getting it from Aterfruits is that we've done that for you.
Yeah, we don't want to constrain people.
We want to put it out there so that people can build on it and learn from it.
And, you know, the whole everyone kind of grows when everyone can kind of see how things work.
Yeah, that's great.
It seems to me like 3D printing would be a good complement to these kinds of things.
Yeah, definitely.
Well, especially for a lot of the projects that you see kind of in the maker world of, yeah, like I have, you know, maybe I'm building like a costume and cosplay.
And so I have some like cool, maybe like a sword that I want to light up or something.
And, yeah, being able to make some custom enclosure for it is really cool.
But, yeah, I love, too, just seeing with 3D printing, just people using it in different ways.
Like, again, like going back to the art aspect and building cool sculptures or things.
It's just fascinating stuff.
I think there's a lot more that we'll see with 3D printing.
But, yeah, 3D printing dovetails very nicely with microcontrollers and, you know, because you're building things.
And usually you want those things to move or to sense the world or light up or something like that.
So, yeah.
Yeah.
Yeah, at least to be in some kind of enclosure so it looks shiny and not just a bunch of wires, right?
Right.
Not the box of wires, yeah.
It might kind of scare airport security or something like that.
Exactly.
He has a bomb.
It's always difficult for me.
So I travel sometimes to Maker Faire.
And, oh, I always worry every time I go through.
I'm like, I just know they're going to look in my bag.
And I've got like this, you know, box of wires and just having to explain to someone what an Arduino is.
It hasn't happened yet, but I know at some point I'm going to have to do that.
It's coming.
Yeah, yeah, yeah.
So one thing I saw you guys have is the Adafruit Web IDE.
What's that?
Yeah.
So that was something in the Raspberry Pi world.
Basically, it's a program you can run on your Raspberry Pi.
And it gives you a little web interface to type in code and run it like Python code.
I think you can even access the file system.
It came about actually in the early days of the Raspberry Pi.
So the Raspberry Pi, I think it's about four years old now.
In those early days, you know, they initially were just had spent all their time getting this $35 computer out there and making it work and turning Linux into something that a beginner could, you know, reasonably get started with and use.
So there wasn't telling a sixth grader to fire up Emacs is probably not the way.
Exactly.
Yes.
And so early days in the Raspberry Pi world, it was still a little bit.
I mean, it was good.
Like they had a graphical interface, but it was maybe a little more difficult sometimes to just get going and start programming things.
So, yeah, we kind of created that as a way to do some of these early Raspberry Pi tutorials to show people like, OK, here's how you connect your board and here's how you start running code.
But nowadays, the Raspberry Pi Foundation, you know, they had a lot of time and they've grown quite a bit.
So they've done a lot more polish as far as like how you go from zero to starting running code.
I mean, they have their new pixel operating system, which is a really nice reskin of the Linux environment.
They've got some nice editors.
I think they're like graphical block based editors and things now.
So, you know, these days, maybe WebID hasn't been updated as much to, you know, or maybe you might be able to get more things from kind of what Raspberry Pi is doing.
But it was originally I just created as a way to get code running quickly on the Raspberry Pi for people.
Sure.
Very cool.
So one of the places that I really one of the things that Adafruit I really like is your learn.adafruit.com.
There's just all these projects and some of them are kind of like you talked about at the beginning, like here's how you understand batteries or displays or whatever.
But a lot of them are, hey, I made a really cool like thing for Halloween and here's how I made it.
Right.
These projects that you you could make or take and customize.
Right.
Yeah, exactly right.
And there's a ton of things.
I think I just checked.
There are 1200 tutorials on the Adafruit learning system.
So there is an immense amount of things there.
And yeah, you're right.
Like it falls in a lot of different categories.
So like every product usually has a guide that goes with it that just shows you, okay, here's what you do when you get it.
Here's how you might have to solder some things to it.
Or here's how you download the software to get started with it.
But then, yeah, like you said, there are lots of projects that just serve as like sometimes as inspiration.
Like, hey, this is cool.
Like, you know, the GPS dog collar, you know, maybe I want to make a cat dog collar or something like that.
So I can, you know, take some of the same code and ideas from that.
So, yeah, inspiration is a good thing for it.
You know, and yeah, just kind of showing off cool things you can do with the projects.
There are also some guides that, yeah, teach the basics, interesting things.
You know, there's one guide that kind of tells you how to do sensor readings and analog readings.
It seems like a boring topic of like, okay, how do you read an analog to digital converter?
And then how do you smooth out the data to make it maybe not jump around as much and stuff like that?
And so, you know, there's a guide to learn stuff like that, which sounds boring,
but it's actually like a really kind of critical thing that you need to learn when you deal with these analog things.
So, yeah.
So we span kind of quite a broad range.
You know, there's, I don't think I know of any case where, you know, we've looked at something and said, no, that's not a guide or something.
You know, there's almost anything we can turn into a guide because it's, you know, it's either teaching someone how to do something or it's showing how a product works or just giving inspiration.
Like some of the guides and projects are really advanced.
Like, you know, there's some of these light painting projects where like the Raspberry Pi light painter, you know, you take a wand of these RGB pixels.
And when you wave it around, you can do the persistence of vision effects where, you know, if you light up the pixels in a certain time and then you have a camera that has like a long exposure, it can kind of average out the movement.
And so you can see really cool things floating in the air.
Like, you know, it looks like an image floating in the air.
But some of those projects can be a little more advanced to build, you know, might require like more kind of difficult soldering and stuff like that.
Sure.
So, you know, everyone might not want to build those, but just seeing that like, wow, that's really cool.
I had no idea that I could make something that looks like that, you know, maybe inspire you to do something a little bit simpler or, you know, more capable.
Yeah, that sounds awesome.
I've picked a few that I like.
I'll read them off just so people kind of get a sense for what's up there.
So one that you guys had was an onion pie, P-I, not P-Y, which was like a took a raspberry pie and made it a Tor proxy, which is kind of cool.
A GPS dog collar for your dog's fitness.
LED bicycle things, wrap it on your bike and it can light up in certain ways.
A DeLorean time circuit, a raspberry pie streaming radio for like Pandora type stuff.
There's a couple of Halloween things like costumes and whatnot.
And I think my favorite was a solar charging handbag, which is pretty cool.
Oh yeah, that's a great one.
Yeah, I love, I love those projects where it's the kind of thing where, you know, you could see that being a commercial product, like something that people would probably pay hundreds of dollars for.
And just, you know, with a few dollars of components, you can build it yourself and customize it, make it the way you want.
Like if you want a cool design or whatever, if you want to put it into some really neat, funky bag that you have, you can do that.
So yeah, it's great stuff.
Yeah, that one was cool.
That's one of the things like I could see myself using that GPS dog collar.
Interesting, but probably not.
Yeah, yeah.
Right, right.
So what are the common, a couple of common.
things you see created with Adafruit hardware?
I think there are a couple standout projects that are, you know, very Adafruit, I don't know, has Adafruit DNA in them for sure.
The Pie Girl, which is basically a Raspberry Pi that you put into a 3D printed enclosure that looks like a Game Boy, like a portable game plane unit.
And you add a little display to it.
We have a display called the Pi TFT.
It's a real low cost display that you just snap onto the Raspberry Pi.
And it's cool because it gives you what looks like a Game Boy.
So you've got, you know, your direction pad and a couple buttons.
But because it's a Raspberry Pi, you can run any games and emulators and things that the Raspberry Pi has.
So you can play like old Nintendo games or Super Nintendo games and stuff like that on there.
And so that one's, yeah, that one's super popular.
Can I play Pitfall on it?
Oh, yeah, you can definitely play Pitfall.
You can play, you know, the 2600 version.
You can play the Super Nintendo, whatever versions of it.
So, yeah, lots of options there.
Another one is the Cupcade, which is a mini arcade cabinet with the Raspberry Pi.
And this one's fun.
Like both of these actually, I've seen kind of commercial projects now.
Like I think I was just in a Target now recently.
I saw this tiny little arcade cabinet that reminded me of this Cupcade project, which now is, I think, like three or four years old.
But it's a little miniature, like, you know, an arcade cabinet.
Like you might imagine a Pac-Man cabinet with a little joystick and a couple little buttons.
But, again, it's got that little Raspberry Pi behind it in the display.
And so you can run a full emulator.
You can run all kinds of arcade games.
So, you know, those are definitely really popular projects.
Like things that use Raspberry Pi are really popular because the Raspberry Pi community is really large.
But, yeah, we're really well known.
We did a lot of things with wearables.
So we have some different boards that are great for like sewing onto clothing and controlling things like lights and sensors and stuff like that.
So we have fun projects like that.
Nice.
Yeah, I saw you had made, I saw some picture where you had one of those arc reactor type things from Iron Man.
Yeah, exactly right.
So I was at the Emerald City Comic Con here in Seattle.
And, yeah, that was fun.
Basically, I took a board that we have called Circuit Playground that has a ring of little lights on it.
And then it's the easiest thing.
I just put a magnet on the back, a name tag magnet, and just clipped it to my shirt.
And it's this little circle of lights.
But then I could control, I could program it.
Because in the Iron Man universe, I think the arc reactor is a little boring.
You know, Tony Stark, it's just, it only glows blue.
And maybe that's because of the, you know, the way it works.
But in my world, with my, with Tony D's arc reactor, I'm going to make it glow different colors.
So I had mine going through, like, rainbow colors and pulsing in different effects and things like that.
And that's cool because I could just write the code that controls it myself.
You know, I built it myself.
So I have total control over it.
Those are all cool projects.
So one more project question.
Do you know of any, like, commercial projects or Kickstarter type things?
Have people, like, used MicroPython or Adafruit to prototype something and then make it into a project?
Even if it's...
Good question, yeah.
So I do see Kickstarters all the time.
I can't think of any off the top of my head.
But I've definitely seen, you know, if you look at a Kickstarter, in a lot of cases,
they'll be showing the prototype that they built.
And look for, like, a little blue board with a white star or a white flower on it.
And that's, in a lot of cases, if they're using a sensor or something,
they've probably got an Adafruit board on there.
Because it's great for, you know, if you're doing a Kickstarter,
you're trying to very quickly build this prototype.
And so you don't have time yet to lay out that circuit board and figure out how it works.
You know, just grab the sensor off the shelf and make it work.
But then the cool thing is, because we publish all of our designs with open source,
when you're ready to turn it into that product,
you just grab our design files and you can see,
oh, here's how they built their sensor board.
And so now I can integrate it in my component.
So yeah, I did.
So one thing, though, that was a really popular Adafruit project was the Firewalker sneaker,
which is basically you put a ring of LEDs,
RGB controllable LEDs around the bottom of your shoes.
And then you put some little sensors in the shoes to detect when you take a step
and you can light up and animate the sneakers.
That was a project, I think it's about four years old or so,
and was really novel and cool.
And nowadays, like you can walk into pretty much any shopping mall and there's like a stand in the middle of the shopping mall
where they're selling commercial versions of these Firewalker sneakers.
I have seen people walking around with these.
Yeah.
And a lot of them, if you look at them, they're not as advanced.
Most of them don't have the sensors that detect when you take a step.
They'll just like have a fixed animation.
So that's, you know, not as interesting.
Like when you build it yourself, you can make it more fun and interesting.
And I haven't seen anything yet with MicroPython,
but I'm pretty sure we'll start to see that in the near future because that would be fun.
You know, make the MicroPython Firewalker sneakers where, you know,
you can have like Python code controlling it or maybe use a board that talks to your phone.
And, you know, maybe your sneakers can glow when you get like a notification or something.
Your sneakers could tweet every time you take a step, which might be a little excessive.
But yeah, so that's maybe the future of things that we'll see with products.
That sounds pretty cool.
Very nice.
Okay.
So I think we're pretty much out of time, Tony, but thank you for sharing all those stories.
Hopefully people are inspired to go out and try to create cool things they've always wanted to see exist.
Oh, yeah, totally.
Exactly.
You know, that's what we love to do in Adafruit is show people how things work and then show,
see what you've done with it.
You know, come back and show us what you built with it.
Really?
Show that it's not like so difficult.
Like, hey, these are all the steps it takes.
You can do this.
Yeah, the greatest thing.
So we do every Wednesday at, I think it's 4.30 Pacific, 7.30 Eastern time.
We have a show and tell on our YouTube channel and it's a live show.
People can come on and we have a hangout and you can show off the projects you built.
And the best thing, and Lamora said, you know, the greatest moments for her are when
you have like a seven-year-old girl come on to show off, you know, what she built or what
she made.
And it happens quite often.
You know, we inspire someone.
And then I think pretty soon we'll start to see that those seven-year-olds who came on the
show, you know, five, six, seven years from now are going to be coming back and saying,
hey, now I'm in college and look what, you know, you inspire me to do.
So looking forward to that.
Yeah, that's awesome.
You know, it just came to mind, like you go to these school science fairs and they have
these projects and a lot of them are like, well, I put a tadpole in a tank and we watched
it and measured it.
So, you know, it seems like if you took some of these things, you could do a really cool
science project.
Oh yeah, yep, exactly.
This is maybe science projects on easy mode.
You know, you just find cool projects we've done and then, you know, modify them yourself
and build on top of them.
Yep, exactly.
Exactly.
All right.
Well, two final questions before I let you out of here.
All right.
So if you're going to write some Python code, what editor do you open up?
Oh, I use the Atom text editor these days.
So I like it a lot.
You know, it's simple, runs on all the different operating systems.
I like the color scheme it has by default too.
Yeah, I like Atom as well.
Nice one.
And most notable or PyPI package you want to recommend?
I really like the click package.
It's used to build command line interfaces.
So it's, I think it was created by the person who created the Flask web framework.
And it's really nice.
It has that same kind of concept of, you know, building command line apps, but breaking it down
into kind of simpler functions that you implement for it.
So it makes it really easy to build an app that does something or a command line tool that does
something.
Yeah.
Excellent.
All right.
Final call to action for people to get started with all this stuff.
What should they do?
Yes.
If you're new to Python and hardware, you know, like I said, the Raspberry Pi is a great platform.
If you're just used to desktop Python and you just want something that feels like a desktop
computer.
But then also explore MicroPython and some of the boards I mentioned, things like the ESP8266.
That's probably the best entry level MicroPython board right now, just because it's a good balance
of cost and performance and really easy to get started.
But keep your eyes peeled for more boards coming in the future.
Circuit Playground board I mentioned.
We've got some boards that are coming soon that are going to run MicroPython and CircuitPython
and some of these versions of Python that run on microcontrollers.
So that'll be another good kind of getting started option for people.
So yeah, definitely check out those boards.
And yeah, don't be afraid to get started.
You know, one thing that holds people back is just thinking, I'm going to break something.
I'm going to spend a bunch of money.
And, you know, it's going to just destroy this piece of hardware.
They're more resilient than you think.
And like I said, if you follow a guide, if you look at a project that someone's already done,
you're going to run into less problems usually and have a little bit more fun
and get kind of quicker feedback on things.
Yeah, absolutely.
Check out learn.adafruit.com.
There's a ton of inspiration there for you.
All right.
Tony, thanks for being on the show.
Oh, yeah.
Thank you so much.
This is great.
Yeah.
Talk to you later.
Yeah.
See ya.
This has been another episode of Talk Python to Me.
Today's guest has been Tony DeCola.
And this episode has been sponsored by Advanced Digital and the Strange Loop Conference.
Advanced Digital would love to work with you to build and extend one of the most visited websites
in the US in Python.
Reach out to them at python.advance.net to see if there's a fit.
The Strange Loop Conference would love to have you present on languages, web development, AI,
and much more.
Visit talkpython.fm/strange loop to submit your proposal.
Don't wait.
The call for proposals closes on May 8th.
Are you or your colleagues trying to learn Python?
Well, be sure to visit training.talkpython.fm.
We now have year-long course bundles and a couple of new classes released just this week.
Have a look around.
I'm sure you'll find a class you'll enjoy.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct
RSS feed at /rss on talkpython.fm.
Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
Corey just recently started selling his tracks on iTunes, so I recommend you check it out
at talkpython.fm/music.
You can browse his tracks he has for sale on iTunes and listen to the full-length version
of the theme song.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Smix, let's get out of here.
Bye.
developers developers developers developers developers developers developers developers
Developers, developers, developers, developers.
you