 by Alan Cale saying people who are really serious about software should make their own hardware and that's a really good thing to know because if you know about the deep things that are going inside your hardware and then you can optimize your code to such a level that you can do anything with it. But to be honest hardware programming or hardware designing in general is quite intimidating especially if you are new to this thing and that is why tools like Arduino, tools like Raspberry Pi comes into it making it more easy for you to do hardware stuff. So this is one of the articles I wrote for a magazine called Open Source for You. It's one of quite famous magazine in India. I wrote this last year and introduction to MicroPython. MicroPython was quite new at that time and I obviously got tons of emails after this about how to get started because there was not a good documentation back then. What projects can we do with MicroPython? Well, now we have a good documentation. It's a really good, amazing project. A lot of contributors from around the world is there and it has gone through an enormous community because Python already have a good community, right? So they have ported the Python to hardware and now MicroPython is there but also a circuit Python is there which we'll be talking about in a bit. So basically when you speak about Python on hardware most of the people might be thinking about the Raspberry Pi situation where there are libraries, you can do any of the controls, you can do sound, you can do that. But if you talk about the Raspberry Pi, that is an operating system, a full-fledged Linux running on a single-board computer. But what exactly a MicroPython is, it's running as a firmware on a microcontroller. So that is not something on an OS-based system but that is a bare-metal thing. So you are running your entire Python programming language on top of a bare-metal. That is your microcontroller. And if you look at the definition of an operating system, it's basically an interface between the user and the hardware, right? So it is a Python operating system in short, the MicroPython language and the CircuitPython language. So CircuitPython is another project that came out of MicroPython. So basically CircuitPython is a fork of MicroPython and it has been maintained by a company called Adafruit. So Adafruit is a company which makes some amazing boots for makers and for hobbies and for students, mostly for educational purposes. So MicroPython supported like an official high-board initially, then they moved to ESP to level 6. But there are tons of amazing, more powerful boards that Adafruit is making like FeatherM0, M4 chip. So might sound so juggles, so you just take it like this. Like there are some amazing boards made by a company called Adafruit and they wanted to support MicroPython. So rather they forked it out and make it more compatible to their hardware. So Cushion is why Python on hardware. Like we really have different options. We can program in assembly. We can program in C. We can also have different options like LuaStrip is there and there are some projects that are doing Javascript on hardware. I guess Tesla is one. So Python on hardware. So one we can ask like the biggest advantage of a Python programming language is open source and it has a huge community backing it up. So Python already is like one of the most good general programming language. Very easy to learn. Very pseudocode based approach. So yeah, so that is why Python is a good choice for hardware and yes, it's very portable. It's very scalable. It has a good library support. You can do a lot of different things. Baptist included approaches there. So again, Python is a good option if you want to do the hardware programming and that is a reason that was chosen. And why not to Python on hardware? So there will be some projects where you shouldn't consider Python on hardware because of various reasons such as slow and not real time. So if you have real time applications like, so I'm an automotive kind of guy. So let's talk about anti-lock breaking system. So that is something you don't, you want to be very strict real time. You don't want to be using Python on that. So that is one constraint. Other is like it's a bit heavy. So Python, if you don't know, it's maybe an interpreted language but at the back it's getting compiled to byte codes, getting run on a virtual machine. So yeah, a bit heavy. And single-thread operation is only supported for MicroPython and CircuitPython as of now. So this is for MicroPython and CircuitPython, there is only single-thread operations. And if you're into hardware, you know how important are the interrupts. So if we are going through this session and if there's a fire, God won't do that. But if there's a fire outside, you want it to get interrupted, right? But there is no such thing in MicroPython and CircuitPython yet. So if you have your projects want some in tropical projects as real time, then please don't consider using MicroPython and CircuitPython. So there are some opportunities I would like to mention, like as a maker, as a engineer, you want to do some hobby projects like making a smartphone, splitting some LEDs around, maybe putting some LEDs on your shoes and making some music boxes. So these are small makeup projects you wanted to do and you see that on the internet all the time. Instructibles, Hackster, Hackaday, and you wanted to build yourself. And many of the software has been integrated to, you know, solder stuffs and do some PCB kind of thing or maybe even program the hardware. That is why MicroPython and CircuitPython comes into picture. Like if you already knew the Python programming language, which is a lovely language and you already doing stuff with the Python on your operating system, then you can use that same approach on the MicroPython and make these small lovely projects. So this is the microcontroller and talking about the microcontroller, it has some limitations. Limitations like it is not something that you can run on like gigahertz of clock, it has a few megahertz maybe, maybe very few kilobytes of gram, mega bits of room and just the level access is provided. So this is something which every electronic device has. That is a diagram of software but it has some constraints. So that was the challenge of supporting Python programming language to a microcontroller and that was the reason before that people were using C, maybe C++ or assembly to do this stuff because this microcontroller has some registers exposed and you need to program directly to that registers. You need to do some bit twiddling, right shifting, left shifting and kind of things to get what you wanted to make the spins as input or make this as output. So that was the thing people were doing before and this is the official MicroPython supported board that is a Pyboard that can learn MicroPython. So MicroPython as a project came from a crowdfunding campaign. It was by a person called Damian Damian George and I guess he was one of first son, he was working with son back then when he felt need for some general purpose hardware language which people can learn very easily and Python was a choice so this was the first official Pyboard and once on an STM32 processor it has analog digital converter digital analog converter GPIOs, UR, then what not so all these kinds of hardware all these kinds of things, all these kinds of variables you can control with your favourite programming language, the Python. So talking about Python on hardware basically what exactly it is it is a stripped down version of Python 3 so Python 3 is an open source language you can do whatever you want with it you can change the code you can port it to different hardware that Damian did with the MicroPython project he took the Python resource code he made it very optimized for small constraint hardware which have only few kilobytes of RAM few MBs of RAM removed the things that were not required added some more things which are required to run on hardware and we have this amazing project called MicroPython and from there Adafruit came into picture for that project for their own boards and circuit Python was born. So MicroPython with MicroPython you can do GPIO that is general purpose input-output you can do pulse-width modulation that is like a fake analog output to dim the LEDs you can do that you can do UART, that is universal asynchronous receiver transmitter that is basically a serial connection between two devices how modem works back in the days you can do I2C internet integrated circuit SPS serial peripheral interface and throw in some joggers that you don't get intimidated again that's not the reason we are setting up we are setting up to make hardware programming more easier but take it as a grain of salt that these things are required to interpinix the hardware with the device few so doing a quick comparison why do you need a MicroPython when there is already a Python available under your OS or there is also something called Arduino there is also something called C Python or the classic Python is there so I'll tell you about the Micro Controller that is a very constrained device having few kilobytes of RAM few megabits of Chrome so Python fitting an entire Python language is not possible in such a constrained environment talking about the Arduino Arduino is a really good tool to start with most of the makers starts with Arduino only but again it's a compile language it's a very heavy language based on actually a wiring language the Arduino IDE stuff and all the drivers you need to install the best part I like about the MicroPython or CircuitPython is the code list on your device itself so you can plug in the device with the USB cable you can fire up a serial console you write the code you save to it and you don't need to compile anything you don't need to do all kind of cross-compilation, linking, loading not at all you just need to write the Python code and you are going to go so these are some boards supported by MicroPython you can see that's official Pyboard this is also BBC MicroBit ESP8 to W6 is one of my favorite and that's the Dinsy another of my favorite boards, a lot of more boards are getting added daily so recently they are adding support for Nordic NRF 52 I guess which is a BLE Bluetooth Low Energy based board so that will enable you to do some Bluetooth based projects like controlling things with your phone, controlling things with your laptops doing some Bluetooth stuff and that all you can do with MicroPython so these are the boards supported by CircuitPython and these are some amazing boards so these are mostly based on M0 chip they call it, that's a Sandy 21 chip by Atmel and again you can see this round board form factor, these are mostly common for variable electronics projects so these pins are there which you can see with a conductive thread on your clothing you can do different kind of variable stuffs and cosplay, so amazing boards they are and here you can see the Trinket, that is the smallest ever board which can run with Python so I'll show you one of my projects where I have put that in and that's really cool so there's a maker's favorite board known as ESP8266 I don't know if you have heard of this this was coined as the cheapest Wi-Fi microcontroller available in the market so Espresso is a company which made ESP8266 and fortunately we have a guy giving a talk about this from Espresso who is there he will be talking about this and ESP82666 and coming talk so that is like the cheapest Wi-Fi you can get today and I guess it was only $5 so every project wanted to support this board because it's a so chip and IoT was so hot back then when it first introduced so again MicroPython did another crowdfunding campaign to support this ESP8266 talking about this board this is having 160KW of RAM it is a H02R11BGN IEEE Wi-Fi standard 4MB flash it has a few GPIOs ADC, I2C and SPI but down the line something happened and CircuitPython dropped the support CircuitPython compared to MicroPython wanted to have more good user experience wanted to give more intuitive user experience to the developers of CircuitPython so ESP8266 doesn't have a native USB support but that means when you plug a USB to your computer with ESP8266 it cannot do USB protocol it relies on a third chip and another third part chip which can convert USB to the language which this board understand so there is some complications around that and so ultimately MicroPython decided to drop the support it also doesn't have SSL and TLS so you cannot do some secured IOT projects which AWS or other services wanted you to have and again less GPIOs are there but definitely using CircuitPython you can use it as a co-processor so what that means is you have a main processor and then you interface this ESP chip with that main processor and then you can do Wi-Fi thing so how you do that ESP is a serial model so it can talk serial communication so you connect this ESP chip using serial wires to your main processor you can write code in Python or MicroPython and then you can do the Wi-Fi thing so that option is already available with CircuitPython but also this happens and ESP32 which is a bigger brother of 8266 came into picture it has more power more memory SSL and TLS support is there but again they have USB support so again CircuitPython support is not there but you can use it as a co-processor and the best thing is you can use it over SPI so you can get more speed out of it okay coming back to MicroPython and CircuitPython these are some of the libraries supported and because the libraries written for the native Python were so huge were so not optimized to run on constant environment the community did this kind of thing where you can see a new written or you written in front of the library so there was a Zlib library already with the Python but that was a big massive library so what they did is use Zlib so that is specific for MicroPython and you can do like Zlib compressions you can do time, you can do construct there should be a garbage character somewhere so these are the MicroPython supported libraries which you can use in your projects and the best part is you can use it directly as you would do in a Python community and you can do everything the API provides okay so there are different ways you can interact with your board and I will show you a couple of them but before let's discuss about them so when you plug a CircuitPython board which has a native USB support it shows as a drive called CircuitPython so it bootups as a drive and in this drive you can see there are some other files so you put your code in the code.py file and as soon as the board boots up the code executes so that is the beauty of CircuitPython you do not need to do any cross-compilation you do not need to do any twiddling with different softwares you just need to load the you just need to plug the board and you edit the code.py and you are good to go there is also a serial communication which you can do so when you do a print command on a Python that prints to STD out right so what you can do is you can also use print command in MicroPython and that will print out to a serial console so if you are familiar with Arduino ID there is a serial built into it also if you are into Linux there is a Minicom there is a screen which you can use to get the output of the serial command and then it is everyone's favorite the repel or the read, evaluate, print loop what basically it allows you to you can code live using the repel so whatever you are writing it gets interpreted in a real time and it gets run on the hardware in real time so that is the beauty of MicroPython you can just plug the board open the serial connection you can start writing the code this is the web repel especially for the ESP8266 board what it does you connect your ESP8266 board with your home wifi your laptop is on the same wifi you open the web repel and over the TCP sockets you can send your code so that is the availability of the tools where you can track the board this is one of my favorite if you do not want to invest straight away to a board you can go to micropython.org slash unicorn there is an emulator there is a pie board and there are different LED servers and all kinds of hardware available so you can directly code there before buying a board so that is another good thing and another one of my favorite thing is the MicroPython live so community what they did they attached a board they attached all the hardware that you will need with it and they put a live camera so you can code on the real time and you can see output on the camera and obviously a lot of people would be doing at the same time so that the job would be processed by a scheduler so you can do that right now micropython.org slash live I guess it is somewhere in Ireland, China I am not sure so here is a comparison how the before micropython world looks like so if you wanted to blink on LED so in hardware in hardware we call blinking an LED as a hello world of hardware so you put on an LED for once again you put it off for once again so before the micropython that is how you do it in a C file in a C programming language and that is for an AVR microcontroller so what you have to do include a board definition file which has all the pin mapping you do some bit shifting or operator you can see I do not want to go into details but that is how you write a code for blinking LED then you use a tool chain you cross compile it you flash it on your board using a flasher tool and an external hardware flasher and then you are able to blink on LED and that is how you do it on a micropython you connect the board you open the code.ty file you put in some lines and that is how you do it so that is the difference between a classic C programming versus a micropython of course there are some head offs like the speed would not be that good that would not be real time but for small 4k project it is not bad so what is new so circuitpython community is one of the amazing community out there they are growing massively bigger day by day they are doing releases like for every month and the next release they are planning to support NRF 52 840 BLH chipset so you can do bluetooth based project with circuitpython Nordic semiconductor is one of the most popular in bluetooth technology and when the support is provided you can use that api to control and make bluetooth based projects similarly usb midi which is a universal protocol for doing music over usb is also planned to be supported and extending your support for pixel based displays so you can do OLED you can do different tft based displays using circuitpython so that is coming up real soon so may the demo gods be with me i am not sure if anything breaks down don't leave me we will put it down together again so i will quickly show you i will be using a boat called circuit playground by edafoot it is an educational based boat it has a temperature sensor light sensor a lot of sensors on the same boat it also has new pixel LEDs new pixel LEDs are basically RGB LEDs you can use single wire to control all the LEDs so it is like a daisy changing thing going on so as soon as i plug the boat as soon as i plug the boat you can see a drive named circuitpython so how do you update the software how do you port the micropython on it it is as simple as just taking this uf2 file and dragging it on top of it so you just drag it and it will update to the latest version so that is how simple you do not need an external programmer you do not need an external flasher it just works on the usb so this one also you can use id or tool known as move being developed by edafoot as well so we will use to do different things so i will show you how to blink a quick LED so let us move to this unicorn editor there you can see the pie board let us do a quick LED so this pie board has built in LED let us blink that so we will import the pie board library using importpyp for delays we will import a time module we will run a forever loop so pyv.led refers to the onboard LED so using the on command we will put it on and then we will do delay of one second just to verify that i am not cheating here there is no LED blinking right there you can see so we will do LED off and then we will do a sweep again and you can see that LED is blinking over here so using just four commands of python you can run on the hardware and that is the micro python and i will show you the same for circuit python as well so that is the blink program circuit python you import a library called cpx cpx is basically the board decoration for this board circuit playground express and this is the mo editor we will paste it over here and we will save this file so you can see that it is start blinking so it is directly being saved on this drive under the code.py file so you need to edit the code.py file and as soon as the board boot up it is run that code.py file so let's do some other things with this board there is one more thing i wanted to show you so one of my favorite feature of circuit python is it supports usb-hid so do you know what is usb-hid anyone raise your hands so usb-hid is a human interface device but it can do the keyboard the mouse the joystick that runs on usb-hid protocols so because these boards have native usb support it can act as a keyboard it can act as a mouse so your operating system when you practice board will think that you have the keyboard so you can program this board to send keystrokes to your computer so i will show you a quick program where i will lock this computer using a key combination being sent from this board so here is a small program so this board actually have one small user button over here i have programmed it whenever i press this button it will send the combination control command and queue and that is the combination for locking the macOS which i am running here so i will copy this code i will put it on my IDE i will press a reset button and i will save that into the code.py file so hopefully when i press this button the computer should lock and it does so i am just sending keystrokes using this button and imagine the possibilities like it has a light sensor so what you can do is you can cover the light sensor and then send the keystrokes so you can play with different kind of sensors and using the circuit by then one more time just press the button to get locked the last demo i wanted to show you is one of my favorite my favorite peripheral of all time is NeoPixel LEDs i just love LEDs like who knows so let me show you a quick program to control LEDs with colors so i won't be going through a code but it is just adding some colors, removing some others and doing some animation so this board actually has 10 NeoPixel LEDs so i have programmed them to do different things so doing a reset and then i will save this as soon as the board appears so you can see this is running on the python you can see different animations you can do and you can do all kind of colors you can do all kind of intensity so that was the one demo i wanted to show you coming back to the slide python and on my shoes that is one of the project i did while i was in university so i like to flaunt to the geeks like see python is running on my shoes that was i call fire walkers and that is a cool shoe so actually it is having the same LEDs which you can see over here i can change the pattern over the music in the nightclub i can change the pattern on number of my feet and it can bring when i complete a full lap which i programmed it for 5 kilometers everyday so there is an accelerometer right there there is a small board this small running a python so all the board is running on the python and that is amazing you can flaunt that python is running on my boots there is also one more project that i did for fancy lab conferences where you can just run python on the display and do a name tag on your bowtie so that is a bowtie not for contests like prepositions more like a fancy lab conference where you need to wear a bowtie so you can do like these kinds of different things that is a whole display right there so that is a circuit python mascot called and i had approved the company i requested them to send some stickers for you guys so you can put it on your laptop so feel free to collect it from me and before going i just wanted to show you one last demo so how many ironman fans are there so that is a small architecture made from this and i wish i would be having some black color t-shirts i would put in over here just flaunting guys i know you're all jealous don't subscribe me on youtube shameless plug thank you very much for joining the stock my name is san thank you i was just wanting to raise this bro so well let's thank this friend i think we have ample time for discussion if you have any questions feel free we have some time if you wanted to tinker yourself with the board feel free to take the board as well so i'll take a few questions i'll take a few wait a moment please how do we like install micrometer in our computer so we can program it okay so you want to try micrometer on a computer before you buy the board right so there's a micrometer emulator if you go to micropathons.org it's available for linux so you can install that and then you can try micropathons before trying on the board also as i showed there is a online editor for micropathons.org slash unicorn you can also use that questions guys won't pass me with questions so other communities are making this around the board how do you use about makers and your board what do you do personally okay so specifically for micropython and circuit python they have their own communities they have their own separate forums especially circuit python forums is very active they have their discord channel as well also there is a weekly newsletter and they have tons of subscribers all over talking about the maker community and the maker boards and all kind of things so i use a hackaday a lot hackaday.com then there is hackster then there is instructables i also use a couple of magazines that are in my country i'm not sure there's also like one or two free open source magazines that you can read one is hack hackspace i guess and one is micrometer so these two i do