MicroPython #1 - Lets Get Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Nice. Saw it yesterday. Pretty good introduction. Looking forward to playing with the tinyPico.

👍︎︎ 2 👤︎︎ u/J_Tarasovic 📅︎︎ Apr 01 2019 🗫︎ replies

Great job on this. Please keep it up!

I'd love to see more bluetooth/ble tutorials... once they get it worked out for esp32/micropython.

👍︎︎ 2 👤︎︎ u/Uggamouse 📅︎︎ Apr 02 2019 🗫︎ replies

Subscribed

👍︎︎ 2 👤︎︎ u/[deleted] 📅︎︎ Apr 13 2019 🗫︎ replies
Captions
let's start off with what is micro Python micro Python is an implementation of regular Python that's used on computers often called C Python they're designed to be lightweight and compact so it can run on many microcontrollers and embedded systems microphone is based around Python 3 but with extra modules like a machine that gives you direct access to the hardware on your microcontroller the ESP 32 is an amazing hardware platform for micro Python it's one of the main motivations from your designing my tiny Pico working with micro Python isn't anything like working with the Arduino IDE let's have a look at the differences and once micro python is a really great alternative to working in c micro Python lives on your microcontroller and exposes the file system that you can add your code to you can store as many micro Python scripts and libraries on there as you like until your file system runs out of space and any code you want to have run when the device boots just needs to be in a file called named PI unite we know C you compile your code against the IDF and the Adreno quarries and then you flesh your code onto your micro controller if you want to change in your code you need to load it back up in the Arduino IDE change the code recompile and reflash the code is machine code so it's faster to execute that can't be altered or easily copied back off and reused micro Python executes byte code at runtime so though it's not a runtime interpreted language it's not as fast as machine code but micro Python can use c modules that are compiled to machine code and can now also use assembler modules in micro Python you can invoke the ripple and type and run code directly on the microcontroller so testing an iteration times are super quick reading and understanding micro Python is easy it's almost just like reading English it's a modern and advanced language that supports features like tuples and comprehensions where strings and Jason are natively and intuitively implemented it's a pleasure to work with let's have a look at how we can get micro Python on our SP 32 there are two ways to get micro Python the first one is via source code which left to compile yourself so at the github.com slash micro Python URL you'll find micro Python and what you want to do is go to the microphone folder you want to clone it or download it it's up to you you'll need the whole micro Python install but the instructions to actually compile for the SBT - is inside ports SP 32 and down here you'll find a lot of steps and instructions on how to actually be able to compile and build markup - from source you'll need to download the expressive RDF which is the a P I for the SP 32 there's quite a few steps involved for a platform to get everything going a few things you'll need to install along the way some config files you'll need to set up some paths and then you'll be able to just do make arrays to delete what's currently on the board and make deploy so it's super simple to update and build like a Python and deploy it to your board from source once you followed all those steps if you need a microphone I don't recommend you going this way what I recommend instead is you go to micro python.org which is the home of markup Python you can just go straight to download you can see the different board set Michael - supports right now I'm going to go to a SP 32 and you want to just download the latest binary so it's already pre-built for you and we're going to be using a SP tool which comes with the arduino ide and the IDF - arrays and reflash micro python onto your microcontroller board so we're gonna do that now I've already downloaded the latest micro pythons I'm going to be installing it on my tiny Pico board so let's do an arrays and build and flesh of my co Python okay I've already got my microphone binary downloaded I've got it in a microphone underscore bin folder in my downloads as you can see here there's just the one file in there the instructions talk about port and slash dev slash TTY USB in my case it's not TTY USB that would be a linux thing in my case I'm using the CP 2104 from Sai labs so what I'm looking for is a Sai labs device so the easiest way to determine what device you've got is to do an LS / dev slash it'll be a TTY something so TTY now you can do a star and it's gonna list everything that's a TTY in my case I know that there's a dot before so do a dot star and I can see that there's a slash dev slash TT y dot slab so celebs USB to UART so that's going to be my device name instead of slash dev slash tty USB it'll be different on your machine depending on your operating system and what board you're installing it from for instance if it's got a SCH 340 on there it'll be a different name so the first thing you want to do always is an erase now what an erase will do is either clean out any microphone install that's already on the board or will clean out any other microcontroller code that's on there maybe from the arduino ide or from the IDF something to make it really easy for myself i'm gonna copy and paste the first part base my port I'm gonna go slash dev slash TTY dot s I hit tab to do autocomplete and then arrays flesh that's gonna look for the board it's going to try to connect to it found it it's doing an arrays right now and it's done and it's done at reset it took 3.5 seconds to do and it raised awesome so right now there's nothing on the chip at all so now I want to put my cap Ivan on there so I'm going to do the same thing again copy the first part slice tear / tty dr. s tab now this is writing it out pretty slow 46 o 800 I might increase that I might do a negative board 92 1 600 and I'm just going to copy and paste to hear some being a little bit lazy and then I want to use the binary that's in this folder so the easiest thing to do is just type in ESP and hit tab there's only one file in there so it found the whole thing and hit enter and again it tries to find the device finds it and it starts flushing it and this is installing micro Python onto the microcontroller and it's done awesome so if you're following along at home gratulations you've now got like a Python on your microcontroller how do we know microphone on there well we can type screen and we can tell it the port again there /gt y dot s tab and tell it the speed 11 5200 and I just reset the board so it goes in this particular case there's no RAM on the board that I've got right now but it's booting to like a Python you can see here it's an SP 32 Pico it's been built against the SPI DF version 3.3 and basically I'm now in a ripple so I have got my client on here and from here I can type in like a Python directly hello world there we go we have like a Python on the board ok it's time to talk about how we get code I don't like no controller I tend to work at the command-line and I use a tool called our shell which I'll show you in a moment there is a really cool editor that's being developed called new and here's the website here code with mu which is basically an IDE for Python where it's got a real time ripple in there and everything else and on a lot of boards you can just save it directly to the board and the code will run on the board and the results you get back in mu are actually from the board a lot of work is being done at the moment to extend that to ESP 32 boards the biggest problem with that right now is that there's no dedicated USB on the SP 32 so it's very hard to detect what board is being plugged in when it's just got a generic USB chip so though I hope to be able to use mu in the future right now I believe it's still very early days for the ESP 32 so I am staying with our shell so let's have a look at our shell it's an open-source tool that runs on any platform it's a python-based and basically gives you remote shell directly to your microcontroller board and once you're there you can copy files back and forwards from your main operating system to the microcontroller you can pull up the ripple and type code directly in there it's a very cool tool it can be automated I'm actually using our shell in some of my tiny pea coat SG code to be able to upload code and inject stuff directly to the repple so it's a very extensive tool highly recommend you download you have a play with it I'm going to show you how I use it right now so I'm currently in my micro Python tiny pico folder on my computer which is a helpful library that I'm developing for the tiny Pico from like a Python there's a whole bunch of different files in here now what I can do is just go our shell negative P for port some tools use negative port some reason ADP I'm going to go to dev TTY don't miss and that's it hit enter and it's now connected so I'm currently in my micro Python tiny pico folder as I mentioned so showing you my local space on my computer so I can type LS I can see the same files but I can also do is type LS / pie board now I shall just assumes that all microphone boards are called pie board it was the original micro Python board that was developed by damian george he's actually just released a brand new version of it I'll put a link in the description if you wanna grab one it's a fantastic board but it just calls every board pie board if I hit enter it'll show me what's on the actual SP 32 in this case there's just a boot pi which every micro Python install on any my controller has a boot pi it's basically configuration file that gets run after micro pipe and boots up so we want to put some code on here what we can also do is just type directly before we put code on ripple and it puts me into the repple now a ripple is a real time way of accessing in the microcontroller I can type code directly in here I can even as it says type help welcome to micro Python on the SP 32 awesome and it gives me a whole lot of information on how to exit and enter some example code seshu so before I could just type in print and do something I could also just create some variables I could say a equals 10 and it said B equals 50 and I can say print string a plus B 60 so it's a great way to be able to just test code you can even copy and paste code directly into it but what I want to do in this case I'm going to exit the ripple by doing ctrl X puts me back to my command line of our shell I'm gonna actually copy some code over so I'm going to use CP and I'm going to copy what like copy I'm gonna copy everything over actually so star dot Python is everything for my local directory to pie board it's gonna copy all the Python over and now again I can do LS / pie board and it shows me the files that are run by a microcontroller and from here I can actually just go into ripple and I can say import now import is just like and include in Sealand but if there's actually code inside it it'll run it automatically so in this case I'm just going to go import example this is a file called example dot pi as you can see just here and hit enter and it says hello from Connie Pico checks my battery voltage and it says that my current starts checking my battery is true fantastic I can just hit control C to break out of that and again control X so that's a shell whoa information overload sorry actually installing micro Python isn't that daunting it's no different to what the Arduino IDE does using esp tool when it injects your code onto your microcontroller when you click build so hopefully some of you will take the plunge and install Michael Python or in one of your microcontrollers and have a bit of a play I look forward to part two of this series where I'm going to start looking at how to actually code in Michael Python I'm a microfiber newbie so you're not gonna be getting expert guidance for me you just going to be getting this is what I do and I look forward to catching you all next time catch you later bye you
Info
Channel: Unexpected Maker
Views: 95,927
Rating: undefined out of 5
Keywords: maker, electronics, hobby, projects, arduino, microcontrollers, Espressif, ESP32, TinyPICO, MicroPython, Python, Installing MicroPython, ESP32 MicroPython Tutorial, MicroPython on TinyPICO, Damien George, PyBoard, Rshell, code with mu, how to
Id: 5W3WvXAmDJc
Channel Id: undefined
Length: 12min 35sec (755 seconds)
Published: Sun Mar 31 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.