# Presto weather station

**URL:** <https://forums.pimoroni.com/t/presto-weather-station/26964>\
**Category:** Support\
**Created:** [December 31, 2024, 3:22pm UTC](https://forums.pimoroni.com/t/presto-weather-station/26964 "2024-12-31T15:22:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mac](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mac](https://forums.pimoroni.com/u/Mac)\
**Post date:** [December 31, 2024, 3:22pm UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/1 "2024-12-31T15:22:01Z")

</div>

I received my new Presto Sunday and have enjoyed playing it. I have had no problem with other codes but when I try to adapt an Enviro+ bme688.py code to display weather the display is blank. I2C functions are normal. This is what I am using…

“”"BME688 / BME680 demo

This demo will work for both the BME680 and BME688.  
“”"  
import time  
from breakout\_bme68x import BreakoutBME68X, STATUS\_HEATER\_STABLE  
from machine import I2C  
from presto import Presto

I2C\_PINS = {“id”: 0, “sda”: 40, “scl”: 41} # The I2C pins the QwSTPad is connected to  
BRIGHTNESS = 1.0

i2c = I2C(\*\*I2C\_PINS)  
bmp = BreakoutBME68X(i2c, address=0x77)

presto = Presto(ambient\_light=True)  
display = presto.display

WIDTH, HEIGHT = display.get\_bounds()

# setup background

BG = display.create\_pen(0, 0, 0)  
TEXT = display.create\_pen(255, 255, 255)  
TEMP = display.create\_pen(255, 0, 0)  
PRESS = display.create\_pen(255, 255, 0)  
HUMID = display.create\_pen(0, 255, 0)

display.set\_pen(BG)  
display.clear()

def draw(temp\_value, press\_value, humid\_value):  
scaled\_temp = int(temp\_value + 40) # Range from -40 to +60 = 1-100  
scaled\_press = int((press\_value - 87000) / ((108400 - 87000) / 100)) # Range 108400 - 87000 = 1 -100  
scaled\_humid = int(humid\_value) # Range 1 - 100  
display.set\_pen(BG)  
display.clear()  
display.set\_pen(TEMP)  
display.rectangle(0, 60, scaled\_temp, 60)  
display.text(“TEMP: {:0.2f}c”.format(temp\_value), scaled\_temp + 5, 80, scale=2)  
display.set\_pen(PRESS)  
display.text(“PRESS: {:0.2f}Pa”.format(press\_value), scaled\_press + 5, 140, scale=2)  
display.rectangle(0, 120, scaled\_press, 60)  
display.set\_pen(HUMID)  
display.text(“HUMID: {:0.2f}%”.format(humid\_value), scaled\_humid + 5, 200, scale=2)  
display.rectangle(0, 180, scaled\_humid, 60)  
display.set\_pen(TEXT)  
display.text(“BME688 enviro Sensor”, 5, 10, scale=2)  
display.update()

while True:  
temperature, pressure, humidity, gas, status, \_, \_ = bmp.read()  
draw(temperature, pressure, humidity)  
heater = “Stable” if status & STATUS\_HEATER\_STABLE else “Unstable”  
print(“{:0.2f}c, {:0.2f}Pa, {:0.2f}%, {:0.2f} Ohms, Heater: {}”.format(  
temperature, pressure, humidity, gas, heater))  
time.sleep(1.0)  
I know I’m missing something, just can’t see it. Any and all help is greatly appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![Tonygo2](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/tonygo2/32/7814_2.png) [@Tonygo2](https://forums.pimoroni.com/u/Tonygo2)\
**Post date:** [January 1, 2025, 10:28am UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/2 "2025-01-01T10:28:23Z")

</div>

Try using **very** simple **display.text(temp\_value**) statments first and then work on the formatting.

When posting code please click on the \</\> icon and paste the code in the blue hi-lighted area so we can see the indents…

---

<div class="post-metadata">

**Author:** ![Mac](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mac](https://forums.pimoroni.com/u/Mac)\
**Post date:** [January 2, 2025, 6:28pm UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/3 "2025-01-02T18:28:07Z")

</div>

Thank you for your help. I reworked it all and managed to get this simple code going…

```auto
import time
from breakout_bme280 import BreakoutBME280
from pimoroni_i2c import PimoroniI2C
from presto import Presto

PINS_BREAKOUT_GARDEN = {"sda": 40, "scl": 41}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
bme = BreakoutBME280(i2c)

# Setup for the Presto display
presto = Presto(ambient_light=True)
display = presto.display
WIDTH, HEIGHT = display.get_bounds()

# Couple of colours for use later
BLUE = display.create_pen(90, 100, 202)
WHITE = display.create_pen(200, 155, 55)

while True:

    # Clear the screen and use blue as the background colour
    display.set_pen(BLUE)
    display.clear()
    # Set the pen to a different colour otherwise we won't be able to see the text!
    display.set_pen(WHITE)
    
     # read the sensors
    temperature, pressure, humidity = bme.read()
    # pressure comes in pascals which is a reight long number, lets convert it to the more manageable hPa
    pressurehpa = pressure / 100
    
    # draw the text
    display.set_pen(WHITE)
    display.text("temperature:", 10, 10, 240, 3)
    display.set_pen(WHITE)
    display.text('{:.1f}'.format(temperature) + 'C', 10, 30, 240, 5)
    
    # and the pressure text
    display.text("pressure:", 10, 85, 240, 3)
    display.text('{:.0f}'.format(pressurehpa) + 'hPa', 10, 105, 240, 5)
    
     # and the humidity text
    display.text("humidity:", 10, 160, 240, 3)
    display.text('{:.0f}'.format(humidity) + '%', 10, 180, 240, 5)

    # Finally we update the screen with our changes :)
    presto.update()

while True:
    reading = bme.read()
    print(reading)
    time.sleep(1.0)
    
 

    # Finally we update the screen with our changes :)
    presto.update()

```

Thanks again

---

<div class="post-metadata">

**Author:** ![Tonygo2](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/tonygo2/32/7814_2.png) [@Tonygo2](https://forums.pimoroni.com/u/Tonygo2)\
**Post date:** [January 4, 2025, 10:38am UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/4 "2025-01-04T10:38:46Z")

</div>

The sensor stick also has a light sensor which reads Lux. I’ve also got an **AHT20** (temperature and relative humidity) so I’ve tested them as well. There temperature and hums readings are different. I find the AHT20 to be nearer to my NPL certified old school, Hg thermometer reading on my desktop!

You can stop the program by touching the screen. (The touch aspect of the screen is very accurate.) I’ve not done any on screen formatting, that is the fun part.

The **Qw/STpad** also works very well if you want ‘proper’ buttons.

```auto
# Sensor readings on Pimoroni Explorer
import time
from machine import Pin, I2C
from breakout_bme280 import BreakoutBME280
from breakout_ltr559 import BreakoutLTR559
import ahtx0
import math
from presto import Presto
'''
import network
import rp2
import requests
rp2.country("GB")
from secrets import WIFI_SSID, WIFI_PASSWORD
'''
# Setup for the Presto display
presto = Presto(full_res=True)
display = presto.display

WIDTH, HEIGHT = display.get_bounds()

touch = presto.touch # Activate touch

# Create some colours
BLUE = display.create_pen(20,0,255)
WHITE = display.create_pen(255, 255, 255)
RED = display.create_pen(255,0,0)
ORANGE = display.create_pen(245, 165, 4)
GREEN = display.create_pen(0,255,0)
PINK = display.create_pen(250, 125, 180)
CYAN = display.create_pen(0,255,255)
MAGENTA = display.create_pen(255,0,255)
BLACK = display.create_pen(0, 0, 0)
YELLOW = display.create_pen(255, 255, 0)

# A few procedures to be used later
def wait(z): # delay a while
    time.sleep(z)
    
def clean(): # Clear the screen to Black
    display.set_pen(BLACK)
    display.clear()
    presto.update()

clean()
i2c = I2C(id=0,scl=Pin(41), sda=Pin(40)) # PESTO

# Check sensors connected
try:
    bme = BreakoutBME280(i2c, address=0x76)
    ltr = BreakoutLTR559(i2c)
    aht20 = ahtx0.AHT20(i2c)
except RuntimeError:
    print("Multi-Sensor Stick or AHT20 missing")

touch = presto.touch # Activate touch

display.set_font("bitmap8") # Change the font
clean()

display.set_pen(RED)
display.text("Presto Sensors",40,120,460,8)
display.set_pen(YELLOW)
display.text("BME280, TR559, AHT20",40,320,460,4)
presto.update()
# Wake up lux sensor
prox, a, b, c, d, e, lux = ltr.get_reading()
time.sleep(1.0)

# Main loop

while True:
    prox, a, b, c, d, e, lux = ltr.get_reading()
    lux = int(lux)
    
    print("\nAHT20")
    print("Temperature: %0.2f C" % aht20.temperature)
    print("Humidity: %0.2f %%" % aht20.relative_humidity)

    # read the sensors
    temperature, pressure, humidity = bme.read()
    temp = round(temperature,2)

    # Convert pressure to hPa
    pressurehpa = int(pressure / 100)
    touch.poll()
    if touch.state:
        break
    
    print("\nBME280")

    print("Temperature: "+str(temp)+" C")
    print("Humidity: "+str(int(humidity)) +" %")
    print("Pressure: "+str(pressurehpa)+" hPa")

    print("\nLTR559\n"+str(lux),"LUX")
    print("\n====================")

    time.sleep(1)
    touch.poll()
    if touch.state:
        break
clean()
presto.update()

```

Sample output:

```auto
====================

AHT20
Temperature: 17.01 C
Humidity: 63.50 %

BME280
Temperature: 17.6 C
Humidity: 59 %
Pressure: 1008 hPa

LTR559
9 LUX

====================

```

---

<div class="post-metadata">

**Author:** ![Mac](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mac](https://forums.pimoroni.com/u/Mac)\
**Post date:** [January 4, 2025, 7:59pm UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/5 "2025-01-04T19:59:54Z")

</div>

Thank you for your help. I went with an Adafruit BME688 I had on hand and added more color options to change things up. I really do like this display and will work on adding it to my Home Assistant setup soon. Thanks again.

---

<div class="post-metadata">

**Author:** ![Mac](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mac](https://forums.pimoroni.com/u/Mac)\
**Post date:** [January 5, 2025, 5:43am UTC](https://forums.pimoroni.com/t/presto-weather-station/26964/6 "2025-01-05T05:43:13Z")

</div>

My final version before I work on more…

```auto
import time
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
from presto import Presto

PINS_BREAKOUT_GARDEN = {"sda": 40, "scl": 41}

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
bme = BreakoutBME68X(i2c, address=0x77)

# Setup for the Presto display
presto = Presto(ambient_light=True)
display = presto.display
WIDTH, HEIGHT = display.get_bounds()

# Create some colours
BLUE = display.create_pen(20,0,255)
WHITE = display.create_pen(255, 255, 255)
RED = display.create_pen(255,0,0)
ORANGE = display.create_pen(245, 165, 4)
GREEN = display.create_pen(0,255,0)
PINK = display.create_pen(250, 125, 180)
CYAN = display.create_pen(0,255,255)
MAGENTA = display.create_pen(255,0,255)
BLACK = display.create_pen(0, 0, 0)
YELLOW = display.create_pen(255, 255, 0)

while True:

    # Clear the screen and use blue as the background colour
    display.set_pen(BLUE)
    display.clear()
    # Set the pen to a different colour otherwise we won't be able to see the text!
    display.set_pen(YELLOW)
    
     # read the sensors
    temperature, pressure, humidity, gas, status, _, _ = bme.read()
    # pressure comes in pascals which is a reight long number, lets convert it to the more manageable hPa
    pressurehpa = pressure / 100
    temperature = temperature * 9/5 + 32
    gas = gas / 1000
    
    display.set_font("bitmap8") # Change the font
    
                     
    # draw the text
    display.set_pen(ORANGE)
    display.text("temperature:", 10, 10, 240, 2)
    display.set_pen(YELLOW)
    display.text('{:.1f}'.format(temperature) + ' °F', 10, 30, 240, 3)
    
    # and the pressure text
    display.set_pen(ORANGE)
    display.text("pressure:", 10, 60, 240, 2)
    display.set_pen(YELLOW)
    display.text('{:.0f}'.format(pressurehpa) + ' hPA', 10, 80, 240, 3)
    
     # and the humidity text
    display.set_pen(ORANGE) 
    display.text("humidity:", 10, 110, 240, 2)
    display.set_pen(YELLOW)
    display.text('{:.0f}'.format(humidity) + ' %', 10, 130, 240, 3)
    
    display.set_pen(MAGENTA)
    display.text("Weather Station", 80, 210, 240, 1)
    display.text("Muddy Creek Customs", 70, 220, 240, 1)
    
    display.set_pen(ORANGE)
    display.text("gas:", 10, 160, 240,2)
    display.set_pen(RED)
    display.text('{:.0f}'.format(gas) + ' K ohms', 10, 180, 240, 3)

    # Finally we update the screen with our changes :)
    presto.update()

while True:
    reading = bme.read()
    print(reading)
    time.sleep(1.0)
    
 

    # Finally we update the screen with our changes :)
    presto.update()

```
