Old V2 Pico Software - alanbjohnston/CubeSatSim GitHub Wiki

Step 2a: Raspberry Pi Pico Software Install

Installing Arduino Software

First, you will need to install the Arduino IDE software so you can compile the STEM Payload code that runs on the Raspberry Pi Pico microcontroller.

We will do this and verify it works by doing a Blink Test with your Pico.

Blink Test

To do the blink test, you need to program your microcontroller. Here are the basic instructions for the Raspberry Pi Pico or Pico W.

I'd recommend using the Arduino Integrated Development Environment (IDE) application to program your Pico, although you can use other IDEs too. Use the 1.8.x version instead of the new version 2 since the new version has some issues with the Pico board. Download it here: https://www.arduino.cc/en/software You will need to scroll down to find the "Legacy IDE (1.8.X)" version to download.

You can even install the Arduino IDE on your Raspberry Pi Ground Station using the "Linux 32 bits" version.

Before you can program your Pico using the Arduino IDE application, you will need to install the board files for the Pico. First, you need to go under Arduino then Settings to open the Preferences and look for the he Additional Boards Manager URLs field. Type this URL https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json into the Additional Boards Manager URLs field:

Select OK. Then open the menu Tools/Board/Boards Manager which will open the Boards Manager. In the search box, type pico then return. You will see the Raspberry Pi Pico/RP2040 by Earle F. Philhower, III Board file which supports the Raspberry Pi Pico and Pico W board.

Click Install and after a few minutes it will show as Installed.

Close the Boards Manager. Now open the Blink example code under the menu File/Examples/01.Basic/Blink and open this sketch.

Go under the Tools menu and select Board and select Raspberry Pi RP2040 Boards. You also need to select the correct version of the board. Select the Raspberry Pi Pico W (this will work even if you have a Raspberry Pi Pico without WiFi). If your Pico has never been programmed, you won't need to select the Port. Instead, you will notice a USB flash drive called RPI-RP2 that has mounted on your computer.

Click the Verify icon (check symbol) at the top to Compile the code. If that works, you are ready to try uploading your code to the Raspberry Pi Pico microcontroller.

You will need a Raspberry Pi Pico W (a Pico works as well but doesn't have WiFi for future features) and either a micro USB cable:

IMG_3874

Or a USB-C cable with a micro USB adapter:

IMG_3867

Plug the other end of the USB cable into your computer.

If you are doing this for the first time, you should be able to just click the Upload icon (arrow pointing right) to upload it to the Pico. You may get a popup about a drive being unplugged - just ignore this, it is normal. If all goes well, the built-in LED in your Pico should be blinking on and off!

Now if you look under Tools/Port you will see a new port labeled Raspberry Pi Pico W. You may have to select this port manually in the future after you plug in your Pico to reprogram it.

If the Upload fails with an error, you might need to manually select the Port. Under menu Tools/Port look for one that says Raspberry Pi Pico W and select it. If you can't find it, try unplugging the Pico, noting the ports listed, then plugging it back in. The new port listed will be the Pico.

If you have difficulty programming your Pico, see the notes here: https://github.com/earlephilhower/arduino-pico#installing-via-arduino-boards-manager

Payload Sensor Testing

You can now test that the Pico can communicate with the two sensor boards. Even if the boards aren't wired up yet, you can install the libraries and code so that you are ready to test them.

Here is the code (sketch) that runs on the Pico:

https://github.com/alanbjohnston/CubeSatSim/tree/beta/stempayload/Payload_BME280_MPU6050_XS

You will need to click on each of the two files, then select download raw file to download both files (Payload_BME280_MPU6050_XS.ino and payload_extension.cpp) and put them both in a folder named Payload_BME280_MPU6050_XS. Open the Payload_BME280_MPU6050_XS.ino in the Arduino IDE software. It should look like this:

This code requires several libraries which you will need to install. If you forget to install one or more libraries, you will get error messages saying "No such file or directory" when you Verify or Upload the code.

Open Tools/Manage Libraries and the Library Manager will open after a few moments. In the search box, type bme280 then return and you will see the Adafruit BME280 library. When you mouse over it, it will give a version pulldown menu and an Install button. Select version 1.1.0 and click on Install to install it. You will be prompted to install a few other library dependencies as well - select Install All. It should look like this when it completes:

Next, type tockn then return in the search box and install the MPU6050_tockn library and click Install to install it. Type tinygpsplus into the search box and install this library as well.

Click Close to close the Library Manager. In the sketch window, click on the Verify icon (checkbox) and it should compile without errors.

If you get an error saying "No such file or directory", go back to the Library Manager and make sure you have installed the correct version of all three libraries. Click on the Upload button (right arrow) and the Pico should be programmed to read the sensors.

Once it is done uploading (indicated by the Done Uploading) message at the bottom of the window, open the Serial Monitor by clicking on the magnifier icon in the top right of the window. You should get a response displayed similar to this updated every second or so:

OK BME280 0.0 0.0 0.0 0.0 MPU6050 -0.02 -0.02 -0.02 -0.00 -0.00 -0.00 GPS 0.0000 0.0000 0.00 TMP -34.50

Squelch: 1

If your sensors are wired up to the Pico, you should see non-zero data such as this:

OK BME280 24.89 1003.96 77.61 21.13 MPU6050 -0.85 -2.48 -1.09 0.19 -0.15 1.02 GPS 0.0 0.0 0.0 TMP 22.3

The OK is the status response. The four numbers after the BME280 are the temperature in Celsius, pressure in hPa, altitude in meters, and humidity in percentage read from the purple BME280 sensor. The six numbers after the MPU6050 are the X, Y, and Z axis angular rotation in degrees per second and the X, Y, and Z axis acceleration in g. If you get a series of zeros after a sensor, it means it was not successfully read by the Pico. The three numbers after GPS are GPS latitude, longitude, and altitude which will be zero unless you have connected a GPS module to your board. After the TMP is the temperature estimated from the diode D3.

If your Raspberry Pi is also connected, you can also use the CubeSatSim/config -p command to see the sensor data from the Pico.