This MicroPython project creates a WiFi hotspot on the Raspberry Pi Pico and serves a web interface that allows you to control the built-in LED and read analog values.
- WiFi Hotspot: Creates an access point named "PicoHotspot"
- Web Interface: Modern, responsive web interface accessible from any device
- LED Control: Toggle the built-in LED on/off via web interface
- Analog Reading: Read analog values from ADC pin and display on website
- Real-time Updates: See current LED status and latest ADC reading
- Raspberry Pi Pico (or Pico W for WiFi capability)
- Micro USB cable for power and programming
- Optional: Analog sensor (potentiometer, light sensor, etc.) connected to GP26
- Built-in LED: GP25 (automatically configured)
- ADC Input: GP26 (ADC0) - for analog readings
- Download the latest MicroPython firmware for Raspberry Pi Pico from micropython.org
- Hold the BOOTSEL button on the Pico while connecting it to your computer
- The Pico will appear as a USB mass storage device
- Copy the
.uf2firmware file to the Pico - The Pico will restart and run MicroPython
- Connect the Pico to your computer
- Copy
main.pyto the Pico's file system - The Pico will automatically run
main.pyon boot
- Power on the Pico
- Look for a WiFi network named "PicoHotspot"
- Connect to it using password:
12345678 - Open a web browser and navigate to:
http://192.168.4.1
The web interface provides:
- LED Control Button: Click to toggle the built-in LED on/off
- Read Analog Button: Click to read the current analog value from GP26
- Status Display: Shows current LED state and latest ADC reading
- The LED button changes color based on current state (green = off, red = on)
- Click the button to toggle between ON and OFF states
- The built-in LED on the Pico will physically turn on/off
- Connect an analog sensor (like a potentiometer) to GP26
- Click "Read Analog Value" to get the current reading
- Values range from 0 to 65535 (16-bit ADC)
- The reading is displayed prominently on the webpage
main.py: Main program file containing all functionality- WiFi hotspot creation and configuration
- Web server implementation
- HTML generation with embedded CSS
- HTTP request handling
- Hardware control (LED and ADC)
Edit these lines in main.py:
ap.config(essid='YourNetworkName', password='YourPassword', authmode=network.AUTH_WPA_WPA2_PSK)To use a different ADC pin, modify:
adc = ADC(26) # Change 26 to your desired pin (26, 27, or 28)The HTML and CSS are embedded in the generate_html() function. You can customize the appearance by modifying the HTML string.
- Ensure you're using a Pico W (has WiFi capability)
- Check that MicroPython is properly installed
- Verify the code is uploaded as
main.py
- Make sure the Pico is powered on
- Check that the SSID "PicoHotspot" appears in your WiFi list
- Try the password:
12345678 - Some devices may take a moment to connect
- Ensure you're connected to the PicoHotspot WiFi
- Try accessing
http://192.168.4.1in your browser - Check the Pico's serial output for error messages
- Verify your analog sensor is connected to GP26
- Check wiring connections
- Ensure the sensor is powered if required
- WiFi Mode: Access Point (AP) mode
- IP Address: 192.168.4.1 (default AP address)
- Port: 80 (HTTP)
- ADC Resolution: 16-bit (0-65535)
- Memory Management: Includes garbage collection to prevent memory issues
- The default WiFi password is simple for testing
- Change the password for production use
- The web interface has no authentication
- Consider adding security measures for sensitive applications
This project is open source and available under the MIT License.