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