1 00:00:01,700 --> 00:00:06,460 Welcome to the CircuitPython Show. I'm your host, Paul Cutler. This episode, I welcome 2 00:00:06,560 --> 00:00:11,080 Justin Myers to the show. Justin is a software engineer living in the Pacific Northwest with 3 00:00:11,120 --> 00:00:15,020 a passion for open source development and recently contributed the new Connection Manager 4 00:00:15,120 --> 00:00:18,360 library to CircuitPython. Justin, welcome to the show. 5 00:00:19,840 --> 00:00:20,980 Thanks very much. I'm glad to be here. 6 00:00:21,470 --> 00:00:23,780 How did you first get started with computers and electronics? 7 00:00:24,540 --> 00:00:29,580 So as a child of the early 80s, my family, my mom was really into it. We got a computer, 8 00:00:29,880 --> 00:00:32,700 connected to the Bulletin Board systems really early on. 9 00:00:32,740 --> 00:00:34,460 And so it's just something that was always there. 10 00:00:35,160 --> 00:00:37,480 And just gravitated towards it. 11 00:00:37,800 --> 00:00:39,480 It's always been something that's interested me 12 00:00:39,880 --> 00:00:41,020 and fascinated me. 13 00:00:41,580 --> 00:00:45,840 I remember the first program I wrote was from a-- 14 00:00:45,840 --> 00:00:48,620 we had a Commodore 64 and literally coding out 15 00:00:48,660 --> 00:00:49,260 of a magazine. 16 00:00:50,500 --> 00:00:52,740 Had no idea what I was doing, just writing verbatim 17 00:00:52,780 --> 00:00:53,260 what was there. 18 00:00:54,280 --> 00:00:56,240 And then just kind of continued and was like, oh, 19 00:00:56,380 --> 00:00:57,060 can I make it do this? 20 00:00:57,120 --> 00:00:57,860 Can I make it do that? 21 00:00:58,020 --> 00:01:00,800 And then I've been doing that for the last 35 22 00:01:00,800 --> 00:01:01,780 plus years at this point. 23 00:01:02,000 --> 00:01:06,160 So that's how I got my started to programming that assembly code right out of a 24 00:01:06,320 --> 00:01:07,620 newspaper like magazine. 25 00:01:08,240 --> 00:01:10,820 And then I spent so much time on BBSs as well. 26 00:01:12,040 --> 00:01:13,760 How did you first get into electronics? 27 00:01:14,659 --> 00:01:15,880 Electronics was interesting. 28 00:01:16,160 --> 00:01:20,600 Like I'd always kind of dabbled at weird things, pulled stuff apart, what not, kind of 29 00:01:20,720 --> 00:01:22,540 looked under the hood, but didn't really do a lot. 30 00:01:23,160 --> 00:01:27,280 And then a number of years ago now, I don't even remember at this point, there was a 31 00:01:27,140 --> 00:01:28,360 a company doing a Kickstarter. 32 00:01:28,960 --> 00:01:30,520 And the company at the time was called Spark. 33 00:01:30,980 --> 00:01:32,920 It's now turned into a Particle, who 34 00:01:32,960 --> 00:01:35,140 I know has partnered with Adafruit on a few things 35 00:01:35,200 --> 00:01:35,580 and whatnot. 36 00:01:36,400 --> 00:01:39,260 But they had a Kickstarter out for these Wi-Fi dev boards 37 00:01:39,340 --> 00:01:41,460 that you could code and do over there updates. 38 00:01:41,540 --> 00:01:43,940 And I was like, that seems like a good thing to donate to. 39 00:01:44,560 --> 00:01:45,840 And so I donated to them. 40 00:01:46,200 --> 00:01:47,140 They're a Kickstarter or whatnot. 41 00:01:47,380 --> 00:01:48,160 And I got them. 42 00:01:49,120 --> 00:01:51,660 From there, I was like, oh, well, I've got these small chips. 43 00:01:51,780 --> 00:01:53,040 I don't know what really to do with them. 44 00:01:53,440 --> 00:01:54,360 And so I did some searching. 45 00:01:54,440 --> 00:01:56,140 And that's when I found Adafruit for the first time. 46 00:01:56,620 --> 00:02:00,900 like, Oh, I need more stuff. I need sensors, I need all of these other things. And then 47 00:02:00,900 --> 00:02:05,280 I just really started, you know, diving in and I kind of add different things and played 48 00:02:05,300 --> 00:02:09,860 with things and just kind of continue down that path for a while and built some, you 49 00:02:09,860 --> 00:02:11,900 know, small fun things to use 50 00:02:11,900 --> 00:02:15,200 and whatnot. And yeah, really just enjoy it. So how did 51 00:02:15,200 --> 00:02:18,580 you discover CircuitPython? Was it part of that process or something that came later? 52 00:02:19,280 --> 00:02:24,320 So I kind of watched it. So a lot of my development originally started in C, I'm now a Python 53 00:02:24,320 --> 00:02:28,960 developer for the most part, but kind of with that, so Arduino and everything made sense to me, 54 00:02:29,000 --> 00:02:34,520 it was really easy to kind of jump in. And then I saw when CircuitPython came out, and I kind of 55 00:02:34,540 --> 00:02:38,240 looked at it, I'm like, well, that's pretty limiting. And I just kind of walked away from it. 56 00:02:38,320 --> 00:02:44,340 I'm like, maybe someday. I think it's kind of when version eight came out, I had looked at some stuff 57 00:02:44,380 --> 00:02:48,280 and I was like, oh, there's, they've added quite a bit to this, you know, they've added some of 58 00:02:48,300 --> 00:02:52,540 their Wi Fi stuff to it and things like that. And I was like, no, this might be worth giving it a 59 00:02:52,400 --> 00:02:57,020 try. And so really kind of started digging in around there and then really started kind of 60 00:02:57,180 --> 00:03:01,040 playing with it more. At this point, I still kind of swap between the two, depending on kind of what 61 00:03:01,080 --> 00:03:01,620 I'm working on. 62 00:03:02,530 --> 00:03:05,760 Speaking of Wi-Fi, over the last year, you've been working with the underlying 63 00:03:05,940 --> 00:03:10,460 networking code in CircuitPython. What is Connection Manager and how does it make networking 64 00:03:10,760 --> 00:03:11,580 easier for users? 65 00:03:12,060 --> 00:03:12,900 I'll kind of step 66 00:03:12,900 --> 00:03:15,540 back one level, so to kind of where 67 00:03:15,540 --> 00:03:16,240 it kind of came from. 68 00:03:16,480 --> 00:03:19,620 So I joined Discord because I had a question about something 69 00:03:20,300 --> 00:03:24,120 and was looking and saw all this stuff, these users that 70 00:03:24,160 --> 00:03:26,740 was constantly just like, where they are here, 71 00:03:27,040 --> 00:03:28,580 like socket stuff, everything. 72 00:03:28,760 --> 00:03:31,120 And I just noticed there was a hole there 73 00:03:31,640 --> 00:03:34,360 and noticed when looking that there 74 00:03:34,400 --> 00:03:36,000 was a handful of other people that would help. 75 00:03:36,680 --> 00:03:39,480 And at that point, I had an airlift board 76 00:03:39,520 --> 00:03:40,900 and I had-- 77 00:03:40,900 --> 00:03:43,280 I don't remember what it was at the time-- 78 00:03:43,280 --> 00:03:46,460 an ESP S2 or S3 or whatever and noticed 79 00:03:46,460 --> 00:03:48,600 as I was playing with them, it was like, oh, wow, 80 00:03:49,020 --> 00:03:50,440 like these two things are totally different. 81 00:03:50,720 --> 00:03:53,120 Like there's no similarities between how you set them up. 82 00:03:53,650 --> 00:03:55,760 And so kind of through that, decided, 83 00:03:56,400 --> 00:03:57,720 kind of reached out to a few people. 84 00:03:57,720 --> 00:03:58,700 And I was like, hey, I think there's 85 00:03:58,700 --> 00:03:59,800 a better way to do this. 86 00:04:00,459 --> 00:04:04,840 And both, like whether using requests or like through Adafruit 87 00:04:04,990 --> 00:04:06,940 I/O, everything was separate. 88 00:04:07,360 --> 00:04:09,740 And so once you use more than one of the services, 89 00:04:10,040 --> 00:04:11,340 things really started getting complicated. 90 00:04:11,760 --> 00:04:14,100 How was your suggestion received on a better way to do it? 91 00:04:14,690 --> 00:04:16,040 I thought it was received pretty well. 92 00:04:16,340 --> 00:04:21,660 So basically, there was a session manager that was in requests that did a lot of this 93 00:04:21,840 --> 00:04:22,019 already. 94 00:04:22,660 --> 00:04:27,680 And so I had done a PR to basically kind of just separate that piece out in requests. 95 00:04:28,340 --> 00:04:31,640 And then from a couple people, they kind of mentioned like, "Oh, maybe we could break 96 00:04:31,680 --> 00:04:33,400 this out into its own thing." 97 00:04:33,400 --> 00:04:36,040 They were really, really forward kind of breaking it up and making it simple. 98 00:04:36,520 --> 00:04:41,460 In the end, Adafruit and specifically CircuitPython, right, they've got their goals, right? 99 00:04:41,520 --> 00:04:45,520 And so they've only got so many people and so many dollars to move things forward. 100 00:04:45,760 --> 00:04:50,180 So when people come up with a different idea to help and they don't have to do much other 101 00:04:50,200 --> 00:04:54,420 than maybe review some code, it seems like they're pretty pretty good know about being 102 00:04:54,540 --> 00:04:55,220 able to add it in. 103 00:04:55,850 --> 00:04:58,840 So you mentioned that there's a few different ways to get networking to work in Circuit 104 00:04:58,920 --> 00:05:02,400 Python with add-on boards like the airlift or was net or native networking. 105 00:05:02,890 --> 00:05:05,720 How does Connection Manager work behind the scenes? 106 00:05:07,140 --> 00:05:11,960 So in a super kind of like high level, right, so you like everything in the end is a radio, 107 00:05:12,180 --> 00:05:12,300 right? 108 00:05:13,160 --> 00:05:16,280 Like if you're using one of the newer boards, it's literally Wi-Fi dot radio 109 00:05:17,020 --> 00:05:19,400 If you are using the SP you're going to define, you know 110 00:05:19,400 --> 00:05:25,600 The SP SPI like you define that or same thing with the Wiznet and so the connection manager like in the end 111 00:05:25,600 --> 00:05:28,440 You just pass it a radio right and then it then goes 112 00:05:28,560 --> 00:05:34,540 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 113 00:05:34,640 --> 00:05:38,480 Needed the radio and the pool and the SSL stuff and so it goes 114 00:05:38,640 --> 00:05:42,520 Oh, it's this type of radio and so it'll then do the imports for you 115 00:05:42,500 --> 00:05:44,360 And so you don't have to think about that anymore, right? 116 00:05:44,380 --> 00:05:49,100 It's a single import for connection manager, and then it'll figure out what you need. 117 00:05:49,480 --> 00:05:52,940 There's different versions, depending on what version of the circuit Python you're on for 118 00:05:53,000 --> 00:05:55,120 like the WIS net that'll actually allow us to sell or won't. 119 00:05:55,120 --> 00:05:57,140 And so it just handles all that for you. 120 00:05:57,230 --> 00:06:00,060 So you just pass it a radio and then it can do everything. 121 00:06:00,340 --> 00:06:04,960 And then there's even a software defined radio if you're doing native networking. 122 00:06:05,140 --> 00:06:08,800 So if you're in C Python that you can actually use connection manager the exact same way. 123 00:06:09,440 --> 00:06:12,220 So you can actually write all of your networking code 124 00:06:12,220 --> 00:06:14,920 and test directly just in Python on your laptop. 125 00:06:15,580 --> 00:06:17,300 Like you don't even need Blink or anything like that 126 00:06:17,320 --> 00:06:20,660 if you're just doing regular internet connection stuff 127 00:06:21,000 --> 00:06:23,380 and you can use that to pre-write all of your code, 128 00:06:23,600 --> 00:06:25,000 which I now do all the time 129 00:06:25,200 --> 00:06:27,160 because my regular net's way faster 130 00:06:27,700 --> 00:06:29,100 than trying to do it on a microcontroller. 131 00:06:29,540 --> 00:06:29,960 - Oh, that's neat. 132 00:06:29,960 --> 00:06:31,920 I had no idea that you could do something similar 133 00:06:31,920 --> 00:06:33,380 in CPython with Connection Manager. 134 00:06:34,380 --> 00:06:37,320 - Yeah, it was like, and especially as I was testing stuff, 135 00:06:37,380 --> 00:06:38,759 like that was kind of a big part of it 136 00:06:38,760 --> 00:06:41,860 was, OK, pulling out an airlift and kind of trying 137 00:06:41,880 --> 00:06:43,240 to work through this stuff and make sure it works, 138 00:06:43,340 --> 00:06:45,040 especially when you're trying to work 139 00:06:45,120 --> 00:06:47,780 through multiple connections and things like that. 140 00:06:48,520 --> 00:06:49,480 They're small chips. 141 00:06:49,600 --> 00:06:50,440 They're not super fast. 142 00:06:50,620 --> 00:06:53,720 And so especially trying to iterate and things like that 143 00:06:54,420 --> 00:06:54,980 makes it a lot harder. 144 00:06:55,800 --> 00:06:57,700 So changing that and everything, and especially 145 00:06:57,760 --> 00:07:00,780 when I do bigger projects and things where I'm doing things 146 00:07:00,850 --> 00:07:03,480 like, say, OAuth through Google or something like that, 147 00:07:03,560 --> 00:07:06,400 having a connection that is strong and stable 148 00:07:06,400 --> 00:07:08,680 and I'm not going to run out of sockets or anything like that. 149 00:07:08,740 --> 00:07:09,660 was really helpful. 150 00:07:10,460 --> 00:07:12,560 - What kind of challenges did you encounter along the way? 151 00:07:13,620 --> 00:07:14,680 - Kind of the biggest one. 152 00:07:14,680 --> 00:07:16,960 So I, as I said, like I started a lot of my 153 00:07:17,800 --> 00:07:19,000 serious development in C 154 00:07:19,580 --> 00:07:22,840 and even did some things in some memory constrained areas. 155 00:07:22,840 --> 00:07:25,880 And so was originally very familiar with that, 156 00:07:25,940 --> 00:07:28,040 but then as the years went by 157 00:07:28,380 --> 00:07:32,480 and I no longer had to compile my own special Linux kernel 158 00:07:32,680 --> 00:07:33,920 for my web hosting and everything, 159 00:07:34,160 --> 00:07:36,619 and like CPU and memory and all of that stuff 160 00:07:36,620 --> 00:07:39,360 was just enormous and free, right? 161 00:07:39,420 --> 00:07:40,660 Like you had as much as you wanted. 162 00:07:41,160 --> 00:07:42,240 Like I think with a lot of people, 163 00:07:42,340 --> 00:07:45,580 my programming style got, I wouldn't say lazy, 164 00:07:45,980 --> 00:07:48,180 but not as far focused. 165 00:07:48,880 --> 00:07:51,080 And so kind of one of the biggest things was as 166 00:07:51,560 --> 00:07:53,960 working through this was, oh yeah, 167 00:07:54,380 --> 00:07:56,000 I'm now on a constrained device again. 168 00:07:56,760 --> 00:07:57,520 And not only that, right? 169 00:07:58,080 --> 00:08:00,580 Like not only memory and CPU and speed, 170 00:08:00,720 --> 00:08:03,680 but these can only do so many connections, right? 171 00:08:03,740 --> 00:08:06,160 You can only have a few before they just run out of memory. 172 00:08:06,600 --> 00:08:10,440 Whereas I can open a socket, hundreds of sockets all day long on my laptop. 173 00:08:10,800 --> 00:08:18,220 So kind of re-going through that switch and trying to think through it for all the devices and everything like that. 174 00:08:19,040 --> 00:08:23,960 It was a good challenge and a good remembering of like, oh, be a little bit more focused. 175 00:08:24,080 --> 00:08:30,980 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, 176 00:08:31,670 --> 00:08:33,479 you know, taking the extra time to think through that. 177 00:08:34,620 --> 00:08:34,979 Very cool. 178 00:08:36,400 --> 00:08:39,620 As part of creating Connection Manager, you developed a testing framework. 179 00:08:39,830 --> 00:08:41,140 Tell me more about the framework. 180 00:08:42,520 --> 00:08:47,660 Yeah, so kind of one of the big things was, so after the initial part of Connection Manager 181 00:08:48,120 --> 00:08:53,300 was created, still realized there were a bunch of different ways to do things. 182 00:08:53,300 --> 00:08:59,940 For example, there was one way to get the IP address from the native radio and a different 183 00:09:00,010 --> 00:09:04,320 way to get it from the, say, the airlift. 184 00:09:04,720 --> 00:09:09,940 And so I wanted to go through and make sure all of these things worked, especially as we moved 185 00:09:10,100 --> 00:09:17,580 stuff around. And so kind of built this testing framework that I could plug in any chip and then 186 00:09:17,700 --> 00:09:21,900 run this set of tests and it would go through and go. It would even detect the radio that it 187 00:09:21,900 --> 00:09:26,560 had connected to it and then go, "Oh, great. You're on a WISNET." And then it would run through a 188 00:09:26,860 --> 00:09:31,320 series of just standard tests to make sure nothing broke. It would go through all the different 189 00:09:31,280 --> 00:09:38,460 things you know HTTP, HTTPS, it would connect to NTP for time, it even you know run a micro server 190 00:09:38,620 --> 00:09:43,620 to basically go check and it was basically like did any of this break? Like the goal was always to 191 00:09:44,300 --> 00:09:49,640 actually have something and hopefully someday I might try to push this down the line again but 192 00:09:49,700 --> 00:09:54,240 like as they come out with new versions. So like another big part of it came out because we were 193 00:09:54,360 --> 00:10:01,260 right between eight and nine for CircuitPython and they were you know making some changes or 194 00:10:01,260 --> 00:10:04,580 we break that? Like, because we'd see, I'd see someone testing, they're like, oh, this 195 00:10:04,700 --> 00:10:08,040 isn't working anymore. And so it was kind of like trying to build something to go, oh, 196 00:10:08,140 --> 00:10:12,920 does all of this stuff work? It kind of, you know, built out of that. And like, ideally, 197 00:10:13,040 --> 00:10:16,140 it would be something that somewhere, like whenever they do a release, these things would 198 00:10:16,220 --> 00:10:21,260 get run, right? Because we see with every release, like sometimes we'll see, you know, 199 00:10:21,800 --> 00:10:26,300 whatever it is, 0.7. And then like, the next day, 0.8 comes out because you have some regression 200 00:10:26,300 --> 00:10:31,100 that some user finds. So if there was some way to build some testing framework around 201 00:10:31,160 --> 00:10:34,880 it, I'm definitely not in their build system or anything like that. But it was something 202 00:10:34,980 --> 00:10:38,600 that I could do to kind of test to make sure things weren't breaking or whatnot. Also help 203 00:10:38,660 --> 00:10:43,580 find all the ways that the different radios were different. So we could slowly work towards 204 00:10:43,620 --> 00:10:44,800 getting them so they're all the same. 205 00:10:45,640 --> 00:10:48,260 Do I want to know how many different boards you ran through those tests? 206 00:10:48,760 --> 00:10:50,740 I know we're not on talking 207 00:10:50,740 --> 00:10:53,580 only, but I'm going to adjust my camera just so you can 208 00:10:53,500 --> 00:10:57,340 see it, that whole stack there is almost as tall as me. 209 00:10:57,440 --> 00:10:58,960 It's so it's all my electronics gear. 210 00:10:59,310 --> 00:11:03,520 I probably have about 50 different boards at this point that are all different. 211 00:11:04,500 --> 00:11:09,160 Ran it through all of them, which obviously is painstakingly when a new 212 00:11:09,320 --> 00:11:13,720 release comes out and you've got to go download 50 firmwares and update 213 00:11:13,840 --> 00:11:15,080 them and everything like that. 214 00:11:15,900 --> 00:11:19,600 And then of course, then my router started having problems because I had too many 215 00:11:19,700 --> 00:11:22,300 connections to it because everything was connected and everything. 216 00:11:22,500 --> 00:11:22,760 Sure. 217 00:11:22,940 --> 00:11:23,700 It's always something. 218 00:11:24,440 --> 00:11:24,560 Yeah. 219 00:11:24,640 --> 00:11:25,300 It's always something. 220 00:11:25,980 --> 00:11:29,140 So last question I ask each guest, you're going to start a new circuit 221 00:11:29,400 --> 00:11:30,900 Python or microcontroller project. 222 00:11:31,140 --> 00:11:31,300 Which 223 00:11:31,300 --> 00:11:32,280 board do you reach for? 224 00:11:33,220 --> 00:11:34,720 So this is always a hard question. 225 00:11:34,980 --> 00:11:37,600 Like I love asking this in a very different thing when I'm interviewing 226 00:11:37,800 --> 00:11:41,280 somebody, like if you were to build a new thing, what software would you use? 227 00:11:41,440 --> 00:11:44,420 And my goal is always to find out like, is this person a. 228 00:11:45,100 --> 00:11:48,300 I'm a hammer and everything's a nail type of person or are they not? 229 00:11:49,000 --> 00:11:51,500 So it really depends on what you were doing. 230 00:11:52,300 --> 00:11:57,940 So good solid Wi-Fi and everything like that good powerful chip if that's what you're looking for 231 00:11:58,480 --> 00:12:02,540 The sp32 s3 is one of the ones that I use often 232 00:12:03,240 --> 00:12:05,060 If I am doing something specifically 233 00:12:05,800 --> 00:12:08,060 That is more bluetooth focused 234 00:12:08,660 --> 00:12:11,020 the nrf52 series, uh, so that 235 00:12:11,740 --> 00:12:16,400 Adafruit has the bluefruit sense. I really like that board. That's really a fun one 236 00:12:16,400 --> 00:12:18,460 It has a couple sensors on it and things like that 237 00:12:18,780 --> 00:12:22,860 And if I'm not doing any sort of Wi-Fi and I just need something that's nice and strong, 238 00:12:22,940 --> 00:12:27,440 like I really enjoy the M4. It's been around for a while. It's a pretty powerful chip. It's got 239 00:12:27,580 --> 00:12:32,300 floating points. I do a lot of stuff with like math and things like that. And so having that 240 00:12:32,400 --> 00:12:40,240 floating point processor, I actually built a library or ported over a library for determining 241 00:12:40,320 --> 00:12:45,240 declination that Noah has built out. And so having that, the floating point makes it a lot more 242 00:12:45,100 --> 00:12:46,560 more accurate and things like that. 243 00:12:47,400 --> 00:12:51,100 I've started diving a little bit more into the Pico series, 244 00:12:51,540 --> 00:12:53,660 but in the end, still not my favorites. 245 00:12:54,960 --> 00:12:57,960 I recently did get a 2350 and I'm going to play with that one. 246 00:12:58,380 --> 00:13:01,440 I think the hardest part of that is since I do do a lot of 247 00:13:01,580 --> 00:13:04,820 CircuitPython and it can't take advantage of the dual processor, 248 00:13:05,460 --> 00:13:06,920 the dual cores, it's like, 249 00:13:07,320 --> 00:13:09,520 "No, I get a lot of something that I can't quite use." 250 00:13:09,520 --> 00:13:09,560 >> 251 00:13:09,560 --> 00:13:09,780 Right. 252 00:13:10,150 --> 00:13:13,340 >> I keep hoping that there's a way to run a second, 253 00:13:13,620 --> 00:13:17,440 Arduino something on the other core that just sits there and listens, and then you can have this 254 00:13:17,520 --> 00:13:24,480 powerful, "Go do this math!" and then do my easy coding in CircuitPython. But someday. 255 00:13:25,240 --> 00:13:28,300 Someday. Justin, thanks so much for making time and coming on the show. 256 00:13:29,020 --> 00:13:30,060 You're quite welcome. I enjoyed it. 257 00:13:31,200 --> 00:13:35,700 Thank you for listening to The CircuitPython Show. That's a wrap on Season 5. I hope you 258 00:13:35,840 --> 00:13:43,600 enjoyed the new topic-based episodes in addition to the interviews. Show notes and transcripts are 259 00:13:44,040 --> 00:13:47,540 There are links to follow the show on Mastodon and Blue Sky in the show notes. 260 00:13:47,920 --> 00:13:50,220 When the show comes back, I'll share it on the socials. 261 00:13:50,640 --> 00:13:52,320 Until next time, stay positive.