Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Created August 14, 2024 14:10
Show Gist options
  • Save stonehippo/c7bc004d0b3834dbe70e50f329f770ed to your computer and use it in GitHub Desktop.
Save stonehippo/c7bc004d0b3834dbe70e50f329f770ed to your computer and use it in GitHub Desktop.
Code from my little CircuitPython display
import board
import time
import adafruit_bme680
import adafruit_veml7700
import neopixel
from adafruit_led_animation.animation.rainbow import Rainbow
from adafruit_led_animation.color import RED
from ulab import numpy as np
i2c = board.I2C()
pixel_pin = board.D6
pixel_num = 64
veml = adafruit_veml7700.VEML7700(i2c)
bme = adafruit_bme680.Adafruit_BME680_I2C(i2c)
def celcius_to_fahrenheit(c):
return c * 1.8 + 32
def print_conditions(delay = 1):
temp_raw = bme.temperature
temp_c = round(temp_raw, 1)
temp_f = round(celcius_to_fahrenheit(temp_c), 1)
hum = round(bme.humidity, 1)
lux = int(veml.lux)
print(f'Current light level: {lux} lux')
print(f'Current temp: {temp_c}ºC/{temp_f}ºF, Current humidity: {hum}% rH')
print('-----')
time.sleep(delay)
# Watch out for running the NeoPixels at full brightness! They candraw too much current
# for the onboard regulator when run with lots of full brightness pixels (e.g. "white")
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.4, auto_write=False)
pixels.fill((255, 0, 0))
pixels.show()
animation = Rainbow(pixels, speed=0.05)
while True:
# print_conditions()
animation.animate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment