Introduction: Raspberry Pi Pico 2W + Mobile App: Build Your Own Smart Wi-Fi Thermometer!
Have you ever wanted to easily monitor the temperature in every room of your house? The good news is that you can do it effortlessly for under ten dollars!
Supplies
Raspberry PI Pico 2W: https://www.raspberrypi.com/products/raspberry-pi-pico-2/?variant=pico-2-w
Temperature Sensor DS19B20: https://amzn.to/3ZvjAJz
Step 1: Connect Temperature Sensor to PICO
Connect DS18B20 to the Raspberry PI Pico according to schema using a resistor between Red and Yellow wire.
Step 2: Set Up Visual Studio Code
- Install Visual Studio Code
- Open Settings -> Extensions
- Install Python, Raspberry PI Pico, MicroPico
Step 3: Connect to the Raspberry PI
- Open View -> Command Pallete
- Search for MicroPico: Connect
- Create a file main.py
- Add a line print("Hello") to the main.py
- When Pico connects, run All Commands -> Upload Project
- Press "Run"
Step 4: Clone a Raspberry PI Pico Framework
Run:
git init
git submodule add https://github.com/Nerdy-Things/itk_pico.git
Step 5: Broadcast Temperature to the Wi-Fi Network
Replace code in the main.py with:
from itk_pico.temperature import TemperatureSensor
from itk_pico.wifi import WiFi
from itk_pico.udp import Udp
from itk_pico.ip_utils import get_broadcast_address
from time import sleep
import json
UDP_PORT = 5468
temperature_sensor = TemperatureSensor(15)
wifi = WiFi()
udp = Udp(UDP_PORT)
wifi.connect("itkacher", "itkacher")
while True:
wifi.try_reconnect_if_lost()
temperature = temperature_sensor.get_temperature()
broadcast_ip_address = get_broadcast_address(wifi.get_ip_address(), wifi.get_subnet_mask())
message_dict = {"name": "Kitchen", "temperature": temperature}
message = json.dumps(message_dict)
udp.send(message, broadcast_ip_address, UDP_PORT)
sleep(10)
Upload the project to the Raspberry PI Pico 2W and press Run
Step 6: Clone a Cross-platform Application
git clone https://github.com/Nerdy-Things/raspberry-pi-pico-thermo-sensor-cross-platform.git
Step 7: Run the Application
To run a desktop application:
cd raspberry-pi-pico-thermo-sensor-cross-platform
cd kotlin-multiplatform
./gradlew run
To run an Android application:
Open the raspberry-pi-pico-thermo-sensor-cross-platform/kotlin-multiplatform folder in Android Studio. Press Run.
To run an iPhone application:
Open the iosApp/iosApp.xcodeprojfile in xCode. Press Run.





