# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/100/412/medium800thumb/raspberry_pi_ezgif.com-gif-maker.jpg?1614982665)

Connect your Raspberry Pi Pico CircuitPython project to the internet by adding an AirLift breakout board. The Adafruit AirLift is a breakout board that lets you use the ESP32 as a WiFi co-processor for a Pico.

In this guide **,** you will wire up a Pico to an AirLift breakout and connect to the internet. Then, you'll learn how to fetch JSON and raw text data from the internet. Finally, an example is included for connecting your Pico to [Adafruit IO, the Adafruit internet-of-things service](http://io.adafruit.com/), so you can interact with and visualize your project's data.

![](https://cdn-learn.adafruit.com/assets/assets/000/100/408/medium800/raspberry_pi_adafruit_io_airlift_io.png?1614978922)

## Why use AirLift?

Having WiFi managed by a separate chip means your code is simpler, you don't have to cache socket data, or compile in & debug an SSL library. With AirLift, you can send basic but powerful socket-based commands over 8MHz SPI for high speed data transfer. The ESP32 can handle all the heavy lifting of connecting to a WiFi network and transferring data from a site, and using the latest TLS/SSL encryption (it has root certificates pre-burned in).

[The firmware on board is a slight variant of the Arduino WiFiNINA core, which works great,](https://github.com/adafruit/nina-fw)&nbsp;and&nbsp;**our Adafruit IO Libraries for&nbsp;[CircuitPython](https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO) support AirLift!**

## Parts
### Adafruit AirLift – ESP32 WiFi Co-Processor Breakout Board

[Adafruit AirLift – ESP32 WiFi Co-Processor Breakout Board](https://www.adafruit.com/product/4201)
Give your plain ol' microcontroller project a _lift_ with the Adafruit AirLift - a breakout board that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your favorite microcontroller (like the ATmega328 or ATSAMD51), awesome peripherals and lots of libraries....

Out of Stock
[Buy Now](https://www.adafruit.com/product/4201)
[Related Guides to the Product](https://learn.adafruit.com/products/4201/guides)
![Top view of Adafruit AirLift Breakout Board.](https://cdn-shop.adafruit.com/640x480/4201-08.jpg)

### Raspberry Pi Pico RP2040

[Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864)
The Raspberry Pi foundation changed single-board computing [when they released the Raspberry Pi computer](https://www.raspberrypi.org/archives/723), now they're ready to do the same for microcontrollers with the release of the brand new **Raspberry Pi Pico**. This...

In Stock
[Buy Now](https://www.adafruit.com/product/4864)
[Related Guides to the Product](https://learn.adafruit.com/products/4864/guides)
![Angle shot of Raspberry Pi Pico RP2040](https://cdn-shop.adafruit.com/640x480/4864-00.jpg)

### Part: USB Cable
quantity: 1
USB cable - USB A to Micro-B - 3 foot long
[USB Cable](https://www.adafruit.com/product/592)

### Part: Breadboard
quantity: 1
Full sized breadboard
[Breadboard](https://www.adafruit.com/product/239)

### Part: Breadboarding Wires
quantity: 1
Breadboarding wire bundle
[Breadboarding Wires](https://www.adafruit.com/product/153)

# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/074/598/medium800/adafruit_products_image.png?1555621088)

## Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard -&nbsp; **long pins down**

![adafruit_products_DSC_4190.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/758/medium640/adafruit_products_DSC_4190.jpg?1555967778)

![adafruit_products_DSC_4191.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/759/medium640/adafruit_products_DSC_4191.jpg?1555967778)

![adafruit_products_DSC_4193.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/760/medium640/adafruit_products_DSC_4193.jpg?1555967777)

## Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

![adafruit_products_DSC_4195.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/761/medium640/adafruit_products_DSC_4195.jpg?1555967777)

## And Solder!

Be sure to solder all 12 pins for reliable electrical contact.  
  
_(For tips on soldering, be sure to check out our&nbsp;_[_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)._

![adafruit_products_DSC_4196.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/768/medium640/adafruit_products_DSC_4196.jpg?1555974929)

![adafruit_products_DSC_4199.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/769/medium640/adafruit_products_DSC_4199.jpg?1555975122)

![adafruit_products_DSC_4202.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/770/medium640/adafruit_products_DSC_4202.jpg?1555976027)

![adafruit_products_DSC_4204.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/771/medium640/adafruit_products_DSC_4204.jpg?1555976178)

You're done! Check your solder joints visually and continue onto the next steps

![adafruit_products_DSC_4209.jpg](https://cdn-learn.adafruit.com/assets/assets/000/074/772/medium640/adafruit_products_DSC_4209.jpg?1555976277)

# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Installing the Mu Editor

Mu is a simple code editor that works with the Adafruit CircuitPython boards. It's written in Python and works on Windows, MacOS, Linux and Raspberry Pi. The serial console is built right in so you get immediate feedback from your board's serial output!

Info: Mu is our recommended editor - please use it (unless you are an experienced coder with a favorite editor already!). While it has been announced end of life in 2026, it still works fine.

You are free to use whatever text editor you wish along with a terminal program to connect to the CircuitPython REPL. Thonny is one such editor.

## Download and Install Mu
Download Mu from&nbsp;[https://codewith.mu](https://codewith.mu/).

Click the&nbsp; **Download** link for downloads and installation instructions.

Click **Start Here&nbsp;** to find a wealth of other information, including extensive tutorials and and how-to's.

&nbsp;

![circuitpython_WtCP_codewithdotmu_main_page.png](https://cdn-learn.adafruit.com/assets/assets/000/105/677/medium640/circuitpython_WtCP_codewithdotmu_main_page.png?1634749167)

Warning: 

## Starting Up Mu
The first time you start Mu, you will be prompted to select your 'mode' - you can always change your mind later. For now please select **CircuitPython**!

The current mode is displayed in the lower right corner of the window, next to the "gear" icon. If the mode says "Microbit" or something else, click the **Mode** button in the upper left, and then choose "CircuitPython" in the dialog box that appears.

![circuitpython_WtCP_Mu_mode_dialogue.png](https://cdn-learn.adafruit.com/assets/assets/000/105/681/medium640/circuitpython_WtCP_Mu_mode_dialogue.png?1634750676)

Mu attempts to auto-detect your board on startup, so if you do not have a CircuitPython board plugged in with a **CIRCUITPY** drive available, Mu will inform you where it will store any code you save until you plug in a board.

To avoid this warning, plug in a board and ensure that the **CIRCUITPY** drive is mounted before starting Mu.

![circuitpython_WtCP_Mu_device_not_found.png](https://cdn-learn.adafruit.com/assets/assets/000/105/679/medium640/circuitpython_WtCP_Mu_device_not_found.png?1634749722)

## Using Mu

You can now explore Mu! The three main sections of the window are labeled below; the button bar, the text editor, and the serial console / REPL.

![](https://cdn-learn.adafruit.com/assets/assets/000/098/505/medium800/circuitpython_Mu_Window_Explained.png?1609970219)

Now you're ready to code! Let's keep going...

# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## CircuitPython WiFi

Warning: 

If you have not yet installed CircuitPython on your Raspberry Pi Pico, [visit our Getting Started product page for the Pico and come back here when you've installed CircuitPython](https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython).

## Pico Wiring
Danger: 

- Pico **VSYS** to **AirLift Vin**
- **Pico GND** to **AirLift GND**
- **Pico GP10** (SPI1 SCK) to **AirLift SCK**
- **Pico GP11** (SPI1 TX) to **AirLift MOSI**
- **Pico GP12** (SPI1 RX) to **AirLift MISO**
- **Pico GP13** (SPI1 CSn) to **AirLift CS**
- **Pico GP14** &nbsp;to **AirLift BUSY**
- **Pico GP15** &nbsp;to **AirLift !RST**

For more information about the SPI peripherals and pinouts of the Pico, [check out this guide](https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/pinouts).

![raspberry_pi_pico_airliftwing_bb.png](https://cdn-learn.adafruit.com/assets/assets/000/100/388/medium640/raspberry_pi_pico_airliftwing_bb.png?1614958749)

## CircuitPython Installation of ESP32SPI Library

You'll need to install the&nbsp;[Adafruit CircuitPython ESP32SPI](https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI)&nbsp;library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases).&nbsp; Our CircuitPython starter guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).

You can manually install the necessary libraries from the bundle:

- **adafruit\_bus\_device**
- **adafruit\_minimqtt**
- **adafruit\_io**
- **adafruit\_esp32\_spi**
- **adafruit\_requests**

## CircuitPython Usage

[Connect to the board's serial REPL](https://learn.adafruit.com/welcome-to-circuitpython/the-repl) via Mu so you are at the CircuitPython **\>\>\>** prompt. Once that's done, load up the following example in Mu and save it to the Pico as **code.py**.

```python
import board
import busio
from digitalio import DigitalInOut

from adafruit_esp32spi import adafruit_esp32spi
import adafruit_requests as requests

print("Raspberry Pi RP2040 - ESP32SPI hardware test")

esp32_cs = DigitalInOut(board.GP13)
esp32_ready = DigitalInOut(board.GP14)
esp32_reset = DigitalInOut(board.GP15)

spi = busio.SPI(board.GP10, board.GP11, board.GP12)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])

for ap in esp.scan_networks():
    print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))

print("Done!")
```

Once all the files are copied from your computer to the Pico, you should have the following files on your **CIRCUITPY** drive.

![raspberry_pi_lib.png](https://cdn-learn.adafruit.com/assets/assets/000/100/409/medium640/raspberry_pi_lib.png?1614981003)

The output to the serial monitor should look something like the following:

![](https://cdn-learn.adafruit.com/assets/assets/000/100/390/medium800/raspberry_pi_1__screen__Users_brentrubell__screen_.png?1614959098)

Make sure you see the same output! If you don't, check your wiring. Once you've succeeded, continue onto the next page!

Warning: 

# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Create Your settings.toml File

CircuitPython works with WiFi-capable boards to enable you to make projects that have network connectivity. This means working with various passwords and API keys. As of [CircuitPython 8](https://circuitpython.org/downloads), there is support for a **settings.toml** file. This is a file that is stored on your **CIRCUITPY** drive, that contains all of your secret network information, such as your SSID, SSID password and any API keys for IoT services. It is designed to separate your sensitive information from your **code.py** file so you are able to share your code without sharing your credentials.

CircuitPython previously used a **secrets.py** file for this purpose. The **settings.toml** file is quite similar.

Warning: Your **settings.toml** file should be stored in the main directory of your **CIRCUITPY** drive. It should not be in a folder.

## CircuitPython **settings.toml** File

This section will provide a couple of examples of what your **settings.toml** file should look like, specifically for CircuitPython WiFi projects in general.

The most minimal **settings.toml** file must contain your WiFi SSID and password, as that is the minimum required to connect to WiFi. Copy this example, paste it into your **settings.toml** , and update:

- `your_wifi_ssid`
- `your_wifi_password`

```auto
CIRCUITPY_WIFI_SSID = "your_wifi_ssid"
CIRCUITPY_WIFI_PASSWORD = "your_wifi_password"
```

Many CircuitPython network-connected projects on the Adafruit Learn System involve using Adafruit IO. For these projects, you must _also_ include your Adafruit IO username and key. Copy the following example, paste it into your settings.toml file, and update:

- `your_wifi_ssid`
- `your_wifi_password`
- `your_aio_username`
- `your_aio_key`

```auto
CIRCUITPY_WIFI_SSID = "your_wifi_ssid"
CIRCUITPY_WIFI_PASSWORD = "your_wifi_password"
ADAFRUIT_AIO_USERNAME = "your_aio_username"
ADAFRUIT_AIO_KEY = "your_aio_key"
```

Some projects use different variable names for the entries in the **settings.toml** file. For example, a project might use `ADAFRUIT_AIO_ID` in the place of `ADAFRUIT_AIO_USERNAME`. **If you run into connectivity issues, one of the first things to check is that the names in the settings.toml file match the names in the code.**

Warning: Not every project uses the same variable name for each entry in the **settings.toml** file! Always verify it matches the code.

## **settings.toml** File Tips
Here is an example **settings.toml** file.

```auto
# Comments are supported
CIRCUITPY_WIFI_SSID = "guest wifi"
CIRCUITPY_WIFI_PASSWORD = "guessable"
CIRCUITPY_WEB_API_PORT = 80
CIRCUITPY_WEB_API_PASSWORD = "passw0rd"
test_variable = "this is a test"
thumbs_up = "\U0001f44d"
```

In a **settings.toml** file, it's important to keep these factors in mind:

- Strings are wrapped in double quotes; ex: `"your-string-here"`
- Integers are _ **not** _ quoted and may be written in decimal with optional sign (`+1`, `-1`, `1000`) or hexadecimal (`0xabcd`).
  - Floats (decimal numbers), octal (`0o567`) and binary (`0b11011`) are not supported.

- Use `\u` escapes for weird characters, `\x` and `\ooo` escapes are not available in **.toml** files
  - Example: `\U0001f44d` for 👍 (thumbs up emoji) and `\u20ac` for € (EUR sign)

- Unicode emoji, and non-ASCII characters, stand for themselves as long as you're careful to save in "UTF-8 without BOM" format

&nbsp;

&nbsp;

When your&nbsp; **settings.toml&nbsp;** file is ready, you can save it in your text editor with the **.toml** &nbsp;extension.

![adafruit_products_dotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/071/medium640/adafruit_products_dotToml.jpg?1671034293)

## Accessing Your **settings.toml** Information in **code.py**
In your **code.py** file, you'll need to `import` the `os` library to access the **settings.toml** file. Your settings are accessed with the `os.getenv()` function. You'll pass your settings entry to the function to import it into the **code.py** file.

```python
import os

print(os.getenv("test_variable"))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/117/072/medium800/adafruit_products_tomlOutput.jpg?1671034496)

In the upcoming CircuitPython WiFi examples, you'll see how the **settings.toml&nbsp;** file is used for connecting to your SSID and accessing your API keys.

# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Internet Connect!

# Connect to WiFi

OK, now that you have your&nbsp; **settings.toml** file set up - you can connect to the Internet.

To do this, you need to first install a few libraries, into the lib folder on your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **examples/** and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your **CIRCUITPY** drive.

Your **CIRCUITPY** drive should now look similar to the following image:

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/esp32spi_esp32spi_simpletest.py.png )

Info: Update to CircuitPython 9.2.x or later to use this example.

https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/main/examples/esp32spi_simpletest.py

And save it to your board, with the name **code.py**.

Don't forget you'll also need to create the **settings.toml** file as seen above, with your WiFi ssid and password.

In a serial console, you should see something like the following. For more information about connecting with a serial console, view the guide [Connecting to the Serial Console](https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console).

```terminal
&gt;&gt;&gt; import wifitest
ESP32 SPI webclient test
ESP32 found and in idle mode
Firmware vers. 1.7.5
MAC addr: 24:C9:DC:BD:0F:3F
	HomeNetwork             RSSI: -46
	HomeNetwork             RSSI: -76
	Fios-12345              RSSI: -92
	FiOS-AB123              RSSI: -92
	NETGEAR53               RSSI: -93
Connecting to AP...
Connected to HomeNetwork 	RSSI: -45
My IP address is 192.168.1.245
IP lookup adafruit.com: 104.20.39.240
Ping google.com: 30 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
----------------------------------------
This is a test of Adafruit WiFi!
If you can read this, its working :)
----------------------------------------

Fetching json from http://wifitest.adafruit.com/testwifi/sample.json
----------------------------------------
{'fun': True, 'company': 'Adafruit', 'founded': 2005, 'primes': [2, 3, 5], 'pi': 3.14, 'mixed': [False, None, 3, True, 2.7, 'cheese']}
----------------------------------------
Done!
```

Going over the example above, here's a breakdown of what the program is doing:

- Initialize the ESP32 over SPI using the SPI port and 3 control pins:

```python
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)

#...

else:
    spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
```

- Get the socket pool and the SSL context, and then tell the `adafruit_requests` library about them.

```python
pool = adafruit_connection_manager.get_radio_socketpool(esp)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(esp)
requests = adafruit_requests.Session(pool, ssl_context)
```

- Verify an ESP32 is found, checks the firmware and MAC address

```auto
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", ":".join("%02X" % byte for byte in esp.MAC_address))
```

- Perform a scan of all access points it can see and print out the name and signal strength.

```python
for ap in esp.scan_networks():
    print("\t%-23s RSSI: %d" % (ap.ssid, ap.rssi))
```

- Connect to the AP we've defined here, then print out the local IP address. Then attempt to do a domain name lookup and ping google.com to check network connectivity. (Note sometimes the ping fails or takes a while; this isn't a big deal.)

```python
print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(ssid, password)
    except OSError as e:
        print("could not connect to AP, retrying: ", e)
        continue
print("Connected to", esp.ap_info.ssid, "\tRSSI:", esp.ap_info.rssi)
print("My IP address is", esp.ipv4_address)
print(
    "IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com"))
)
```

Now we're getting to the really interesting part of the example program. We've written a library for web fetching web data, named [adafruit\_requests](https://github.com/adafruit/Adafruit_CircuitPython_Requests). It is a lot like the regular Python library named [requests](https://requests.readthedocs.io/en/latest/). This library allows you to send HTTP and HTTPS requests easily and provides helpful methods for parsing the response from the server.

- Here is the part of the example program is fetching text data from a URL.

```python
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"  # Further up in the program

# ...

print("Fetching text from", TEXT_URL)
r = requests.get(TEXT_URL)
print('-' * 40)
print(r.text)
print('-' * 40)
r.close()
```

- Finally, here the program is fetching some JSON data. The `adafruit_requests` library will parse the JSON into a Python dictionary whose structure is the same as the structure of the JSON.

```auto
JSON_URL = "http://wifitest.adafruit.com/testwifi/sample.json"   # Further up in the program

# ...

print("Fetching json from", JSON_URL)
r = requests.get(JSON_URL)
print('-' * 40)
print(r.json())
print('-' * 40)
r.close()
```

# Advanced Requests Usage

Want to send custom HTTP headers, parse the response as raw bytes, or handle a response's http status code in your CircuitPython code?

We've written an&nbsp;example to show advanced usage of the requests module below.

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **examples/** and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your **CIRCUITPY** drive.

https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/main/examples/esp32spi/requests_esp32spi_advanced.py

Your **CIRCUITPY** drive should now look similar to the following image:

![CIRCUITPY](https://adafruit.github.io/Adafruit_CircuitPython_Bundle/requests_esp32spi_requests_esp32spi_advanced.py.png )

# WiFi Manager

The way the examples above connect to WiFi works but it's a little finicky. Since WiFi is not necessarily so reliable, you may have disconnects and need to reconnect. For more advanced uses, we recommend using the `WiFiManager` class. It will wrap the connection/status/requests loop for you - reconnecting if WiFi drops, resetting the ESP32 if it gets into a bad state, etc.

Here's a more advanced example that shows using the `WiFiManager` and also how to fetch the current time from a web source.

https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/main/examples/esp32spi_localtime.py

# Further Information

For more information on the basics of doing networking in CircuitPython, see this guide:

### Networking in CircuitPython

[Networking in CircuitPython](https://learn.adafruit.com/networking-in-circuitpython)
# Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi 

## Usage with Adafruit IO

[Adafruit IO is an internet of things platform](https://learn.adafruit.com/welcome-to-adafruit-io) (designed by [Adafruit](http://adafruit.com/about)!) to help connect your project to the internet.&nbsp;You're going to send the Pico's CPU temperature to Adafruit IO and display it on a dashboard page. You'll add a toggle block to turn on or off the Pico's LED from the internet.

## Secrets File Setup for Adafruit IO

To connect to Adafruit IO, you will need to start by modifying your _secrets&nbsp;_file to include your Adafruit IO credentials.

- **If you do not already have a secrets file** , [visit this page and come back here when you've created a secrets file](https://learn.adafruit.com/adafruit-airlift-breakout/internet-connect#whats-a-secrets-file-3034650-1)

Navigate to [io.adafruit.com](https://io.adafruit.com/) and click&nbsp;_My Key&nbsp;_to obtain your Adafruit IO username and Active Key. Add these credentials into the secrets file, which will now look something like the following:

```python
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it

secrets = {
    'ssid' : 'home ssid',
    'password' : 'my password',
    'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
    'aio_username': 'MY_ADAFRUIT_IO_USERNAME',
    'aio_key': 'MY_ADAFRUIT_IO_PASSWORD'
    }
```

## Create Adafruit IO Feeds

Next, set up two new Adafruit IO feeds - `temperature` and `led`. The temperature feed will store the value of the Pico's CPU temperature and the LED feed will store the state of a toggle switch block on an Adafruit IO dashboard.

- If you do not know how to set up a feed on Adafruit IO, [follow this page and come back when you've created the two feeds listed above](https://learn.adafruit.com/adafruit-io-basics-feeds/creating-a-feed).

## Create an Adafruit IO Dashboard

Navigate to [the Adafruit IO Dashboards page](https://io.adafruit.com/dashboards) and create a new dashboard named **Pico RP2040**.

- If you do not know how to create a dashboard on Adafruit IO, [follow this page and come back when you've created a new dashboard](https://learn.adafruit.com/adafruit-io-basics-dashboards/creating-a-dashboard).

Click the cog in the upper right hand corner of the dashboard to bring up the Dashboard Settings.

From the Dashboard settings, **click Create New Block**

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/392/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614963374)

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/393/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614963392)

Add a toggle block to turn the Pico's LED on or off.

- From the Create a New Block screen, select the Toggle Block.
- Connect the _led_ feed to the block by ticking the checkbox.
- In the final screen, click **Create Block**.

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/394/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614963580)

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/395/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614963626)

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/396/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614963758)

Next, create a gauge block to display the Pico's CPU temperature.

- Create a new gauge block.
- Connect the _temperature_ feed to the block by ticking the checkbox.
- Under Block Settings, you may change the block's look and feel.
- When you've finished customizing the block, click Create Block.

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/397/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614969295)

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/398/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614969338)

![raspberry_pi_IO_-_Pico_RP2040.png](https://cdn-learn.adafruit.com/assets/assets/000/100/401/medium640/raspberry_pi_IO_-_Pico_RP2040.png?1614969621)

Once you've finished creating both blocks, your dashboard should look something like the following image:

![](https://cdn-learn.adafruit.com/assets/assets/000/100/402/medium800/raspberry_pi_IO_-_Pico_RP2040.png?1614969752)

## Code&nbsp;

Copy the code below into Mu and save as a file named **code.py** &nbsp;on your **CIRCUITPY** drive.

https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO/blob/main/examples/adafruit_io_mqtt/adafruit_io_pubsub_rp2040.py

Once all the files are copied from your computer to the Pico, you should have the following files on your **CIRCUITPY** drive.

![raspberry_pi_lib.png](https://cdn-learn.adafruit.com/assets/assets/000/100/406/medium640/raspberry_pi_lib.png?1614977195)

## Code Usage

The code should connect to your wireless network and Adafruit IO.&nbsp;

```python
Connecting to WiFi...
Connected!
Connecting to Adafruit IO...
Connected to Adafruit IO!
Subscribed to brubell/f/led with QOS level 0
CPU temperature is 24.32 degrees C
Publishing 24.32 to temperature feed...
Published!
```

Navigate to your Adafruit IO Dashboard and you should see a new value in the gauge block. Every 30 seconds, the Pico reads its internal CPU temperature and sends it to Adafruit IO.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/100/405/medium800/raspberry_pi_IO_-_Pico_RP2040.png?1614976438)

Toggle the switch block to turn the Pico's LED on or off:

![](https://cdn-learn.adafruit.com/assets/assets/000/100/407/medium800thumb/raspberry_pi_ezgif.com-gif-maker.jpg?1614978798)


## Featured Products

### Adafruit AirLift – ESP32 WiFi Co-Processor Breakout Board

[Adafruit AirLift – ESP32 WiFi Co-Processor Breakout Board](https://www.adafruit.com/product/4201)
Give your plain ol' microcontroller project a _lift_ with the Adafruit AirLift - a breakout board that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your favorite microcontroller (like the ATmega328 or ATSAMD51), awesome peripherals and lots of libraries....

Out of Stock
[Buy Now](https://www.adafruit.com/product/4201)
[Related Guides to the Product](https://learn.adafruit.com/products/4201/guides)
### Raspberry Pi Pico RP2040

[Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864)
The Raspberry Pi foundation changed single-board computing [when they released the Raspberry Pi computer](https://www.raspberrypi.org/archives/723), now they're ready to do the same for microcontrollers with the release of the brand new **Raspberry Pi Pico**. This...

In Stock
[Buy Now](https://www.adafruit.com/product/4864)
[Related Guides to the Product](https://learn.adafruit.com/products/4864/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

Out of Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
### Full Sized Premium Breadboard - 830 Tie Points

[Full Sized Premium Breadboard - 830 Tie Points](https://www.adafruit.com/product/239)
This is a 'full-size' premium quality breadboard, 830 tie points. Good for small and medium projects. It's 2.2" x 7" (5.5 cm x 17 cm) with a standard double-strip in the middle and two power rails on both sides. You can pull the power rails off easily to make the...

In Stock
[Buy Now](https://www.adafruit.com/product/239)
[Related Guides to the Product](https://learn.adafruit.com/products/239/guides)
### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)

## Related Guides

- [Adafruit AirLift - ESP32 WiFi Co-Processor Breakout](https://learn.adafruit.com/adafruit-airlift-breakout.md)
- [Multi-Sensor IoT Environmental Sensor Box With CircuitPython](https://learn.adafruit.com/remote-iot-environmental-sensor.md)
- [Networking in CircuitPython](https://learn.adafruit.com/networking-in-circuitpython.md)
- [MQTT in CircuitPython](https://learn.adafruit.com/mqtt-in-circuitpython.md)
- [Quickstart - Raspberry Pi RP2040 with BLE and CircuitPython](https://learn.adafruit.com/quickstart-raspberry-pi-rp2040-with-ble-and-circuitpython.md)
- [Adafruit IO Basics: AirLift](https://learn.adafruit.com/adafruit-io-basics-airlift.md)
- [Upgrading AirLift ESP32 Firmware](https://learn.adafruit.com/upgrading-esp32-firmware.md)
- [PyPortal Astronauts in Space](https://learn.adafruit.com/pyportal-astronauts-in-space.md)
- [CircuitPython TFT Candy Hearts](https://learn.adafruit.com/circuit-python-tft-gizmo-candy-hearts.md)
- [CircuitPython-Powered 3-minute Nightlight](https://learn.adafruit.com/circuitpython-powered-gemma-nightlight.md)
- [Adafruit Feather RP2040 RFM69](https://learn.adafruit.com/feather-rp2040-rfm69.md)
- [Articulated Pi Display V2 Mount](https://learn.adafruit.com/pi-wall-mount.md)
- [LED Shoji Lamp](https://learn.adafruit.com/led-shoji-lamp.md)
- [CLUE BLE MIDI Glove](https://learn.adafruit.com/clue-midi-glove.md)
- [CompuCanvas 101 - Transitions](https://learn.adafruit.com/compucanvas-101.md)
