I love the Raspberry Pi Pico with MicroPython

As soon as I heard of the new „Raspberry Pi Pico“ I wanted one! It‘s a microcontroller which is programmable with MicroPython. Since my main coding language is Python and I always wanted to start some little electronics projects I decided to buy some.

Today they came! I got to work and had a look at some online getting started guides on how to upload and run the code. It‘s as easy as pressing the „BOOTSEL“ (Boot Selection) button when connecting it to your Computer - by doing that it‘ll be detected as a kind of USB-Stick.

After making some tiny LED blinking projects I made this:

from machine import Pin, ADC
import utime

blueLED = Pin(2, Pin.OUT)
greenLED = Pin(3, Pin.OUT)
redLED = Pin(4, Pin.OUT)
sensor_temp = ADC(4)
conversion_factor = 3.3 / (65535)

def checkTemp(temp):
    temp = round(temp)
    if temp >= 20 and temp <= 22:
        print("TEMP OK - {0}°C".format(temp))
        print("TEMP NOT OK - {0}°C".format(temp))
        if temp < 20:
        elif temp > 22:
while True:
    reading = sensor_temp.read_u16() * conversion_factor 
    temperature = 27 - (reading - 0.706)/0.001721

It measures the temperature and indicates it in the following way: Blue LED: Too cold (under 20°C) Green LED: Good (between 20°C and 22°C) Red LED: Too hot (over 22°C)

Again, it‘s relatively simple but I like how quick and easy it was! If you want to try this out, I‘d recommend you to get the Thonny IDE. Also don‘t forget to save your file as main.py on the Pico.

Sources: heise, how2electronics.com