 Fe bod gennych i'w dda o'r dwylaid o ran ffotod G.C. Gwyddoch chi'r ffordd ei rhan o gyhoedd yma rwynt i'w ffocor sauce, ac mae'n gwybod, yn cymhwylion, mae'n bedi'n gofynu Pryddoch i'r pwynt yn gwneud o ffodol, ac mae'r pwynt yn y gyfer, mae hyn yn cymhwylion. Felly mae'n felly mae'r pwynt yn gweithio gwyddoch chi, ac mae hyn yn cymryd Pryddoch ffodol yn gwneud o'r drew, maen nhw fan o ceisio gyfer samar ychydig. nonsense That scales to image processing for the space telescope which is amazing. We know it is moving to running on the browser. So we are going to talk about something that goes down to the other end of the scale down to smaller devices. So, talking about running Python on small circuit boards, on LEGO bricks that is going to become relevant later on on watches, ac mae'n cael eu hwn yn gofod. Rydw i'n ddosion ymlaen. Rydw i'n ddweud i Twitter yw'r adegydd cymdeithasol. Rydw i wedi'r adegydd cymdeithasol a'r rhaid o'r cyflwyno a'r tyfu. Rydw i'n ddweud i am Python a'r micropythyn. Rydw i ammell hynny'n hynny'n cyfrifau yn Ohio. Rydw i'n ddweud i ychydig i'r freffyniad i'r Python. Rydw i'n ddweud i'r ddweud i'r ddweud i'r cyfrifol. I am not an expert in electronics. I am not an expert in micropythons. This is really going to be a talk about my journey learning about micropythons in particular in the last sort of six, eight months. I have got some experience in the past and I'm talking 10, 15 years ago. I worked at IBM. I was one of the people that worked on MQTT there. I've been playing with things like Arduino for a long time but I've never fully got my head around a lot of the electronics concepts. I'm a LEGO fan and that's going to become relevant. Bear with me and hopefully you'll learn along with me as I've discovered things here. Let's talk about micropythons. What it is as in where it came from really and the differences between it and other varieties of pythons. Why I think it's important, why I'm here talking about it as opposed to talking about other varieties again or distributions of pythons. Also how to start using it because that's kind of fun. Hopefully we'll play around with it on a few different boards and see the kinds of things you can start to learn. For those of you that aren't familiar, how many of you have no knowledge at all of micropythons? No idea what it is. A few of you. Okay, cool. Micropythons actually just celebrated its ninth year so just in May is the ninth anniversary of its first release. It started off as a Kickstarter project from a guy called Damian George who's an awesome guy. He's actually over in Australia now. He had this idea that pythons are a great expressive language. Why not try to run it on small devices? Now you can't run the CPython on some of these devices. We're talking about things with very limited amounts of RAM in particular. So some of the optimisations in micropython are really focused on things that CPython is not optimised for. So it's not CPython. It's a full re-implementation of a language that looks very similar as actually the same as Python. It doesn't include all of the batteries included that you get with the regular Python distributions. The libraries in micropython have to be re-implemented specifically for the hardware and for the environment they're running in. So specifically it's a re-implementation of Python at around about 3.4, 3.5 release. And since then over the years incrementally they've added additional sort of pet features that have come along since then. As they make sense and as they can be accommodated within the constraints of the language. And since then it's been pooled across a whole range of microcontrollers. The most recent one that's been added in the latest release of 1.19 of micropython is a Rinesas SA board. But about two weeks ago the Raspberry Pi Foundation brought out the Raspberry Pi PicoW, which is a Pico with wireless. And it runs there as well, which hopefully I'll be able to show you in just a few minutes. I may have heard of some other things and I know there have been also talks about other varieties of Python for small devices, in particular CircuitPython from Adafruit, which is really, really cool. I'll talk about why I started down the path of micropython though. It's been going over, as I say, going since 2014, now May 2014. Before that, I think actually was it 2013? Just had nine years, that must be 2013. And this is just a star chart showing and stars are not necessarily the best indicator of popularity or growth of a project on GitHub. But it's interesting to see that micropython, the red line there, has grown in a fairly linear fashion over time. Some other derivatives of micropython, things that have been built off of micropython, such as CircuitPython and Pybrics, have come along at different times and have also been tracking really well. It's exciting to see these languages getting into these environments. So why is it important? Well Damien, I was listening to a podcast the other day from a few years ago to get a bit more inside Damien's head really, as best I could. And he described his initial idea when he went to Kickstarter to launch for some funding as sort of a proof of possibility, I think was the phrase he used, which I thought was really interesting. Python is a great language for expressing your ideas as code. And I certainly have had that experience myself. I've been doing code in various forms for 30 plus years and I think Python is a great language. It's relatively easy to pick up and it's very easy to be productive in very quickly. It's particularly good for prototyping, iterating, trying things out, optimising things later. And importantly, micropython is now the foundation, as I said, for some of those other projects. So Adafritzpo, a lot of investment into building a version of Python that's got micropython at its core called CircuitPython. They've got a team that builds that commercially as well as it being an open source project. They pay people to actually work on it as their day jobs. CircuitPython itself has had stuff built in it. So there's a keyboard firmware called KMK for programmable macro pads and things that's built on CircuitPython. So you've kind of got these sets of layers. Cyfryx, which is able to run on a lot of Legos controllers, has been built on micropython as well. So I think it's really important to understand and build on that foundation. And I was talking to Carlos downstairs earlier who had some micro bits down in the maker space there. And he was kind of describing it as really a bit like a Linux distribution model where you've got a core and you've got different ports and different varieties and different ways that people are bundling micropython and extending it. So you heard there'd be demos if you read the abstract I put out. So we're going to probably want to have a board. We don't have to have a board. There is an emulator called Wokwi, which you can go and try micropython and an emulator of a board like a Pico in the browser, which is very cool, actually. So you don't have to go out and spend lots of money on hardware. AliExpress can end up being a lot more expensive than it starts off looking when you start looking at fun little boards. Once you've got a board you're going to need to put micropython on it. I've got micropython on all the things on the desk already. So I'm not going to go into how to install it, but it's usually just a question of plugging the board in, resetting it into bootloader mode, and then dragging a firmware on in most cases. And a code editor. Now how did I get involved with all of this? Well, in January, Deborah, who's a maker on Twitter, tweeted this board that you can see here, the one with the LEDs. And she said somebody's sort of blinged out a tiny board, which I've now put under here, with lots of RGB LEDs, and she thought this is amazing, and it cost, I don't know, four or five dollars. So a bunch of us also saw that tweet and thought, yeah, okay, that's not very expensive. We all need one of those, and it's got Wi-Fi and Bluetooth and other stuff on there as well. It's an ESP32C3 chip, USB-C on the top. So she ordered one and started making jewelry with it. It's kind of fun, and she's got this necklace. She can change the stuff on there. And then she also made one which had a made a little 3D printed cloud and did the different rain patterns and things on it. So I got one of these, and it wouldn't at that time support CircuitPython. ESP32C3 doesn't enable you to have a USB, mount it as a USB drive, which is what CircuitPython typically does, although they're moving more towards being able to programme them directly over Bluetooth. So I ended up starting a project for myself. And then, because a lot of other people had bought these boards around the same time, we all started sort of figuring out what the maker over in China had done, what the pins were on the boards, what we needed to do to drive it. The other thing at the time, in February, was that the ESP32C3 chips were not as well supported in MicroPython, or in fact in the ESP32C3 toolchain, so we ended up fixing some bugs. So I put together this little project. It started off as MicroPython examples, and then it ended up, I've played with TinyGo, and there's some other languages you can use on there as well. So that's why I started digging in on MicroPython, and it had been a while since I looked at it myself. I'd previously looked at CircuitPython, which has got a really nice workflow. You literally just are editing a file on a USB mass storage device. MicroPython, you kind of need to do a bit more work yourself, which is fine for me, because I'm familiar with things. MicroPython, as of some of the more recent versions, has got a CLI called MP Remote, which we'll try and have a quick look at in a second. I also mentioned that MicroPython is not as batteries included as full Python, so you're typically going to need to be installing libraries as you need them, and you're going to want to be very thoughtful about what libraries you actually need, what hardware you're driving, again, how much RAM you're using on the board, because with some of them, you're going to very rapidly run out. Other ones, you can get some of the RP2040 boards with a lot more storage and other capabilities and memory. The other thing I started looking at was all of the IDE's options. So Nicholas is here and has got the Mew editor, which is awesome, and that works really, really nicely for CircuitPython in particular. It works really nicely for lots of varieties of regular Python. We saw him building that cool game with Pygame Zero the other day. But there's a nice one called Thoni, which I've been using. There's a plug-in for PyCharm. There's a plug-in for VS Code from one of the other board vendors called PyMaker. I haven't got it to work. VS Code is my go-to editor, so I'm a bit disappointed about that. There's a variety of them to check out. So we're going to take a quick whip through some boards, and that's why I've got this camera here, and we'll see what we can achieve. Let's see. Where did I do with my Pyboard light? So when Damian did the Kickstarter, he built a board, and this is actually a clone of the Pyboard light. I do have the actual proper Pyboard light, but I picked up the wrong one when I was rushing and packing my stuff the other day. Now these boards don't have wireless connectivity on them. You can connect something to them. I hope people can see that. Can everybody see this okay? Excellent. I can actually increase the size of this for now, because I'm not going to be immediately jumping into code, but I will do in a second. Pyboard light. So initially the Pyboards were bundled with the Kickstarter rewards. We've also got this 5x5 board, which I've got a cable plugged into at the moment. Now I should have this. This is where everything goes horribly wrong and I lose all my connections, so bear with me. That's not going to reach. Switch USB hubs. So I can put it in front of the camera. I also need to get one of those funky close-up cameras, which this is not. So in principle, when I plug this in, it's going to connect to the European Wi-Fi. There's a little blue light on the back. So this is an ESP32 board. Has anybody heard of a project called Cheer Lights? Nobody? So Cheer Lights is a synchronised colour API driven over, oh wow. Driven over the internet, you tweet a colour. Hashtag Cheer Lights. Currently the colour is green. So this is subscribed to an MQTT topic. So when it started, it connected to the Wi-Fi, subscribed to the Cheer Lights topic. If anybody wants to tweet the Cheer Lights at the moment, that will change colour. But it's given the time, I'm going to jump straight over to the Pico W because I want to show you this one. So until about two weeks ago, the Raspberry Pi Pico was in plentiful supply, but it didn't have any Wi-Fi connectivity. You could get some boards with Ethernet, or you could add Wi-Fi or Ethernet yourself. They've just added one which has got Wi-Fi. So let's jump into some code because I think this is hopefully going to work. Let's move to that to stop for a second. So we've connected, I've plugged this in and we've connected to it. So this is, it's got a, it has Python. So I can do import US, print uname. So the uname functionality in the latest release has improved a bit, so it will show you a bit more about the tool chain it was compiled with, which is handy. So I've got a couple of scripts here. There's one here called space, which is borrowed from my friend Les Pounder, Twitter. So this is going to connect to the conference Wi-Fi and it's hopefully going to get us back the current list of astronauts in space. That is saying it hasn't connected to the Wi-Fi yet, which is why it says false. Hopefully it will come true in a second. Okay, so that's the Pico. That's not running on my laptop. That's running on the Pico here. What's the point of that? Well, this could be connected to a small display in your home on very little power if you wanted to, astronauts in space are probably not going to change very often, but you might want to do some other things with that. And the Pico is incredibly affordable board. It's like six quid, seven quid for I think the Wi-Fi version. Sorry, you can tell I'm British and referring to things in quid rather than euros or dollars or any other thing. The other thing I've got here, which I quite like, Alistair Allen from the foundation, Pi Foundation put this one together. So, I'm going to just kick this one off. Let me stop the one that's running. And when I start this, there should be a new Wi-Fi hotspot in the room called Explore Europe Python, sorry, Explore U Python if anybody wants to try connecting to it. The password is Dublin 2022. And there should be a web page at 192.168.4.1. I do have this to show you all, especially for those who are remote connected to that. It will look something, I hope, like this. So, that's just running straight off the board again. If anybody's connecting, then I should be able to see it, but nobody has connected yet. So, oh well. I promise you it works, because otherwise I wouldn't have been able to do that screenshot earlier. There we go, somebody's connected. Thank you. It's a Linux Android Dalvik machine thing. So, the web address is 192.168.4.1. And then if you load that, you should get back the web page. And I've even got the SVG logo from the conference in it, I hope. Anyway, moving right along, this is quite simple stuff. I'm not going to plug in any more boards on the grounds of time, but again, the BBC Microbit runs a MicroPython, and you can be programmed visually as well. Yes, Lego. Can't find my Lego man board. Well, I have a Lego man of my own, which you can't see on the camera right now. You know, I do lots of conference speaking, but this one's going very, very quickly. So, my Lego man, so I'm into Lego, and I think Lauren from the Pybricks team was going to try and connect to watch my talk. But Lego sell a variety of these kits where you can program them typically on an iPad or something like that or with a visual interface. So, this is one of them. This is from their Lego Droids set where you can build an RTD2 and drive it. It comes with things like colour sensors, so I'm not going to show you now for the reasons of purposes of time, but I can assure you that it works. It's really nice. One is programmed over Bluetooth, and they have an editor that looks a bit like this. So, were I to run this and connect to it now, this would start printing out the colour of things that I put in front of that sensor. You could do some really cool stuff with that if you're building things with Lego. It's a really nice project. I apologise to the folks from Pybricks for not giving them a bit more time today, but if you're interested in that, do check that out as well. This is actually... Somewhere in my bag down there, a little Lego minifig shaped board, definitely not approved by Lego, that has a SAMD51 chip that has got a micro-USB connector on the back, and you can use a micro-python or a circuit-python with that as well, which is really fun. This watch is running in Python. It's a cheap, it's only, I think, 30 quid. It's got a touchscreen, various sensors on there. So, what I've been doing is, as well as learning about this stuff, coming to talk to you about this stuff, I've been trying to get involved with the community, and I think that's really helped me. I've been writing on what I've been learning, so the little 5x5 board. There's a series of logos on dev.to, to, dev, and I'm also moderating the micro-python tag over there. There's a GitHub topic now for micro-python that I submitted. If you didn't know, topics on GitHub, you can actually go and add for which are on the explore section on GitHub. You can actually send a pull request to add descriptions and stuff. I've also been attending the meet-ups. They have monthly meet-ups on micro-python now. All of the leads, almost all of the leads I think are in Australia, so I've been joining at 7 or 8 in the morning, and they've been having their meet-ups in their evening, but it's been really good. Especially actually because of the fact that we've had the pandemic and we've had the lockdown, they've been doing them online, which has meant that I've been able to join, which has been really fun. You can try micro-python on Wokwi. If you search for micro-python Wokwi, which is fairly specific spelling there, then you'll be able to find a site where you can go and basically select boards and try things there. The final two things I really want to recommend are the awesome micro-python list. If you're familiar with awesome lists, there's one for micro-python. You're going to learn a lot if you get into this around different types of sensors, different types of connectors to attach sensors to your boards, and you often need drivers for those. The awesome micro-python list is a really good place to go and learn about them. There's a great guy called Baveshover in Canada who's been doing an amazing series of tutorials on his blog with videos as well-showing, doing things like building colour changing lamps, using micro-python with MQTT, NTP, other things. This watch is actually connecting to NTP to do the synchronisation. Thank you very much for attending. I really appreciate it. I apologise that it seemed like I was scrabbling around for boards. I shall consider my use of my space and time more carefully in the future, or just ask for a longer slot. Thanks so much. I can't stay for the sprints unfortunately, but do you tweet me or come find me before the end of today? I'd love to chat. Thanks. Mr Quick, since I'm not familiar with all the hardware, what are we talking about in terms of memory restrictions? I think the absolute lower limits are, they're in less than megabytes of memory. You're talking about very small amounts of memory that they're optimising for, and trying to do a lot of stuff as well in that memory, in RAM, rather than necessarily, you've got no swap right, so you're having to do that. It does scale up as well. I don't know, I'm not an expert on the absolute specifics. What does the typical board have, like the ESP32? A lot of them are one-off to make a flash storage for your files. Again, I'm not 100% sure on the actual RAM restrictions on all of them. I'd have to look up the different specs for the different boards. Sorry about that. The other thing is I've been talking about having lots of fun with all this stuff, which is what I get to do, is actually writing MicroPython. As I mentioned, several of them are in Australia are using this for industrial automation and industrial use cases as well. So it's definitely something that's a bit more serious than blinking LEDs. Folks are using it for some really cool orchestrations. But I will tweet some information about this later on, because I now feel like I need to know that. First of all, it was really exciting. I guess that when you started working with this, you already had some experience in the overall thing. Yes. If someone with less experience, someone that's a beginner wants to actually start working with MicroPython, which would be your advice? I think Wokwi is really nice because they've got some templates on there. Microbit is really good as well because it's designed as an educational tool and it enables you to go from a block-type-based environment into Python. I think that the advantage that CircuitPython has got is that they've got Adafoot behind it with a team of people that are constantly building tutorials, really good content on there. CircuitPython is slightly different. It's not 100% compatible with MicroPython, but they've got some really great walk-through tutorials. I think that's something that's not there currently on the MicroPython side. Well, I'd love to help with. Vavesh is doing some great work around it, but it's all on a volunteer basis there, which is also the case to some extent for Adafoot. I did struggle a little bit and I've actually been chatting with Jimmo, who's one of the folks who's on the core team for MicroPython about how we can improve the documentation experience in particular. Again, because all of the boards are slightly different and there's a number of ports, for example, the network, which you briefly saw some lines of code from there, the WLAN function, some of the properties are slightly different between the different ports, so you end up digging through the docs to figure out what's what. But I think MicroBit's really good for starting out. The Pi Foundation's got a couple of bits for, they've actually got a book about MicroPython on the Pico, which is quite nice. I think those kind of resources are a good starting point. I wanted to do another one. From the other perspective, you have, I guess, a lot of experience, so do you see an area there for MicroPython that this technology has some steps to do more? I just want to make sure I'm understanding the question. Are you asking if there's a gap? No, I'm not sure that I heard properly. Are you saying is there a gap or something, or is there an opportunity? Yeah, yeah, exactly. I personally think that the MicroPython, I say we, I'm hoping to be part of that community and everybody to be part of that community. I think that there are definitely some gaps because the core team is small and they're focused on the technical aspects of the language. So I think, you know, tutorials, documentation, all of those kind of things are an opportunity and then also bringing things together in a community space. There's currently a forum on, I think it's a PHPPB-based forum. There's a discussion about whether that's right for the job now but they might move it to have discussions or something else. There's a Slack community, there's also a Discord community so it's like knowing where to go, find out, ask questions and again everybody's doing it on this better time as often happens. So it's really just making sure that everybody's talking to one another and that's always an opportunity. Thank you. Okay, enjoy the rest of the week. Thank you.