This repository contains a C-based project for the Raspberry Pi Pico W that transforms the device into a standalone Wi-Fi Access Point and Web Server to monitor CO2, temperature, and humidity using a Sensirion SCD30 sensor.
- Standalone Access Point: Hosts a Wi-Fi network named
Pico_CO2_Monitor. - Web Dashboard: Serves a mobile-friendly HTML interface that auto-refreshes every 3 seconds to display real-time sensor data.
- Integrated Network Services: Includes a built-in DHCP server and DNS server to provide a seamless "captive portal-like" experience.
- Thread-Safe Networking: Utilizes
pico_cyw43_arch_lwip_threadsafe_backgroundfor stable Wi-Fi and sensor concurrent operations. - Robust Sensor Handling: Implements a blocking read with retries to mitigate I2C collisions during Wi-Fi activity.
- Raspberry Pi Pico W or Pico 2 W.
- Sensirion SCD30 Sensor.
| SCD30 Pin | Pico W Pin |
|---|---|
| VCC | 3V3 / VSYS |
| GND | GND |
| SDA | GPIO 4 |
| SCL | GPIO 5 |
main.c: Core application logic, Web Server, and sensor polling loop.dhcpserver/: Implementation of a lightweight DHCP server for assigning client IPs.dnsserver/: A simple DNS server that resolves all queries to the Pico's IP (192.168.4.1).sensirion_i2c_hal.c: Hardware Abstraction Layer mapping Sensirion's I2C calls to the Pico SDK.- Can configure I2C pins and speed via
sensirion_i2c_hal_init().
- Can configure I2C pins and speed via
lwipopts.h: Optimized LwIP configuration for Access Point and DHCP functionality.
- Use VSCode with the official Pico extension for easier building and flashing.
Ctlr+Shift+P->CMake: Configure- Click
Compilein bottom bar. - Put your Pico W into BOOTSEL mode (hold the BOOTSEL button while plugging it in).
- Click
Runin bottom bar to flash the firmware.
- Power the Pico W.
- Connect your phone or computer to the Wi-Fi network "Pico_CO2_Monitor" using the password "12345678".
- Open a web browser and navigate to
http://192.168.4.1. - The dashboard will display current CO2 (ppm), Temperature (°C), and Humidity (%).
- The SCD30 sensor is set to a 2-second measurement interval to balance responsiveness and I2C stability.
- The web page auto-refreshes every 3 seconds to provide near real-time updates without overwhelming the network or sensor.
- The I2C bus rate was set to 50kHz which seems to prevent the senor from locking up.
- Probably should not add more sensors to the same I2C bus.
This project is licensed under the MIT License - see the LICENSE file for details
