Skip to content

MarioCruz/PicoWiFi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Pico W WiFi Connection & Internet Test Suite by Mario The Maker

A comprehensive MicroPython script for Raspberry Pi Pico W that connects to WiFi and performs thorough internet connectivity testing with bandwidth estimation.

πŸš€ Features

  • 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

πŸ“‹ Requirements

Hardware

  • Raspberry Pi Pico W (WiFi-enabled version)
  • USB cable for programming
  • Access to a WiFi network

Software

  • MicroPython v1.19+ (tested on v1.25.0)
  • Any MicroPython-compatible IDE (Thonny, VS Code with Pico extension, etc.)

πŸ”§ Installation

1. Flash MicroPython to Pico W

  1. Download the latest MicroPython firmware for Pico W from micropython.org
  2. Hold the BOOTSEL button while connecting Pico W to USB
  3. Copy the .uf2 file to the RPI-RP2 drive
  4. Pico W will reboot with MicroPython

2. Upload the Script

  1. Connect to your Pico W using your preferred IDE
  2. Copy the entire script to your Pico W
  3. Save as main.py for auto-run on boot, or any .py filename

βš™οΈ Configuration

Edit the WiFi credentials in the script:

# WiFi credentials
WIFI_SSID = 'YourNetworkName'
WIFI_PASSWORD = 'YourPassword'

🎯 Usage

Basic Usage

# Simply run the script
python main.py

Running Individual Tests

# 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 Results Explanation

Connection Quality Ratings

Test Result Description
πŸŽ‰ PERFECT All 5 tests passed - excellent connection
🌟 EXCELLENT 4/5 tests passed - nearly perfect
βœ… GOOD 3/5 tests passed - reliable internet
⚠️ FAIR 2/5 tests passed - basic functionality
❌ POOR <2 tests passed - significant issues

Speed Ratings

Latency Rating Description
<50ms πŸš€ EXCELLENT Very fast connection
50-150ms βœ… GOOD Normal broadband speed
150-300ms ⚠️ MODERATE Acceptable for basic use
>300ms 🐌 SLOW May affect real-time applications

Signal Strength

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

πŸ§ͺ Test Suite Details

1. Hardware Detection

  • Verifies Pico W WiFi capability
  • Prevents errors on standard Pico boards

2. WiFi Connection Test

  • Connects to specified network
  • Reports IP configuration
  • Shows connection status and timing

3. Internet Connectivity Test

  • 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

4. Speed & Latency Test

  • Tests connection time to multiple servers
  • Calculates average latency
  • Provides speed estimates based on response times

5. HTTP Functionality Test

  • Performs actual HTTP requests
  • Tests web service connectivity
  • Validates response data

6. Bandwidth Estimation

  • Times data transfer operations
  • Estimates connection throughput
  • Provides performance ratings

7. Network Environment Scan

  • Scans for available WiFi networks
  • Shows signal strength and security
  • Identifies current network

πŸ” Troubleshooting

Common Issues

"OSError: [Errno 1] EPERM"

Cause: Using standard Pico instead of Pico W
Solution: This script requires a Pico W with WiFi capability

"Connection timeout"

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

"DNS Resolution Failed"

Causes & Solutions:

  • Router DNS issues β†’ Try restarting router
  • ISP DNS problems β†’ Wait and retry
  • Firewall blocking β†’ Check network security settings

"HTTP Test Failed"

Causes & Solutions:

  • Internet filtering β†’ Some networks block external HTTP
  • Temporary service issues β†’ Retry later
  • Firewall restrictions β†’ Check network policies

Debug Mode

Add debug prints by modifying timeout values:

# Increase timeouts for debugging
s.settimeout(30)  # Instead of 5
max_wait = 30     # Instead of 15

πŸ“ˆ Performance Optimization

Memory Management

# Add between tests to free memory
gc.collect()

Faster Connection

# Reduce scan time for known networks
wlan.connect(SSID, PASSWORD)
# Skip network scan if not needed

Custom Test Selection

# Run only essential tests
def quick_test():
    connect_wifi()
    simple_connectivity_test()
    return True

πŸ”§ Customization

Adding Custom Servers

servers = [
    ('your-server.com', 80, 'Custom Server'),
    ('8.8.8.8', 53, 'Google DNS'),
    # Add more servers
]

Custom HTTP Endpoints

# Test your own web services
def test_custom_api():
    # Your custom HTTP test code
    pass

Modified Output Format

# JSON output for logging
def output_json_results(results):
    import json
    return json.dumps(results)

πŸ“ Example Output

============================================================
πŸš€ 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!

πŸ“„ License

This project is open source and available under the MIT License.

🀝 Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for:

  • Additional test types
  • Performance improvements
  • Bug fixes
  • Documentation improvements

πŸ“ž Support

If you encounter issues:

  1. Check the troubleshooting section
  2. Verify you're using a Pico W (not standard Pico)
  3. Confirm MicroPython version compatibility
  4. Test with a different WiFi network

πŸ”— Related Projects


Made for Raspberry Pi Pico W with ❀️

About

Test Pico Wifi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages