|
1 | 1 |
|
2 | 2 |
|
3 | 3 |
|
4 | | -Welcome to the SparkFun IoT RedBoard - RP2350 Quick Start Guide. This streamlined version of our standard Hookup Guides assumes a working knowledge of how to use a development board and the required software to program them for your project's needs. It covers a quick assembly and then jumps right into getting the necessary software packages installed to start uploading code in just a few short minutes. The guide finishes with simple examples for each development environment showing how to set up and use the RM2 wireless chip to connect to a WiFi network. |
| 4 | +Welcome to the SparkFun IoT RedBoard - RP2350 Quick Start Guide. This streamlined version of our standard Hookup Guides assumes a working knowledge of how to use a development board and the required software to program them for your project's needs. It covers a quick assembly and then jumps right into getting the necessary software packages installed to start uploading code in just a few short minutes. The document finishes with simple examples for each development environment showing how to set up and use the RM2 wireless chip to connect to a WiFi network. |
5 | 5 |
|
6 | 6 | If you're not familiar with using development boards or the development environments covered in this guide, refer to the Hardware & Software sections for a detailed overview of the board along with instructions on setting up and programming the IoT RedBoard - RP2350. |
7 | 7 |
|
@@ -50,7 +50,66 @@ The IoT RedBoard - RP2350 is supported in **version needed - ML** of the Pico SD |
50 | 50 |
|
51 | 51 | The IoT RedBoard - RP2350 has Beta releases of MicroPython firmware available [here](https://github.com/sparkfun/micropython/releases). Download and install the MicroPython firmware onto your IoT RedBoard - RP2350, open your preferred Python IDE (or CLI) and copy the code below into it: |
52 | 52 |
|
53 | | -**Insert example code -ML** |
| 53 | +**Code to Note**: |
| 54 | +LED control. Values are (R,G,B) 0-255. This sets the LED to full Red. |
| 55 | +``` py |
| 56 | +led[0] = (255, 0, 0) |
| 57 | +led.write() |
| 58 | +``` |
| 59 | +WiFi network connection. Enter values for network ID and password. |
| 60 | + |
| 61 | +```py |
| 62 | +wlan = network.WLAN(network.STA_IF) |
| 63 | +wlan.active(True) |
| 64 | +wlan.connect('WIFI_NETWORK', 'WIFI_PASSWORD') |
| 65 | +``` |
| 66 | + |
| 67 | +``` py |
| 68 | +import network |
| 69 | +import urequests |
| 70 | +import time |
| 71 | +import neopixel |
| 72 | +import machine |
| 73 | + |
| 74 | +# Set up the NeoPixel LED |
| 75 | +pin = machine.Pin("NEOPIXEL") |
| 76 | +led = neopixel.NeoPixel(pin, 1) |
| 77 | + |
| 78 | +# Set the LED to red while connecting to WiFi |
| 79 | +led[0] = (255, 0, 0) |
| 80 | +led.write() |
| 81 | + |
| 82 | +# Connect to a WiFi network |
| 83 | +wlan = network.WLAN(network.STA_IF) |
| 84 | +wlan.active(True) |
| 85 | +wlan.connect('WIFI_NETWORK', 'WIFI_PASSWORD') |
| 86 | + |
| 87 | +# Wait for the connection to complete |
| 88 | +print("Waiting for connection...") |
| 89 | +while not wlan.isconnected(): |
| 90 | + time.sleep(1) |
| 91 | + print('.', sep='', end='', ) |
| 92 | +print('Connected!') |
| 93 | + |
| 94 | +# Set the LED to blue while downloading data |
| 95 | +led[0] = (0, 0, 255) |
| 96 | +led.write() |
| 97 | + |
| 98 | +# Download the list of astronauts currently in space |
| 99 | +print('Downloading list of astronauts currently in space...') |
| 100 | +astronauts = urequests.get("https://corquaid.github.io/international-space-station-APIs/JSON/people-in-space.json").json() |
| 101 | + |
| 102 | +# Print the number of astronauts and their names |
| 103 | +number = astronauts['number'] |
| 104 | +print('There are', number, 'astronauts in space.') |
| 105 | +for i in range(number): |
| 106 | + print(i+1, astronauts['people'][i]['name']) |
| 107 | + |
| 108 | +# Set the LED to green to indicate success |
| 109 | +led[0] = (0, 255, 0) |
| 110 | +led.write() |
| 111 | + |
| 112 | +``` |
54 | 113 |
|
55 | 114 |
|
56 | 115 |
|
|
0 commit comments