Justin Myers
S05:E46

Justin Myers

Episode description

In the final episode of season 5, Justin Myers joins the show. Justin shares how he created the new connectionmanager library for networking in CircuitPython.

Follow the show on Mastodon or Bluesky for news of when the show will return.

Show Notes

00:00 Intro

00:21 Justin’s start with computers

1:11 Discovering electronics

2:15 Discovering CircuitPython

3:02 ConnectionManager

4:55 How does connectionmanager work?

7:10 What were the challenges in creating connectionmanager?

8:35 Software testing framework

11:21 Which board?

13:25 Wrap-up

Download transcript (.srt)
0:01

Welcome to the CircuitPython Show. I'm your host, Paul Cutler. This episode, I welcome

0:06

Justin Myers to the show. Justin is a software engineer living in the Pacific Northwest with

0:11

a passion for open source development and recently contributed the new Connection Manager

0:15

library to CircuitPython. Justin, welcome to the show.

0:19

Thanks very much. I'm glad to be here.

0:21

How did you first get started with computers and electronics?

0:24

So as a child of the early 80s, my family, my mom was really into it. We got a computer,

0:29

connected to the Bulletin Board systems really early on.

0:32

And so it's just something that was always there.

0:35

And just gravitated towards it.

0:37

It's always been something that's interested me

0:39

and fascinated me.

0:41

I remember the first program I wrote was from a--

0:45

we had a Commodore 64 and literally coding out

0:48

of a magazine.

0:50

Had no idea what I was doing, just writing verbatim

0:52

what was there.

0:54

And then just kind of continued and was like, oh,

0:56

can I make it do this?

0:57

Can I make it do that?

0:58

And then I've been doing that for the last 35

1:00

plus years at this point.

1:02

So that's how I got my started to programming that assembly code right out of a

1:06

newspaper like magazine.

1:08

And then I spent so much time on BBSs as well.

1:12

How did you first get into electronics?

1:14

Electronics was interesting.

1:16

Like I'd always kind of dabbled at weird things, pulled stuff apart, what not, kind of

1:20

looked under the hood, but didn't really do a lot.

1:23

And then a number of years ago now, I don't even remember at this point, there was a

1:27

a company doing a Kickstarter.

1:28

And the company at the time was called Spark.

1:30

It's now turned into a Particle, who

1:32

I know has partnered with Adafruit on a few things

1:35

and whatnot.

1:36

But they had a Kickstarter out for these Wi-Fi dev boards

1:39

that you could code and do over there updates.

1:41

And I was like, that seems like a good thing to donate to.

1:44

And so I donated to them.

1:46

They're a Kickstarter or whatnot.

1:47

And I got them.

1:49

From there, I was like, oh, well, I've got these small chips.

1:51

I don't know what really to do with them.

1:53

And so I did some searching.

1:54

And that's when I found Adafruit for the first time.

1:56

like, Oh, I need more stuff. I need sensors, I need all of these other things. And then

2:00

I just really started, you know, diving in and I kind of add different things and played

2:05

with things and just kind of continue down that path for a while and built some, you

2:09

know, small fun things to use

2:11

and whatnot. And yeah, really just enjoy it. So how did

2:15

you discover CircuitPython? Was it part of that process or something that came later?

2:19

So I kind of watched it. So a lot of my development originally started in C, I'm now a Python

2:24

developer for the most part, but kind of with that, so Arduino and everything made sense to me,

2:29

it was really easy to kind of jump in. And then I saw when CircuitPython came out, and I kind of

2:34

looked at it, I'm like, well, that's pretty limiting. And I just kind of walked away from it.

2:38

I'm like, maybe someday. I think it's kind of when version eight came out, I had looked at some stuff

2:44

and I was like, oh, there's, they've added quite a bit to this, you know, they've added some of

2:48

their Wi Fi stuff to it and things like that. And I was like, no, this might be worth giving it a

2:52

try. And so really kind of started digging in around there and then really started kind of

2:57

playing with it more. At this point, I still kind of swap between the two, depending on kind of what

3:01

I'm working on.

3:02

Speaking of Wi-Fi, over the last year, you've been working with the underlying

3:05

networking code in CircuitPython. What is Connection Manager and how does it make networking

3:10

easier for users?

3:12

I'll kind of step

3:12

back one level, so to kind of where

3:15

it kind of came from.

3:16

So I joined Discord because I had a question about something

3:20

and was looking and saw all this stuff, these users that

3:24

was constantly just like, where they are here,

3:27

like socket stuff, everything.

3:28

And I just noticed there was a hole there

3:31

and noticed when looking that there

3:34

was a handful of other people that would help.

3:36

And at that point, I had an airlift board

3:39

and I had--

3:40

I don't remember what it was at the time--

3:43

an ESP S2 or S3 or whatever and noticed

3:46

as I was playing with them, it was like, oh, wow,

3:49

like these two things are totally different.

3:50

Like there's no similarities between how you set them up.

3:53

And so kind of through that, decided,

3:56

kind of reached out to a few people.

3:57

And I was like, hey, I think there's

3:58

a better way to do this.

4:00

And both, like whether using requests or like through Adafruit

4:04

I/O, everything was separate.

4:07

And so once you use more than one of the services,

4:10

things really started getting complicated.

4:11

How was your suggestion received on a better way to do it?

4:14

I thought it was received pretty well.

4:16

So basically, there was a session manager that was in requests that did a lot of this

4:21

already.

4:22

And so I had done a PR to basically kind of just separate that piece out in requests.

4:28

And then from a couple people, they kind of mentioned like, "Oh, maybe we could break

4:31

this out into its own thing."

4:33

They were really, really forward kind of breaking it up and making it simple.

4:36

In the end, Adafruit and specifically CircuitPython, right, they've got their goals, right?

4:41

And so they've only got so many people and so many dollars to move things forward.

4:45

So when people come up with a different idea to help and they don't have to do much other

4:50

than maybe review some code, it seems like they're pretty pretty good know about being

4:54

able to add it in.

4:55

So you mentioned that there's a few different ways to get networking to work in Circuit

4:58

Python with add-on boards like the airlift or was net or native networking.

5:02

How does Connection Manager work behind the scenes?

5:07

So in a super kind of like high level, right, so you like everything in the end is a radio,

5:12

right?

5:13

Like if you're using one of the newer boards, it's literally Wi-Fi dot radio

5:17

If you are using the SP you're going to define, you know

5:19

The SP SPI like you define that or same thing with the Wiznet and so the connection manager like in the end

5:25

You just pass it a radio right and then it then goes

5:28

Oh, what kind of radio is this and then from that it then does so before you'd have all these imports to be as you

5:34

Needed the radio and the pool and the SSL stuff and so it goes

5:38

Oh, it's this type of radio and so it'll then do the imports for you

5:42

And so you don't have to think about that anymore, right?

5:44

It's a single import for connection manager, and then it'll figure out what you need.

5:49

There's different versions, depending on what version of the circuit Python you're on for

5:53

like the WIS net that'll actually allow us to sell or won't.

5:55

And so it just handles all that for you.

5:57

So you just pass it a radio and then it can do everything.

6:00

And then there's even a software defined radio if you're doing native networking.

6:05

So if you're in C Python that you can actually use connection manager the exact same way.

6:09

So you can actually write all of your networking code

6:12

and test directly just in Python on your laptop.

6:15

Like you don't even need Blink or anything like that

6:17

if you're just doing regular internet connection stuff

6:21

and you can use that to pre-write all of your code,

6:23

which I now do all the time

6:25

because my regular net's way faster

6:27

than trying to do it on a microcontroller.

6:29

- Oh, that's neat.

6:29

I had no idea that you could do something similar

6:31

in CPython with Connection Manager.

6:34

- Yeah, it was like, and especially as I was testing stuff,

6:37

like that was kind of a big part of it

6:38

was, OK, pulling out an airlift and kind of trying

6:41

to work through this stuff and make sure it works,

6:43

especially when you're trying to work

6:45

through multiple connections and things like that.

6:48

They're small chips.

6:49

They're not super fast.

6:50

And so especially trying to iterate and things like that

6:54

makes it a lot harder.

6:55

So changing that and everything, and especially

6:57

when I do bigger projects and things where I'm doing things

7:00

like, say, OAuth through Google or something like that,

7:03

having a connection that is strong and stable

7:06

and I'm not going to run out of sockets or anything like that.

7:08

was really helpful.

7:10

- What kind of challenges did you encounter along the way?

7:13

- Kind of the biggest one.

7:14

So I, as I said, like I started a lot of my

7:17

serious development in C

7:19

and even did some things in some memory constrained areas.

7:22

And so was originally very familiar with that,

7:25

but then as the years went by

7:28

and I no longer had to compile my own special Linux kernel

7:32

for my web hosting and everything,

7:34

and like CPU and memory and all of that stuff

7:36

was just enormous and free, right?

7:39

Like you had as much as you wanted.

7:41

Like I think with a lot of people,

7:42

my programming style got, I wouldn't say lazy,

7:45

but not as far focused.

7:48

And so kind of one of the biggest things was as

7:51

working through this was, oh yeah,

7:54

I'm now on a constrained device again.

7:56

And not only that, right?

7:58

Like not only memory and CPU and speed,

8:00

but these can only do so many connections, right?

8:03

You can only have a few before they just run out of memory.

8:06

Whereas I can open a socket, hundreds of sockets all day long on my laptop.

8:10

So kind of re-going through that switch and trying to think through it for all the devices and everything like that.

8:19

It was a good challenge and a good remembering of like, oh, be a little bit more focused.

8:24

And I've even now re-implemented some of that stuff in my daily life to be, you know, think through a little bit more performance level,

8:31

you know, taking the extra time to think through that.

8:34

Very cool.

8:36

As part of creating Connection Manager, you developed a testing framework.

8:39

Tell me more about the framework.

8:42

Yeah, so kind of one of the big things was, so after the initial part of Connection Manager

8:48

was created, still realized there were a bunch of different ways to do things.

8:53

For example, there was one way to get the IP address from the native radio and a different

9:00

way to get it from the, say, the airlift.

9:04

And so I wanted to go through and make sure all of these things worked, especially as we moved

9:10

stuff around. And so kind of built this testing framework that I could plug in any chip and then

9:17

run this set of tests and it would go through and go. It would even detect the radio that it

9:21

had connected to it and then go, "Oh, great. You're on a WISNET." And then it would run through a

9:26

series of just standard tests to make sure nothing broke. It would go through all the different

9:31

things you know HTTP, HTTPS, it would connect to NTP for time, it even you know run a micro server

9:38

to basically go check and it was basically like did any of this break? Like the goal was always to

9:44

actually have something and hopefully someday I might try to push this down the line again but

9:49

like as they come out with new versions. So like another big part of it came out because we were

9:54

right between eight and nine for CircuitPython and they were you know making some changes or

10:01

we break that? Like, because we'd see, I'd see someone testing, they're like, oh, this

10:04

isn't working anymore. And so it was kind of like trying to build something to go, oh,

10:08

does all of this stuff work? It kind of, you know, built out of that. And like, ideally,

10:13

it would be something that somewhere, like whenever they do a release, these things would

10:16

get run, right? Because we see with every release, like sometimes we'll see, you know,

10:21

whatever it is, 0.7. And then like, the next day, 0.8 comes out because you have some regression

10:26

that some user finds. So if there was some way to build some testing framework around

10:31

it, I'm definitely not in their build system or anything like that. But it was something

10:34

that I could do to kind of test to make sure things weren't breaking or whatnot. Also help

10:38

find all the ways that the different radios were different. So we could slowly work towards

10:43

getting them so they're all the same.

10:45

Do I want to know how many different boards you ran through those tests?

10:48

I know we're not on talking

10:50

only, but I'm going to adjust my camera just so you can

10:53

see it, that whole stack there is almost as tall as me.

10:57

It's so it's all my electronics gear.

10:59

I probably have about 50 different boards at this point that are all different.

11:04

Ran it through all of them, which obviously is painstakingly when a new

11:09

release comes out and you've got to go download 50 firmwares and update

11:13

them and everything like that.

11:15

And then of course, then my router started having problems because I had too many

11:19

connections to it because everything was connected and everything.

11:22

Sure.

11:22

It's always something.

11:24

Yeah.

11:24

It's always something.

11:25

So last question I ask each guest, you're going to start a new circuit

11:29

Python or microcontroller project.

11:31

Which

11:31

board do you reach for?

11:33

So this is always a hard question.

11:34

Like I love asking this in a very different thing when I'm interviewing

11:37

somebody, like if you were to build a new thing, what software would you use?

11:41

And my goal is always to find out like, is this person a.

11:45

I'm a hammer and everything's a nail type of person or are they not?

11:49

So it really depends on what you were doing.

11:52

So good solid Wi-Fi and everything like that good powerful chip if that's what you're looking for

11:58

The sp32 s3 is one of the ones that I use often

12:03

If I am doing something specifically

12:05

That is more bluetooth focused

12:08

the nrf52 series, uh, so that

12:11

Adafruit has the bluefruit sense. I really like that board. That's really a fun one

12:16

It has a couple sensors on it and things like that

12:18

And if I'm not doing any sort of Wi-Fi and I just need something that's nice and strong,

12:22

like I really enjoy the M4. It's been around for a while. It's a pretty powerful chip. It's got

12:27

floating points. I do a lot of stuff with like math and things like that. And so having that

12:32

floating point processor, I actually built a library or ported over a library for determining

12:40

declination that Noah has built out. And so having that, the floating point makes it a lot more

12:45

more accurate and things like that.

12:47

I've started diving a little bit more into the Pico series,

12:51

but in the end, still not my favorites.

12:54

I recently did get a 2350 and I'm going to play with that one.

12:58

I think the hardest part of that is since I do do a lot of

13:01

CircuitPython and it can't take advantage of the dual processor,

13:05

the dual cores, it's like,

13:07

"No, I get a lot of something that I can't quite use."

13:09

>>

13:09

Right.

13:10

>> I keep hoping that there's a way to run a second,

13:13

Arduino something on the other core that just sits there and listens, and then you can have this

13:17

powerful, "Go do this math!" and then do my easy coding in CircuitPython. But someday.

13:25

Someday. Justin, thanks so much for making time and coming on the show.

13:29

You're quite welcome. I enjoyed it.

13:31

Thank you for listening to The CircuitPython Show. That's a wrap on Season 5. I hope you

13:35

enjoyed the new topic-based episodes in addition to the interviews. Show notes and transcripts are

13:44

There are links to follow the show on Mastodon and Blue Sky in the show notes.

13:47

When the show comes back, I'll share it on the socials.

13:50

Until next time, stay positive.