A comprehensive MicroPython script for Raspberry Pi Pico W that connects to WiFi and performs thorough internet connectivity testing with bandwidth estimation.
- Hardware Detection: Automatically detects if you're using a Pico W or standard Pico
- WiFi Connection: Robust WiFi connection with detailed status reporting
- Internet Testing: Multi-layered connectivity tests including DNS, HTTP, and server reachability
- Speed Testing: Bandwidth estimation and latency measurements
- Network Scanning: Scan and display available WiFi networks with signal strength
- System Information: Display hardware and memory information
- Comprehensive Reporting: Detailed test results with performance ratings
- Raspberry Pi Pico W (WiFi-enabled version)
- USB cable for programming
- Access to a WiFi network
- MicroPython v1.19+ (tested on v1.25.0)
- Any MicroPython-compatible IDE (Thonny, VS Code with Pico extension, etc.)
- Download the latest MicroPython firmware for Pico W from micropython.org
- Hold the BOOTSEL button while connecting Pico W to USB
- Copy the
.uf2file to the RPI-RP2 drive - Pico W will reboot with MicroPython
- Connect to your Pico W using your preferred IDE
- Copy the entire script to your Pico W
- Save as
main.pyfor auto-run on boot, or any.pyfilename
Edit the WiFi credentials in the script:
# WiFi credentials
WIFI_SSID = 'YourNetworkName'
WIFI_PASSWORD = 'YourPassword'# Simply run the script
python main.py# Test only WiFi connection
success, wlan = connect_wifi()
# Test only internet connectivity
simple_connectivity_test()
# Test only speed
quick_speed_test()
# Scan networks only
network_scan_test()| Test Result | Description |
|---|---|
| π PERFECT | All 5 tests passed - excellent connection |
| π EXCELLENT | 4/5 tests passed - nearly perfect |
| β GOOD | 3/5 tests passed - reliable internet |
| 2/5 tests passed - basic functionality | |
| β POOR | <2 tests passed - significant issues |
| Latency | Rating | Description |
|---|---|---|
| <50ms | π EXCELLENT | Very fast connection |
| 50-150ms | β GOOD | Normal broadband speed |
| 150-300ms | Acceptable for basic use | |
| >300ms | π SLOW | May affect real-time applications |
| RSSI | Indicator | Quality |
|---|---|---|
| >-50dBm | πΆ Excellent | Maximum performance |
| -50 to -60dBm | πΆ Good | Reliable connection |
| -60 to -70dBm | πΆ Fair | May have occasional issues |
| <-70dBm | πΆ Weak | Unstable connection |
- Verifies Pico W WiFi capability
- Prevents errors on standard Pico boards
- Connects to specified network
- Reports IP configuration
- Shows connection status and timing
- DNS Resolution: Tests domain name resolution
- Google DNS: Tests connection to 8.8.8.8
- Cloudflare DNS: Tests connection to 1.1.1.1
- Multiple Servers: Redundant connectivity verification
- Tests connection time to multiple servers
- Calculates average latency
- Provides speed estimates based on response times
- Performs actual HTTP requests
- Tests web service connectivity
- Validates response data
- Times data transfer operations
- Estimates connection throughput
- Provides performance ratings
- Scans for available WiFi networks
- Shows signal strength and security
- Identifies current network
Cause: Using standard Pico instead of Pico W
Solution: This script requires a Pico W with WiFi capability
Causes & Solutions:
- Wrong WiFi credentials β Check SSID and password
- Network not available β Verify network is broadcasting
- Weak signal β Move closer to router
- Network congestion β Try again later
Causes & Solutions:
- Router DNS issues β Try restarting router
- ISP DNS problems β Wait and retry
- Firewall blocking β Check network security settings
Causes & Solutions:
- Internet filtering β Some networks block external HTTP
- Temporary service issues β Retry later
- Firewall restrictions β Check network policies
Add debug prints by modifying timeout values:
# Increase timeouts for debugging
s.settimeout(30) # Instead of 5
max_wait = 30 # Instead of 15# Add between tests to free memory
gc.collect()# Reduce scan time for known networks
wlan.connect(SSID, PASSWORD)
# Skip network scan if not needed# Run only essential tests
def quick_test():
connect_wifi()
simple_connectivity_test()
return Trueservers = [
('your-server.com', 80, 'Custom Server'),
('8.8.8.8', 53, 'Google DNS'),
# Add more servers
]# Test your own web services
def test_custom_api():
# Your custom HTTP test code
pass# JSON output for logging
def output_json_results(results):
import json
return json.dumps(results)============================================================
π PICO W WIFI CONNECTION AND INTERNET TEST SUITE
============================================================
=== System Information ===
MicroPython: 3.4.0; MicroPython v1.25.0 on 2025-04-15
Platform: rp2
CPU Frequency: 125.0 MHz
Free Memory: 156032 bytes
WiFi Status: Connected
SSID: AceDrummer
IP: 192.168.7.242
============================================================
Starting WiFi connection...
Checking WiFi hardware...
β WiFi hardware detected
Already connected to WiFi
IP Address: 192.168.7.242
Subnet: 255.255.252.0
Gateway: 192.168.4.1
DNS: 192.168.4.5
β
WiFi connection successful!
==================================================
π COMPLETE INTERNET CONNECTIVITY TEST SUITE
==================================================
[1/5] Basic Connectivity Test
=== Internet Connectivity Test ===
Testing DNS...
β DNS: Working
Testing Google connection...
β Google DNS: Connected (87ms)
Testing Cloudflare connection...
β Cloudflare DNS: Connected
π Results: 3/3 tests passed
π EXCELLENT: Full internet connectivity
[2/5] Speed Test
=== Quick Speed Test ===
β Google: 89ms
β Cloudflare: 92ms
β OpenDNS: 156ms
π Average latency: 112.3ms
β
GOOD speed
π FINAL RESULTS: 5/5 tests passed
π PERFECT: All tests passed! Excellent connection!
==================================================
π SUCCESS: AceDrummer connection is working perfectly!
π Internet access confirmed and tested
πΆ Final Status: Connected to 'AceDrummer'
π§ You can now use internet-based features!
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit pull requests or open issues for:
- Additional test types
- Performance improvements
- Bug fixes
- Documentation improvements
If you encounter issues:
- Check the troubleshooting section
- Verify you're using a Pico W (not standard Pico)
- Confirm MicroPython version compatibility
- Test with a different WiFi network
Made for Raspberry Pi Pico W with β€οΈ