Raspberry Pi Pico 2W + Mobile App: Build Your Own Smart Wi-Fi Thermometer!

by gektor650 in Workshop > Home Improvement

76 Views, 1 Favorites, 0 Comments

Raspberry Pi Pico 2W + Mobile App: Build Your Own Smart Wi-Fi Thermometer!

rpi-pico-thermometer-instructables.png

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

Connect Temperature Sensor to PICO

00-schema.jpg
09-case.jpg
08-sensors.jpg

Connect DS18B20 to the Raspberry PI Pico according to schema using a resistor between Red and Yellow wire.

Set Up Visual Studio Code

03-python.jpg
04-pico.jpg
05-micro-pico.jpg
  1. Install Visual Studio Code
  2. Open Settings -> Extensions
  3. Install Python, Raspberry PI Pico, MicroPico

Connect to the Raspberry PI

06-command-palletepng.jpg
07-run-button.jpg
  1. Open View -> Command Pallete
  2. Search for MicroPico: Connect
  3. Create a file main.py
  4. Add a line print("Hello") to the main.py
  5. When Pico connects, run All Commands -> Upload Project
  6. Press "Run"

Clone a Raspberry PI Pico Framework

Run:

git init
git submodule add https://github.com/Nerdy-Things/itk_pico.git

Broadcast Temperature to the Wi-Fi Network

10-test.jpg

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

Clone a Cross-platform Application

git clone https://github.com/Nerdy-Things/raspberry-pi-pico-thermo-sensor-cross-platform.git

Run the Application

14-desktop.jpg
15-android.jpg
16-xcode.jpg
17-xcode.jpg

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.xcodeproj file in xCode. Press Run.