Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsThe Raspberry Pi has a hardware serial port on GPIO 14 and 15. Connected to a GPS module, a short Python script using pyserial reads the NMEA sentences and writes a row to a CSV file every five seconds, ready to open in a spreadsheet or map tool. Serial login must be turned off in raspi-config first, or the console will fight the GPS for the port. A first position fix needs a clear sky view and can take minutes.
Tick anything you already have and the total updates.
microSD card for the operating system
Follow the colours: red is power, dark grey is ground, blue is a signal.
Official Pi 4 power supply, or a power bank for carrying it.
gps_log.pyimport csv, time
import serial
def to_deg(value, hemi):
deg = int(float(value) / 100)
d = deg + (float(value) - deg * 100) / 60
return -d if hemi in ("S", "W") else d
port = serial.Serial("/dev/serial0", 9600, timeout=1)
last_write = 0
with open("track.csv", "a", newline="") as f:
w = csv.writer(f)
if f.tell() == 0:
w.writerow(["utc_time", "latitude", "longitude", "speed_kmh"])
while True:
line = port.readline().decode("ascii", errors="ignore").strip()
if line[3:6] != "RMC":
continue
p = line.split(",")
if len(p) < 8 or p[2] != "A":
continue
if time.time() - last_write < 5:
continue
last_write = time.time()
speed = float(p[7] or 0) * 1.852
w.writerow([p[1], round(to_deg(p[3], p[4]), 6), round(to_deg(p[5], p[6]), 6), round(speed, 1)])
f.flush()
Check that serial is enabled, the login shell is off, and TX and RX are crossed.
No fix yet. Go outdoors and wait. Only valid fixes are saved.
Add your user to the dialout group: sudo usermod -aG dialout $USER, then log in again.
Yes, from a power bank, with the GPS near a window.
Yes. Many online tools accept latitude and longitude columns from a CSV.
Yes, the same pins work, but the serial device name can differ; check with ls /dev/serial*.
6 parts: Raspberry Pi 4 Model B 2GB RAM Single Board Computer, Official Raspberry Pi 4 USB-C Power Supply – 15.3W, Official Raspberry Pi 32GB A2 Class Micro SD Card, DFRobot Gravity GNSS GPS BeiDou Receiver Module – I2C & UART, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (gps_log.py).
About ₹10,323 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Enabling the Pi's hardware serial port; Reading NMEA with pyserial; Writing a CSV track file.
Ideas that reuse this build: Pico GPS clock and position. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.