Raspberry Pi Pico - Review and Getting Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there my name is gary sims and this is gary explains now the raspberry pi foundation seems to be continuing in their search for some form of validation in this world by bringing out a new product that is nothing to do with the raspberry pi as we know it of course recently we had the raspberry pi 400 kind of that culmination of that dream to bring back a home computer from the 1980s to the uh 2020s and i'm not saying it's a bad machine it is a good machine and it does fulfill that role and now the foundation's gone completely the other direction down to the microcontroller level so here it is the raspberry pi pico it's a very interesting board there of course so many microcontroller boards in this world from arduino and just so many others but here it is they thought they wanted to produce one as well so let's have a look at it let's see how you get it up and running with it and how you use micro python on it so if you want to find out more please let me explain okay so the traditional raspberry pi boards are able to run full operating systems so you can run linux on them you can get a desktop and you can connect usb and wi-fi and bluetooth and you get a kind of that full computing experience and as i said that's kind of the fulfillment of that is the raspberry pi 400 with the built-in keyboard and all that kind of stuff now at the other end of computing you've got micro controllers now microcontrollers are different to the processes that you get in the normal raspberry pi for a few reasons the first is they run at a very very different clock speed so a raspberry pi is one gigahertz and upwards a microcontroller normally runs at 48 megahertz 133 megahertz as is the case of the raspberry pi pico 200 megahertz that's kind of like the maximum you get secondly there's no virtual memory hardware that means you can't run an operating system like linux because there's no way the hardware can do virtual addressing and of course because of all that it also means that it's much much low power so that when you turn it on you can run it from maybe a battery pack or some kind of little cell battery and it might run for months at a time i'm sure there'll be some interesting tests about how long a ra a peat rose by pico can run on different types of battery setups and the last thing is that when you start it up it starts up instantaneously it's not booting up linux you're not waiting for the desktop to come up you're not waiting for the moving your mouse till it starts moving and it's all there it comes up in kind of you know just uh under a second and the program that's kind of on the flash that starts running straight away so it's a very different proposition of course it's still very very useful for makers and hobbyists and amateurs who want to be able to use hardware and software python or c and c plus plus to control things like stepper motors and read temperature sensors and display driver you know use display little character displays all that kind of stuff you can do all of that with the raspberry pi pico another thing of course is the cost these only cost four dollars so if when i ordered when i owned two straight away because i said well might as well have two here i could be using four different projects now it's interesting question of course should you buy a raspberry pi zero which is five dollars without the wi-fi or rather by pico for four dollars obviously we're talking just a few dollars for either boards and of course they are different as i said the other one will run linux you need an sd card in it you need to plug in your keyboard and the display and it runs a full desktop when you boot it up it might take a you know a minute or so to boot up this is a micro controller very different lower speed low performance but boots up almost instantly and starts running the program that you've got here on the memory let's take a quick look at the specification as i said runs 133 megahertz dual cortex m0 plus cores in here and that's why it's called the rp204 oh that chip there is the rp2040 the two standing for dual core the zero part standing for cortex m0 in this case m0 plus then the last two are about the amount of ram and the amount of storage so this has got 264 k of ram and it's got two uh two megabytes of internal storage there's an led that's built in so it will you can program it to flash pretty simply without having to build any extra circuitry and of course usb for powering it up for putting programs on it flashing it and also you can get some serial debug information over this as well talking of debug there are also pins for proper hardware debugging which they tell you how to do which you can actually do from the raspberry pi without having to buy any special uh debug hardware so that's a good advantage of using the raspberry pi to program and control this okay so what we're going to do is we're going to look at how you get a micro python so there's a micro python interpreter which you can put on the flash and then you can put python programs onto the flash as well and it will run that python program all the time so it kind of boots up into the interpreter then runs the python program a really super easy way to get kind of simple projects up and running so the first thing you need to do is download fonny now fonny is a python integrated development environment you can get for windows and for linux and for mac os of course you get it for the raspberry pi as well now i'm going to be showing you how to do everything on windows a lot of the documentation that the raspberry pi foundation have released assumes you're using a raspberry pi itself to talk to the raspberry pi pico and that's a good idea and they can guarantee that setup because of course they have the raspberry pi as theirs and the raj by pico is there and they can show you how to get that working i'm going to talk mainly about how you do it under windows because i think most people who are going to get into this will probably have windows on their desktop and they'll want to use it this way of course there are instructions online uh for how to do it from linux with the raspberry pi or linux if you're using linux desktop or even from mac os now downloading installing thon is pretty simple you download it from the website you go through the fairly standard installation procedure and then the program will be installed now once it's installed you need to fire it up and you need to go to run and then you need to go to select interpreter and then from the drop-down list you need to make sure you pick the raspberry pi pico now if you're using thoni 3.3.3 or greater then it understands what the raspberry pi pico is and you don't need to do anything now there are some plugins if you're using an older version but my recommendations you go with the newer version it understands what this board is and you just say yeah please use that and it knows everything that it needs to do so let's take a look at how you get micro python running so to get micro python on your raspberry pi pico you need to go to the getting started page there'll be link in the description below you scroll down here here you'll see three tabs the board specification getting started with micro python and also how getting started with c c plus plus today we're looking at micro python if you scroll to this tab here there is download the uf2 file click on that and download it and save it somewhere where you know on your pc it's really easy to get new binaries onto your pico what you do is press that boot select button connect it to the usb and then it will appear as a usb drive on your computer you can see here it's appeared for me as drive n you might have a different drive letter but the important thing it says r rpi rp2 and you'll see these two files in there you don't need to touch them but if you look here on my desktop here is that download of the macro python that i had and all you do is you just drag it over let go and that will copy onto the board and then the board will automatically reboot into micro python it's also worth mentioning if you don't want to do the whole drag and drop swing from the desktop if you're inside of sony and you've got the right interpreter selected you can click on the install or update firmware it will go and get that automatically from the internet for you and allow you to install it okay so we're back inside sony and i've altered the font size and everything so that it's easy to see on the screen now down here at the bottom you can see it says macro python 1.4 raspberry pi pico so this is actually the python interpreter running here using the command line that you can use inside of python but we're going to write a program and we're going to start with the very simplest program just going to say hello pico okay simple as that i'm assuming you know a little bit about python i do have a one or two videos about python on this channel if you want to brush up on some of your python skills now once you've typed in your mega complicated program here we have this print statement what you need to do is you need to save it so you go up here and click on the save icon and it will ask you because phony in fact can be used as a desktop you know just a normal desktop python environment it says do you want to do it on this computer or on the raspberry pi pico i'm going to say on the raspberry pi pico and then it says please give a file then if you do main dot py what will happen is whenever you reboot the pico connected to the power it'll run that file automatically so it's the it's the program that will run as soon as it gets to the power so that's what we're going to do we're going to say okay and there it is now saved on the machine and if we go up to this little run button here we press that and it will run it and as we will see down there the font is actually smaller there but it says hello pico exactly what it is that we wanted to do so you could now start writing python programs here and have the output come out there on the little sort of the display the little connection they've got to the pico board but let's do something because this is a microcontroller let's do some controlling of things so of course the best thing the first one is always to control the led and there is a built-in led on the board it's connected to gpio pin gpo general purpose input output gpio pin 25 so we're gonna write a very small program that can flash that on and off very very simple two lines to start with about importing things from machine that's one of the libraries provided import pin pin gives you access to the gpio pins okay and also we want to import you time because we want to do a sleep make the program go to sleep for a little while because that's because we're flashing the led we want it to flash on and off so we're going to define a variable called lead led and we're going to say it's connected to a pin and it's pin 25 and it is what an input or an output well it's an output pin so that's the pin object they give you as part of the micro python and it tells you we want to better control that pin for output now we have a while loop and we're going to go around forever and ever so we say while true and then what's going to happen first of all we're going to turn the led on so you say lead value one pretty simple then we're gonna sleep for one second so we can say u time uh dot sleep one so it sleeps for one second then we say lead value zero turn the led off again this is really you know advanced stuff here and then again we go back to sleep and then of course it will go around in a loop turn it back on again wait another second and so on and so on now if you just click the run button it will run the code that's inside of the editor if you want to make sure the file is actually saved onto the pico so that it's always there for when you reboot you do need to hit the save button first and then the run button and then it will start working if you're just kind of doing rapid development here you could just keep running the run button but you've got to know that the set changes aren't saved actually on the picot itself let's just hit the run button and now as we can see the led is flashing there on the pico board so i have a little circuit that i've built using a breadboard i've checked out two important things one is the uh oled display we'll talk more about that in a minute and the other is i've checked up an led with a resistor and i've connected to gpo pin 14. here's a quick look at the gpo layout for the pico it's freely available on the raspberry pi pico documentation which you'll find on the raspberry pi website now what we're going to do is we're rather than flashing the internal led now let's flash that external led and we can do it slightly different way we're going to do it using a timer so what we do start off with is from machine import pin as we did before but also import timer so what a timer does it fires off at a certain interval and runs a particular function in your program it will do that regularly same again we're going to say led is equal to pin this time we're going to go with pin and it is an output and now we do certain things like different we say tim is equal to timer so we're creating a timer object and now we're going to find a new function which we're going to call tick you can get which will get called every time the timer is run okay and inside the tick what we're going to do is we want to say we need access to that variable called led so we'd say give me global access to that one and now there's in fact there's a toggle which means if it was on it goes off if it was off it goes on as simple as that and then the final part of the main program now we're outside of the function now we finished that is you say tim that's our timer object init initialize it please frequency okay well we're going to go with 2.5 times a second so this isn't the sleep intervals how often might happen per second mode is equal to timer dot periodic periodic and callback what function do you want to call every time the timer fires what we want to call tick so it achieves the same thing it turns the led on and off but it does it by a macro python running a timer in the background when that timer is expired it fires off the tick program resets the time automatically and just keeps doing that every two and a half seconds you can have multiple timers running very very useful way of getting things to happen on a regular basis and now if we run this we'll be able to see the led that we connected up to the system is actually flashing now also i would mention the oled display now there are some packages for support for different types of display the oled display that i'm using is using the ssd 1306 i squared c interface it's fairly simple i squared c means you only need four pins two of them for power and then two of them for the i squared c so it's very easy to wire up to the right pins on the raspberry pi pico and then you just use the right software package to control it let's have a quick look at the micro python for doing something on the display okay the first step is you need the python file that is the driver for the ssd 1306 and that is under the raspberry pi github repository i'll leave a link to this precise file in the description below all we do let's go to the raw version you can just quickly see here it's just this code that they've provided for how you talk to the is squared c this device we don't want to worry about it we'll just click raw and we'll just select all of the text in there and then we'll go over to the funny ide in the funny ide you want to paste all that code here i've got the big font as i said earlier so there we go there it is there and we want to save it on the pico and we want to call it sd 1306 if you haven't got that file just type in sd 1306 down there and it will save it on to your pico now the next thing we'll do is start another file here and this will now be our main dot python and we want to do something with the display so what i've got here is a very quick program that uh calculates prime numbers using division by trial division doesn't use a civ or anything like that and then it writes it out onto display so what does it do first of all the imports that we can use the display sets of the size of the display here 128 by 32 sets up the i squared c interface and then finally actually says uh here is the i squared c for the oled then you fill it all with zeros to make the text go black you can add in some text which i've done here and then finally you say show to actually updo the actual update you can do things in the background then when you do show that's when it actually does it at the same time we're going to use our little timer that we've done before little timer here that will flash the uh the led on pin 25 okay and that's just going to run in the background so we're going to be doing multiple things we're running the timer flashing the led and we're going to be doing the prime stuff here is just a simple prime test uh written in python and finally what we do in the main loop is we say this we say for the first uh million uh numbers let's test to see if it's prime if it is prime then blank out this section here with a zero zero means black there then write the text okay which is basically the prime number p there and then show it so basically every time it finds a prime number it will update the display and show it and it's as simple as that so you once you get the i squared c library working and the ssd 1306 library where can you just use the uh the text and the fill commands that come as part of the frame buffer uh thing frame buffer library you can see all the documentation for that is available of course online and you just basically write to the display so let's just save that on there and run it [Music] okay that's about it so there we go the raspberry pi pico another product in raspberries pies up i wonder what they'll come up with next okay my name is gary sims this is gary explains i really hope you enjoyed this video if you please do give it a thumbs up i read lots lots of comments about people saying they're not getting uh their videos recommended so really the best thing to do is to not use youtube's recommendation algorithm not rely on that but subscribe to the channel click that bell notification icon and then you will know when i've uh dropped a new video okay that's it i'll see in the next one [Music] you
Info
Channel: Gary Explains
Views: 39,085
Rating: undefined out of 5
Keywords: Gary Explains, Tech, Explanation, Tutorial, Raspberry Pi Pico, Raspberry Pi, Microcontroller, Cortex-M0+, MicroPython, RP2040, SSD1306, OLED display, microcontroller board, microcontroller board from Raspberry Pi, RP2040 microcontroller, Arm Cortex M0+ processor, Dual-core Arm Cortex M0+ processor, I2C
Id: Csmu8svTN4s
Channel Id: undefined
Length: 18min 32sec (1112 seconds)
Published: Mon Feb 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.