The Raspberry Pi Pico 2W pairs the dual-core RP2350 microcontroller with the Infineon CYW43439 Wi-Fi/Bluetooth chip, delivering 520KB of SRAM and 4MB of flash for roughly $7. Unlike the original Pico W, the RP2350 architecture introduces a selectable Arm Cortex-M33 or Hazard3 RISC-V core, alongside a completely redesigned power delivery system that mitigates the brownout issues that plagued early Pico 1W Wi-Fi transmissions.
This guide walks through building a Wi-Fi connected DS18B20 temperature logger. We will use pure, built-in MicroPython libraries—meaning you can copy, paste, and run the code without hunting down third-party drivers.
Hardware BOM and RP2350 Spec Comparison
Before wiring, it is critical to understand how the Pico 2W stacks up against its predecessor and the ubiquitous ESP32-C3. The RP2350's 520KB SRAM is a massive upgrade for buffering HTTP/TLS payloads, but the CYW43439 Wi-Fi chip still strictly requires 2.4GHz networks.
| Feature | Raspberry Pi Pico 1W | Raspberry Pi Pico 2W | ESP32-C3 SuperMini |
|---|---|---|---|
| MCU Core | Dual RP2040 (Arm M0+) | Dual RP2350 (Arm M33 / RISC-V) | Single RISC-V |
| SRAM | 264 KB | 520 KB | 400 KB |
| Flash | 2 MB | 4 MB | 4 MB |
| Wi-Fi Chip | CYW43439 | CYW43439 | Integrated |
| Typical Price | $6.00 | $7.00 | $3.50 |
Required Parts List
- Board: Raspberry Pi Pico 2W with pre-soldered headers (Part # SC1155)
- Sensor: Waterproof DS18B20 Digital Temperature Probe (includes built-in 4.7kΩ pull-up resistor in the tip, or use a standalone 4.7kΩ resistor)
- Power: 5V/2A USB-C power supply (crucial for Wi-Fi transmission spikes)
- Wiring: 22 AWG solid core jumper wires, half-size breadboard
Pin Mapping and Breadboard Wiring
The RP2350 features 48 GPIO pins, but the Pico 2W board breaks out 26 of them. A common bench mistake is assuming the onboard LED is on GP25 like the Pico 1. On the Pico 2W, the LED is wired to the CYW43439 Wi-Fi chip and must be addressed as WL_GPIO0.
| Pico 2W Pin | RP2350 GPIO | DS18B20 Wire Color | Function / Notes |
|---|---|---|---|
| Pin 38 (GND) | GND | Black (or Blue) | Common Ground |
| Pin 36 (3V3 OUT) | 3.3V | Red | Sensor VCC (Max 300mA draw) |
| Pin 21 (GP16) | GPIO 16 | Yellow (or White) | OneWire Data Bus |
85°C (the default power-on reset value) or throw a OneWireError.
Assembly Steps
- Insert the Pico 2W into the breadboard, ensuring the USB port faces the edge.
- Connect the DS18B20 Red wire to Pin 36 (3V3 OUT) and Black wire to Pin 38 (GND).
- Connect the Yellow data wire to Pin 21 (GP16).
- If using a raw sensor (not a waterproof probe), insert the 4.7kΩ pull-up resistor between the Red and Yellow wires.
- Plug the USB-C cable into the Pico 2W and connect it to your PC for flashing.
MicroPython Code: Wi-Fi and Sensor Telemetry
Target Board Variant: This code is written specifically for the Raspberry Pi Pico 2W running MicroPython v1.24.0+ (RP2350 build). Do not flash the RP2040 firmware, or the CYW43439 Wi-Fi driver will fail to initialize.
The script below reads the temperature and uses the built-in urequests library to POST the data to a local HTTP endpoint. We include explicit memory cleanup to prevent the ENOMEM crashes common in long-running IoT loops.
# main.py - Raspberry Pi Pico 2W DS18B20 HTTP Logger
import network
import time
import machine
import onewire
import ds18x20
import urequests
# --- Pin Definitions ---
ONE_WIRE_PIN = 16
# Note: Pico 2W LED is on the Wi-Fi chip, not GP25
LED_PIN = 'WL_GPIO0'
# --- Network Configuration ---
SSID = 'Your_2.4GHz_SSID'
PASSWORD = 'Your_Password'
WEBHOOK_URL = 'http://192.168.1.50:8080/api/temperature'
def connect_wifi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
# Prevent Wi-Fi chip from sleeping during critical TX
wlan.config(pm = 0xa11140)
print(f'Connecting to {SSID}...')
wlan.connect(SSID, PASSWORD)
timeout = 15
while not wlan.isconnected() and timeout > 0:
time.sleep(1)
timeout -= 1
if wlan.isconnected():
print('Wi-Fi Connected:', wlan.ifconfig())
return wlan
else:
raise RuntimeError('no available wifi network')
def read_temp(ds_sensor):
ds_sensor.convert_temp()
time.sleep_ms(750) # DS18B20 requires 750ms for 12-bit conversion
roms = ds_sensor.scan()
if not roms:
return None
return ds_sensor.read_temp(roms[0])
def main():
led = machine.Pin(LED_PIN, machine.Pin.OUT)
ds_pin = machine.Pin(ONE_WIRE_PIN)
ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))
wlan = connect_wifi()
while True:
try:
temp_c = read_temp(ds_sensor)
if temp_c is None:
print('Sensor not found. Check pull-up resistor.')
time.sleep(5)
continue
payload = {'device': 'pico2w_01', 'temp_c': temp_c}
print(f'Sending: {payload}')
led.value(1) # Turn on CYW43439 LED
# HTTP POST with error handling
response = urequests.post(WEBHOOK_URL, json=payload)
print(f'Status: {response.status_code}')
# CRITICAL: Close response to free SRAM and prevent ENOMEM
response.close()
led.value(0)
except Exception as e:
print(f'Transmission Error: {e}')
# Blink LED rapidly to indicate fault state
for _ in range(5):
led.value(not led.value())
time.sleep(0.1)
time.sleep(60) # Log every 60 seconds
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Logger stopped by user.')
machine.reset()
Debugging: Exact Errors and the First Three Checks
The CYW43439 driver on the RP2350 is robust, but power delivery and network configuration still cause 90% of bench failures. If your script crashes, look for these exact error strings in the Thonny shell.
Error 1: RuntimeError: no available wifi network
This occurs when wlan.connect() times out or the Wi-Fi chip fails to scan.
- Cause 1 (Most Likely): You are trying to connect to a 5GHz or WPA3-Enterprise network. The CYW43439 is strictly 2.4GHz 802.11n and supports WPA2-PSK.
- Cause 2: USB brownout. The Wi-Fi chip draws up to 150mA during TX. If powered by a standard PC USB 2.0 port (500mA limit) with a high-resistance cable, the 3.3V rail sags, resetting the Wi-Fi chip silently.
- Cause 3: Wrong firmware. You flashed the RP2040
.uf2file instead of the RP2350 file. The driver cannot find the hardware PCI interface.
Error 2: OSError: [Errno 12] ENOMEM
This translates to 'Out of Memory' and usually happens on the 4th or 5th loop iteration during the urequests.post() call.
- Cause 1 (Most Likely): You forgot to call
response.close(). MicroPython's garbage collector does not instantly reclaim the socket buffers allocated byurequests, rapidly exhausting the 520KB SRAM. - Cause 2: The HTTP endpoint is returning a massive HTML error page instead of a lightweight JSON acknowledgement, filling the receive buffer.
- Verify Firmware: Hold BOOTSEL, plug in USB, and ensure the drive says
RPI-RP2350, notRPI-RP2. Flash the latest stable RP2350 MicroPython build from micropython.org. - Check Power: Swap the USB cable for a known-good, short (<1 meter) data cable and plug it into a dedicated 5V/2A wall brick, not a PC hub.
- Ping the Target: Open a terminal on your PC and ping your webhook IP address to ensure your PC and the Pico are on the same VLAN/subnet.
Extending and Simplifying the Build
Depending on your deployment environment, you may need to strip this project down to its bare essentials or scale it up for home automation integration.
How to Simplify (Battery/Remote Deployment)
If you are running this on a LiFePO4 cell in a remote enclosure, drop the HTTP POST and switch to ESP-NOW or Bluetooth Low Energy (BLE) advertising. The RP2350 supports deep sleep via machine.deepsleep(). By putting the CYW43439 to sleep and waking only the RTC (Real Time Clock) every 15 minutes to take a single DS18B20 reading, you can reduce average current draw from 45mA to under 15µA, yielding months of runtime on a single 18650 cell.
How to Extend (Home Assistant Integration)
To integrate this directly into Home Assistant without a middle-man server, replace the urequests HTTP block with the umqtt.robust library. Publish the JSON payload to the homeassistant/sensor/pico2w/temp topic. Because the Pico 2W has double the SRAM of the Pico 1W, you can comfortably load the TLS certificates required to connect securely to a Mosquitto broker running on port 8883, a task that frequently caused memory panics on the older RP2040.
For deeper architectural details on the RP2350's security and memory subsystems, refer to the official Raspberry Pi Pico Series Documentation and the MicroPython RP2 Quick Reference.






