I'm going to show you how to upload MicroPython scripts to your Raspberry Pi Pico using RShell. Using RShell means we're flashing our script to the Pico. We can remove power, plug power back in, and it'll just pick up that same script and keep running it. Let's do it.
We'll start by opening a terminal. On Windows, that's PowerShell. And we'll just need to check that we have a couple of things installed. We're going to need Python, so I'll enter Python version, to query what version of Python we're running, and I get some result. And also pip version. So I already have both Python and pip installed. If you have a problem with either of these, I'll show you some links to get Python and pip. I also recommend keeping pip up to date using one of these commands.
With that taken care of, we need to install RShell. And all we have to do is execute pip install RShell. And if everything goes well, then we can just execute RShell version, and we get some result. So we have RShell installed. Now let's connect to the Pico using RShell. To do that, we'll need to know what serial port it's using. We've covered that in another video. Execute RShell. And now the P option for the COM port we're going to use. Today I'm using COM port 4. We have to set the buffer size to 512 for the Pico. If I execute that...
So a lot just flashed up on the screen just now. The important things are the root directories. At the moment, there is nothing shown here. There's no files on the Pico. But importantly, the board name has been called PyBoard. And this is a bit of a default for RShell. We'll need that soon. Also good to note that the prompt has turned green here, and that's telling us that RShell is currently running. So commands we execute will be RShell contextual commands. Let's upload a script.
In my documents directory, I've created a folder called code. And inside that is just a small script called main.py. Really briefly, all this script does is set up a timer. And every second, that timer will call a function. All the function does is toggle the state of the onboard LED and print some text to the console. Let's use RShell to upload that script. I'll first cd into documents. And it was in the code directory. If I perform a list statement, we can see the script is right here. So all I need to do is copy that to the board. So I'll execute cp. And I want to copy main.py. Now, remember before, the board name is PyBoard. And that's where we want to copy it to. We want to copy main.py to slash PyBoard main.py and hit enter. And as easy as that, we've flashed the Pico. I'll just power cycle it. I'll plug that back in. There's our flashing LED. I'll also open up Cool Term and connect to it via serial. We also did this in a previous video. And there we have our print statement coming down the screen.
If you ever want to exit RShell and return to your regular prompt, all you have to do is use If you ever want to exit RShell and return to your regular prompt, all you have to do is use control+C. And now you'll see that the prompt has turned back to white for the normal prompt. There you have it, using the power of RShell to upload scripts to the Raspberry Pi Pico. Now, RShell is a command line utility. There's a lot of other options to explore. And there's a fair bit of power that you can achieve with automation using these tools. So be sure to check out the documentation for RShell. I'll see you next time.
Makers love reviews as much as you do, please follow this link to review the products you have purchased.