diff --git a/micropython/examples/tiny_2350/breakouts/bme688-breakout.py b/micropython/examples/tiny_2350/breakouts/bme688-breakout.py new file mode 100644 index 0000000..baf8a7d --- /dev/null +++ b/micropython/examples/tiny_2350/breakouts/bme688-breakout.py @@ -0,0 +1,37 @@ +import time +from pimoroni import RGBLED +from pimoroni_i2c import PimoroniI2C +from breakout_bme68x import BreakoutBME68X + +# SDA and SCL pins for the Tiny 2350 QW/ST connector +PINS_TINY_2350 = {"sda": 12, "scl": 13} + +# Setup an instance of I2C and BME68X +i2c = PimoroniI2C(**PINS_TINY_2350) +bme = BreakoutBME68X(i2c) + +# Setup the RGB Led +led = RGBLED(18, 19, 20) + +# Values for high (red) and low (blue) temperature. Adjust these if you like :) +HIGH = 24 +LOW = 18 + + +while True: + # Grab the readings + temperature, pressure, humidity, gas_resistance, status, gas_index, meas_index = bme.read() + + # Print the current temperature, you'll be able to see this in Thonny's shell + print(temperature) + + # Set the LED based on the latest temperature reading + if temperature >= HIGH: + led.set_rgb(255, 0, 0) + elif temperature <= LOW: + led.set_rgb(0, 0, 255) + else: + led.set_rgb(0, 255, 0) + + # Now we take a little nap before the next reading ZzzzZz + time.sleep(1) diff --git a/micropython/examples/tiny_2350/breakouts/scd41-breakout.py b/micropython/examples/tiny_2350/breakouts/scd41-breakout.py new file mode 100644 index 0000000..2bb8c88 --- /dev/null +++ b/micropython/examples/tiny_2350/breakouts/scd41-breakout.py @@ -0,0 +1,40 @@ +import time +from pimoroni import RGBLED +from pimoroni_i2c import PimoroniI2C +import breakout_scd41 + +# SDA and SCL pins for the Tiny 2350 QW/ST connector +PINS_TINY_2350 = {"sda": 12, "scl": 13} + +# Setup an instance of I2C and SCD41 +i2c = PimoroniI2C(**PINS_TINY_2350) +breakout_scd41.init(i2c) + +# Setup the RGB Led and then turn it off +led = RGBLED(18, 19, 20) +led.set_rgb(0, 0, 0) + +# 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 CO2 measurement, you'll be able to see this in Thonny's shell + print(co2) + + # Change the onboard LED based on the current CO2 levels + + if co2 < 1000: + led.set_rgb(0, 255, 0) + elif co2 >= 1000 and co2 <= 2000: + led.set_rgb(255, 165, 0) + elif co2 > 2000: + led.set_rgb(255, 0, 0) + + # Now we take a little nap before the next reading ZzzzZz + time.sleep(3) diff --git a/micropython/examples/tiny_2350/buttons.py b/micropython/examples/tiny_2350/buttons.py new file mode 100644 index 0000000..81e03ae --- /dev/null +++ b/micropython/examples/tiny_2350/buttons.py @@ -0,0 +1,11 @@ +import time +import machine + +user_button = machine.Pin(23, machine.Pin.IN) + +while True: + + if user_button.value() == 0: + print("BUTTON PRESSED!") + + time.sleep(0.2) diff --git a/micropython/examples/tiny_2350/rgb_led.py b/micropython/examples/tiny_2350/rgb_led.py new file mode 100644 index 0000000..90a9844 --- /dev/null +++ b/micropython/examples/tiny_2350/rgb_led.py @@ -0,0 +1,15 @@ +from pimoroni import RGBLED +from time import sleep + +# Setup the RGB Led +led = RGBLED(18, 19, 20) + +# Cycle through RGB + +while True: + led.set_rgb(255, 0, 0) + sleep(1) + led.set_rgb(0, 255, 0) + sleep(1) + led.set_rgb(0, 0, 255) + sleep(1)