Close Menu
5gantennas.org5gantennas.org
  • Home
  • 5G
    • 5G Technology
  • 6G
  • AI
  • Data
    • Global 5G
  • Internet
  • WIFI
  • 5G Antennas
  • Legacy

Subscribe to Updates

Subscribe to our newsletter and never miss our latest news

Subscribe my Newsletter for New Posts & tips Let's stay updated!

What's Hot

4 Best Wi-Fi Mesh Networking Systems in 2024

September 6, 2024

India is on the brink of a new revolution in telecommunications and can lead the world with 6G: Jyotiraditya Scindia

August 29, 2024

Speaker Pelosi slams California AI bill headed to Governor Newsom as ‘ignorant’

August 29, 2024
Facebook X (Twitter) Instagram
Facebook X (Twitter) Instagram
5gantennas.org5gantennas.org
  • Home
  • 5G
    1. 5G Technology
    2. View All

    Deutsche Telekom to operate 12,500 5G antennas over 3.6 GHz band

    August 28, 2024

    URCA Releases Draft “Roadmap” for 5G Rollout in the Bahamas – Eye Witness News

    August 23, 2024

    Smart Launches Smart ZTE Blade A75 5G » YugaTech

    August 22, 2024

    5G Drone Integration Denmark – DRONELIFE

    August 21, 2024

    Hughes praises successful private 5G demo for U.S. Navy

    August 29, 2024

    GSA survey reveals 5G FWA has become “mainstream”

    August 29, 2024

    China Mobile expands 5G Advanced, Chunghwa Telecom enters Europe

    August 29, 2024

    Ateme and ORS Boost 5G Broadcast Capacity with “World’s First Trial of IP-Based Statmux over 5G Broadcast” | TV Tech

    August 29, 2024
  • 6G

    India is on the brink of a new revolution in telecommunications and can lead the world with 6G: Jyotiraditya Scindia

    August 29, 2024

    Vodafonewatch Weekly: Rural 4G, Industrial 5G, 6G Patents | Weekly Briefing

    August 29, 2024

    Southeast Asia steps up efforts to build 6G standards

    August 29, 2024

    Energy efficiency as an inherent attribute of 6G networks

    August 29, 2024

    Finnish working group launches push for 6G technology

    August 28, 2024
  • AI

    Speaker Pelosi slams California AI bill headed to Governor Newsom as ‘ignorant’

    August 29, 2024

    Why Honeywell is betting big on Gen AI

    August 29, 2024

    Ethically questionable or creative genius? How artists are engaging with AI in their work | Art and Design

    August 29, 2024

    “Elon Musk and Trump” arrested for burglary in disturbing AI video

    August 29, 2024

    Nvidia CFO says ‘enterprise AI wave’ has begun and Fortune 100 companies are leading the way

    August 29, 2024
  • Data
    1. Global 5G
    2. View All

    Global 5G Enterprise Market is expected to be valued at USD 34.4 Billion by 2032

    August 12, 2024

    Counterpoint predicts 5G will dominate the smartphone market in early 2024

    August 5, 2024

    Qualcomm’s new chipsets will power affordable 5G smartphones

    July 31, 2024

    Best Super Fast Download Companies — TradingView

    July 31, 2024

    Crypto Markets Rise on Strong US Economic Data

    August 29, 2024

    Microsoft approves construction of third section of Mount Pleasant data center campus

    August 29, 2024

    China has invested $6.1 billion in state-run data center projects over two years, with the “East Data, West Computing” initiative aimed at capitalizing on the country’s untapped land.

    August 29, 2024

    What is the size of the clinical data analysis solutions market?

    August 29, 2024
  • Internet

    NATO believes Russia poses a threat to Western internet and GPS services

    August 29, 2024

    Mpeppe grows fast, building traction among Internet computer owners

    August 29, 2024

    Internet Computer Whale Buys Mpeppe (MPEPE) at 340x ROI

    August 29, 2024

    Long-term internet computer investor adds PEPE rival to holdings

    August 29, 2024

    Biden-Harris Administration Approves Initial Internet for All Proposals in Mississippi and South Dakota

    August 29, 2024
  • WIFI

    4 Best Wi-Fi Mesh Networking Systems in 2024

    September 6, 2024

    Best WiFi deal: Save $200 on the Starlink Standard Kit AX

    August 29, 2024

    Sonos Roam 2 review | Good Housekeeping UK

    August 29, 2024

    Popular WiFi extender that eliminates dead zones in your home costs just $12

    August 29, 2024

    North American WiFi 6 Mesh Router Market Size, Share, Forecast, [2030] – அக்னி செய்திகள்

    August 29, 2024
  • 5G Antennas

    Nokia and Claro bring 5G to Argentina

    August 27, 2024

    Nokia expands FWA portfolio with new 5G devices – SatNews

    July 25, 2024

    Deutsche Telekom to operate 12,150 5G antennas over 3.6 GHz band

    July 24, 2024

    Vodafone and Ericsson develop a compact 5G antenna in Germany

    July 12, 2024

    Vodafone and Ericsson unveil new small antennas to power Germany’s 5G network

    July 11, 2024
  • Legacy
5gantennas.org5gantennas.org
Home»WIFI»How to use Wi-Fi on Raspberry Pi Pico 2 (requires expansion board)
WIFI

How to use Wi-Fi on Raspberry Pi Pico 2 (requires expansion board)

5gantennas.orgBy 5gantennas.orgAugust 10, 2024No Comments8 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Share
Facebook Twitter LinkedIn Pinterest WhatsApp Email


Just like the original Raspberry Pi PicoThe new Raspberry Pi Pico 2 doesn’t have Wi-Fi or Bluetooth connectivity. The Pico 2 W is coming, confirmed by Raspberry Pi co-founder and CEO Eben Upton, but that’s still a few months away. What can you do in the meantime? Raspberry Pi Pico W?

Looking back through the archives, I remembered the original guide for adding Wi-Fi to a Raspberry Pi Pico back in 2021. This guidance is a bit out of date now, but Adafruit has updated CircuitPython and its modules to make it even easier to get online.

In this how-to, you will learn how to connect your Raspberry Pi Pico 2 to the Internet. Adafruit AirLift WiFi Feather WingThis board is essentially an ESP32, which is already a powerful Wi-Fi enabled microcontroller, so you might be asking “why?” Because there may be edge cases where you need the power of the new RP2350 over a Wi-Fi connection.

To demonstrate how you can use data from the Internet, we will create a simple and fun project that downloads some humorous “facts” about Chuck Norris, using an API (Application Programming Interface) that formats the returned data into a format called JSON.

Yes! You can now use Wi-Fi on your Raspberry Pi Pico 2. All you need is an ESP32 – YouTube
Yes! You can now use Wi-Fi on your Raspberry Pi Pico 2. All you need is an ESP32 - YouTube

Watch now

What you need for this project

  • Raspberry Pi Pico 2 (project also works with Raspberry Pi Pico)
  • Adafruit Airlift WiFi Featherwing Coprocessor
  • 8 x Male to Male Jumper Wires
  • Breadboard

Connecting a Raspberry Pi Pico 2 to Adafruit’s Airlift WiFi Featherwing

Adafruit’s Feather series of boards use a different pinout than the Raspberry Pi Pico 2, so you will need to solder header pins on the Raspberry Pi Pico 2 and the Featherwing Airlift. Since you will be using both boards on a breadboard, the included male headers will suffice.

If you are using the Featherwing with an Adafruit Feather board, such as the Feather RP2040, you will need to solder a female header to the top of the microcontroller. These should have come with the Adafruit Airlift WiFi Featherwing. We chose to solder the female header with extra long male header pins so that it would fit on a breadboard.

In the diagram, pay attention to the location of MISO, MOSI, and SCK. The Featherwing pinout has more pins on one side than the other, so check carefully before powering it up.

Get the best Tom’s Hardware news and in-depth reviews straight to your inbox.

Swipe to scroll horizontally
Raspberry Pi Pico 2 Adafruit Airlift WiFi Featherwing Coprocessor
VSYS USB
ground Any GND pin
GPIO 10 SCK
GPIO 11 Moshi
GPIO 12 miso
GPIO 13 ESPCS
GPIO 14 busy
GPIO 15 ESPRST

Installing CircuitPython

Flashing CircuitPython onto your microcontroller is easy – we’ve designed it to be easy. The Raspberry Pi Pico 2 will use an alpha release of CircuitPython, but we don’t recommend deploying it in mission-critical projects as you may encounter issues and crashes – in that case, please wait for the full release.

1. download Latest version of CircuitPython for Pico 2. Please note that at the time of writing it was an alpha release, so it may crash from time to time.

2. Hold down the BOOTSEL button on the Pico and insert the USB cable into the Pico and into your computer.

3. Copy the CircuitPython UF2 files to the RP23502 driveThe drive will be unmounted and disappear while the code is flashed. A new drive, CIRCUITPY, will appear, confirming the flash was successful.

4. download Library Archives This depends on which version of CircuitPython you downloaded. For example, version 9.2.0 is only compatible with CircuitPython 9 libraries.

5. Extract the downloaded contents to a folder.

6. Copy the following files/folders to the lib folder on the CIRCUITPY drive:

/adafruit_bus_device

/adafruit_esp32spi

adafruit_requests.mpy

Writing the project code in CircuitPython

Our project is written in CircuityPython, Adafruit’s version of MicroPython. CircuitPython differs in that it allows easy installation of code modules for use with Adafruit’s various products. We will use Thonny to drive the CircuitPython code that communicates with the Adafruit Featherwing and retrieves data from the web.

1. Download and install Tony.

2. Go to Tools >> Options and select the Interpreter tab.

Raspberry Pi Pico 2 Wi-Fi

(Image courtesy of Tom’s Hardware)

3. Set the interpreter to CircuitPython (generic) and the port to match your USB-Serial device (Pico 2).[OK]Click You can also try the auto port option to force Thonny to find the port.

Raspberry Pi Pico 2 Wi-Fi

(Image courtesy of Tom’s Hardware)

4.Clicking STOP will force the interpreter to connect and run a Python shell on your Raspberry Pi Pico 2.

5. To create a project, you import a set of CircuitPython modules.

board: Basic GPIO access

Bushio: Used to create a SPI connection between the Pico 2 and an Adafruit board

digital: Used to get and set the GPIO pin configuration

adafruit_connection manager: Creating a network connection

Ada Fruit Request: A version of Adafruit’s Python requests library used to make web requests with network devices.

Adafruit_esp32spi: Used to communicate with the ESP32 on the Adafruit Featherwing

secret: A module to store Wi-Fi and country details. We will create this later.

import board
import busio
from digitalio import DigitalInOut
import adafruit_connection_manager
import adafruit_requests
from adafruit_esp32spi import adafruit_esp32spi
from secrets import secrets

6. Print a message to the Python shellTell users what the project is about.

print("Raspberry Pi Pico 2: Chuck Norris Joke-Randomizer")

7. Create an object to store URLs for Chuck Norris jokes. This can be the URL of any API or JSON source you want to use.

CHUCK_NORRIS_URL = "https://api.chucknorris.io/jokes/random"

8. Configure GPIO pins Used for SPI connection between Pico 2 and Adafruit Featherwing.

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)

9. Configure the network infrastructure aspects of your code. These are all the behind-the-scenes technologies that make the connection possible.

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)

10. The project will print a message informing you that it will attempt to connect to Wi-Fi.

print("Connecting to AP...")

11. While the Adafruit Featherwing’s ESP32 is not connected, the code will attempt to connect using the Wi-Fi AP and password stored in the secrets.py file. You will create this file later.

while not esp.is_connected:
   try:
       esp.connect_AP(secrets["ssid"], secrets["password"])

12. Use these lines to handle connection errors. If an error occurs, the code will keep trying to connect.

   except OSError as e:
       print("could not connect to AP, retrying: ", e)
       continue

13. If the connection is successful, print the connection details. These two lines print the access point name and the internal IP address of the project.

print("Connected to", esp.ap_info.ssid, "\tRSSI:", esp.ap_info.rssi)
print("My IP address is", esp.ipv4_address,"\n")

14. Print a message Presenting Chuck Norris jokes.

print("Your Random Chuck Norris joke is... ")

15. We use an Adafruit request to get the latest jokes in JSON format and store them inside an object called “r”.

r = requests.get(CHUCK_NORRIS_URL).json()

16. Extract the jokes from the JSON object. JSON is very similar to Python’s dictionary data structure, which uses “keys” to extract “values” from objects. In this case, the keys are called “values”. It’s not a very good choice, as the names can be confusing, but you have no control over that.

joke = r['value']

17. It prints a joke enclosed within a frame made of “-“. You can use the len() command to get the length (the number of characters in the joke string) and use that to create a frame with the correct number of characters.

print("-" * len(joke))
print(joke)
print("-" * len(joke))

18. Save the code as code.py on your Raspberry Pi Pico 2. This will overwrite your existing code.py file and will cause the code to launch automatically every time the Pico 2 is powered on.

Complete code listing for code.py

import board
import busio
from digitalio import DigitalInOut
import adafruit_connection_manager
import adafruit_requests
from adafruit_esp32spi import adafruit_esp32spi
from secrets import secrets

print("Raspberry Pi Pico 2: Chuck Norris Joke-Randomizer")
CHUCK_NORRIS_URL = "https://api.chucknorris.io/jokes/random"

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)
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)

print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(secrets["ssid"], secrets["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,"\n")

print("Your Random Chuck Norris joke is... ")
r = requests.get(CHUCK_NORRIS_URL).json()
joke = r['value']
print("-" * len(joke))
print(joke)
print("-" * len(joke))

Creating a secret file

The secrets.py file is a handy tool to store your Wi-Fi details and the country specific details you can use to connect to your Wi-Fi. By keeping the secrets separate from the main code, you can share the code.py file without worrying about sharing the secrets.

1. Create a new file on your Raspberry Pi Pico 2.

2. Create an object called “secrets” and Save Wi-Fi SSID, password, and time zone In an object, an object is a Python dictionary. The key identifies what the data stored in the value represents.

secrets = {
  'ssid' : 'YOUR SSID',
  'password' : 'YOUR PASSWORD',
  'timezone' : YOUR TIMEZONE SEE THE URL >> ', # http://worldtimeapi.org/timezones
}

3. Save the file as secrets.py on your Raspberry Pi Pico 2.

Running the project code

Raspberry Pi Pico 2 Wi-Fi

(Image courtesy of Tom’s Hardware)

Now we are ready to learn some valuable wisdom about Chuck Norris.

1. Switch back to the code.py tab.

2. Click Run >> Run Current Script. (Or press F5 or the green play button) to start the code.

The code runs in a Python shell and after a moment it connects to Wi-Fi and downloads the latest Chuck Norris jokes using a JSON API.



Source link

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleInternet down again? Try these tips to get back online
Next Article 6 ways to prevent your home security cameras from being hacked
5gantennas.org
  • Website

Related Posts

4 Best Wi-Fi Mesh Networking Systems in 2024

September 6, 2024

Best WiFi deal: Save $200 on the Starlink Standard Kit AX

August 29, 2024

Sonos Roam 2 review | Good Housekeeping UK

August 29, 2024

Comments are closed.

Latest Posts

4 Best Wi-Fi Mesh Networking Systems in 2024

September 6, 2024

India is on the brink of a new revolution in telecommunications and can lead the world with 6G: Jyotiraditya Scindia

August 29, 2024

Speaker Pelosi slams California AI bill headed to Governor Newsom as ‘ignorant’

August 29, 2024

Crypto Markets Rise on Strong US Economic Data

August 29, 2024
Don't Miss

Business News | Communications Minister Scindia promotes 6G leadership and nationwide broadband in meeting with telecom operators

By 5gantennas.orgAugust 24, 2024

New Delhi [India]August 24 (ANI): Union Telecom Minister Jyotiraditya Scindia along with Minister of State…

SingTel and SK Telecom prepare for the 6G future

July 8, 2024

Apple focuses on 6G for future iPhones

December 11, 2023

Subscribe to Updates

Subscribe to our newsletter and never miss our latest news

Subscribe my Newsletter for New Posts & tips Let's stay updated!

About Us
About Us

Welcome to 5GAntennas.org, your reliable source for comprehensive information on 5G technology, artificial intelligence (AI), and data-related advancements. We are passionate about staying at the forefront of these cutting-edge fields and bringing you the latest insights, trends, and developments.

Facebook X (Twitter) Pinterest YouTube WhatsApp
Our Picks

4 Best Wi-Fi Mesh Networking Systems in 2024

September 6, 2024

India is on the brink of a new revolution in telecommunications and can lead the world with 6G: Jyotiraditya Scindia

August 29, 2024

Speaker Pelosi slams California AI bill headed to Governor Newsom as ‘ignorant’

August 29, 2024
Most Popular

Will 5G make 2024 the most connected year in the industry?

December 1, 2023

The current state of 5G in the US and how it can improve

September 28, 2023

How 5G technology will transform gaming on the go

January 31, 2024
© 2025 5gantennas. Designed by 5gantennas.
  • Home
  • About us
  • Contact us
  • DMCA
  • Privacy Policy
  • About Creator

Type above and press Enter to search. Press Esc to cancel.