Robotics & Engineering Python
Advanced
60 mins
Teacher/Student led
+125 XP
What you need:
Chromebook/Laptop/PC

Wifi Signal Strength Scanner

In this lesson, you will create a Wifi Signal Strength Scanner using your Raspberry Pico. You will build a web page that displays the signal strength of nearby Wi-Fi networks, and learn how to connect your Pico to the internet.
Learning Goals Learning Outcomes Teacher Notes

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Import Libraries

    Start by importing the necessary libraries:

    import network
    import socket
    from time import sleep

    2 - Set Wi-Fi Credentials

    Replace 'Your_SSID' and 'Your_PASSWORD' with your Wi-Fi network's SSID and password:

    ssid = 'Your_SSID'
    password = 'Your_PASSWORD'

    3 - Create scan_wifi Function

    Create a function called 'scan_wifi' that scans for nearby Wi-Fi networks and returns a list of tuples containing the SSID and signal strength (RSSI) of each network:

    def scan_wifi():
        wlan = network.WLAN(network.STA_IF)
        wlan.active(True)
        networks = wlan.scan()
        wifi_data = []
        for net in networks:
            ssid = net[0].decode('utf-8')
            rssi = net[3]
            wifi_data.append((ssid, rssi))
        return wifi_data

    4 - Create webpage Function

    Create a function called 'webpage' that takes the Wi-Fi data list as an argument and generates an HTML string to display the Wi-Fi signal strength information in a table:

    def webpage(wifi_data):
        ... (include the full 'webpage' function code from the provided code snippet)

    5 - Create serve Function

    Create a function called 'serve' that connects the Pico to the Wi-Fi network, starts a web server, and sends the generated HTML string to clients when they connect:

    def serve():
        ... (include the full 'serve' function code from the provided code snippet)

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more