Pico Plus 2: new examples

This commit is contained in:
thirdr 2024-08-09 13:43:24 +01:00
parent 7e38164d7b
commit c19c7ac4ac
4 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import time
from pimoroni_i2c import PimoroniI2C
from breakout_bme68x import BreakoutBME68X
# SDA and SCL pins for the Pico Plus 2 QW/ST connector
PINS_PICO_PLUS_2 = {"sda": 4, "scl": 5}
# Setup an instance of I2C and BME68X
i2c = PimoroniI2C(**PINS_PICO_PLUS_2)
bme = BreakoutBME68X(i2c)
while True:
# Grab the readings
temperature, pressure, humidity, gas_resistance, status, gas_index, meas_index = bme.read()
# Print the current temperature, pressure and humidity. You'll be able to see this in Thonny's shell
print("Temperature: {}°C\nPressure:{} Pa\nHumidity:{} %rH\n\n".format(temperature, pressure, humidity))
# Now we take a little nap before the next reading ZzzzZz
time.sleep(1)

View File

@ -0,0 +1,26 @@
import time
from pimoroni_i2c import PimoroniI2C
import breakout_scd41
# SDA and SCL pins for the Pico Plus 2 QW/ST connector
PINS_PICO_PLUS_2 = {"sda": 4, "scl": 5}
# Setup an instance of I2C and BME68X
i2c = PimoroniI2C(**PINS_PICO_PLUS_2)
breakout_scd41.init(i2c)
# Start the SCD41 sensor
breakout_scd41.start()
while True:
# Grab the readings if the sensor is ready.
if breakout_scd41.ready():
co2, temperature, humidity = breakout_scd41.measure()
# Print the latest measurements, you'll be able to see this in Thonny's shell.
print("CO2: {} PPM\nTemperature: {}°C\nHumidity: {} %RH\n\n".format(co2, temperature, humidity))
# Now we take a little nap before the next reading ZzzzZz
time.sleep(3)

View File

@ -0,0 +1,13 @@
from machine import Pin
# Setup the LED and Button pin.
led = Pin(25, Pin.OUT)
button = Pin(45, Pin.IN)
# Light the LED when the button is presed!
while True:
if button.value() == 0:
led.value(1)
else:
led.value(0)

View File

@ -0,0 +1,14 @@
import time
from machine import Pin
# Setup the LED pin.
led = Pin(25, Pin.OUT)
# Blink the LED!
while True:
led.value(1)
time.sleep(1)
led.value(0)
time.sleep(1)