I am attempting to get my Tufty to display data from a bme280 in graph form so that I can track trends. specifically I want to monitor the barometric pressure the most to be able to predict incoming bad weather. I also live in a hurricane prone area and would like to be able to watch data as a storm approaches. Below is where I’m stuck. I’ve used the awesome info from GitHub - kevinmcaleer/pico_dashboard and some work on my own. I have the empty graphs displaying but can’t for the life of me figure out where I’m need to add the data portion. If just recently began experimenting with the 2040 products. and I’m having a lot of fun and learning a lot.
import picodisplay2 as display
from pichart import Chart, Card, Container
from Colour import hsv2rgb, rgb2hsv, fade
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
display = PicoGraphics(display=DISPLAY_TUFTY_2040, rotate=180, pen_type=PEN_RGB332)
import gc
import machine
from time import sleep
import utime
from random import randint
from pimoroni_i2c import PimoroniI2C
from breakout_bme280 import BreakoutBME280
PINS_BREAKOUT_GARDEN = {“sda”: 4, “scl”: 5}
PINS_PICO_EXPLORER = {“sda”: 20, “scl”: 21}
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
WIDTH, HEIGHT = 240,240
from breakout_bme280 import BreakoutBME280
from pimoroni_i2c import PimoroniI2C
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
PINS_BREAKOUT_GARDEN = {“sda”: 4, “scl”: 5}
PINS_PICO_EXPLORER = {“sda”: 20, “scl”: 21}
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
bme = BreakoutBME280(i2c)
temperature, pressure, humidity = bme.read()
pressuremb = pressure / 100
temperature = temperature * 9/5+ 32
scaled_temp = int(temperature + 40) # Range from -40 to +60 = 1-100
scaled_press = int((pressure - 87000) / ((108400 - 87000) / 100)) # Range 108400 - 87000 = 1 -100
scaled_humid = int(humidity) # Range 1 - 100
Set the theme colour
THEME = {‘red’: 255, ‘green’: 171, ‘blue’: 57}
THEME2 = {‘red’: 252, ‘green’: 193, ‘blue’: 109}
THEME3 = {‘red’: 151, ‘green’: 250, ‘blue’: 121}
WHITE = {‘red’: 255, ‘green’: 255, ‘blue’: 255}
LIGHT_GREY = {‘red’: 240, ‘green’: 240, ‘blue’: 240}
BLUE = {‘red’: 20, ‘green’: 155, ‘blue’: 206}
LIGHT_BLUE = {‘red’: 55, ‘green’: 170, ‘blue’: 213}
BLACK = {‘red’: 0, ‘green’: 0, ‘blue’: 0}
GREEN = {‘red’: 0, ‘green’: 220, ‘blue’: 0}
LIGHT_GREEN = fade(GREEN, WHITE, 0.15)
DARK_GREEN = fade(GREEN, BLACK, 0.15)
ORANGE = {‘red’: 255, ‘green’: 171, ‘blue’: 57}
LIGHT_ORANGE = {‘red’: 255, ‘green’: 195, ‘blue’: 110}
Frame background colour
BACKGROUND = {‘red’: 255, ‘green’: 171, ‘blue’: 57}
border = 20
frame(border,border,width-(border2),height-(border2),BACKGROUND)
chart1 = Chart(display, title=‘Temprature’)
chart2 = Chart(display, title=‘Humidity’)
chart3 = Chart(display, title=“Pressure”,)
chart4 = Chart(display, title=“Humidity”,)
chart1.background_colour = BLACK
chart1.data_colour = WHITE
chart1.title_colour = WHITE
chart1.border_colour = WHITE
chart1.grid_colour = DARK_GREEN
chart1.border_width = 1
chart2.border_width = 1
chart3.border_width = 1
chart4.border_width = 1
container = Container(display)
container.add_chart(chart1)
container.add_chart(chart2)
container.add_chart(chart3)
container.add_chart(chart4)
container.background_colour = BLACK
container.grid_colour = DARK_GREEN
container.data_colour = WHITE
container.title_colour = WHITE
container.border_colour = GREEN
container.border_width = 1
chart1.show_bars = True
chart1.show_lines = False
chart1.data_point_radius = 2
chart1.show_datapoints = True
chart1.show_labels = True
chart2.show_bars = False
chart2.show_lines = True
chart3.data_point_radius = 2
chart3.show_datapoints = True
chart3.show_bars = False
chart3.show_labels = True
chart3.show_lines = True
chart4.show_labels = True
container.cols = 2
container.update()
data = [20,34]
chart1.x_values = data
chart2.x_values = data
chart3.x_values = data
chart4.x_values = [0,50]
chart1.scale_data()
chart2.scale_data()
chart3.scale_data()
chart4.scale_data()
data =
air_quality_data =
chart1.x_values = data
chart3.x_values = data
chart4.x_values = air_quality_data
while True:
temperature, pressure, humidity = bme.read()
pressuremb = pressure / 100
temperature = temperature * 9/5+ 32
draw_graph(temperature, pressure, humidity)
print("{:0.2f}F, {:0.2f}mb, {:0.2f}%".format(
temperature, pressuremb, humidity))
utime.sleep (1)