Code runs fine from Thonny, but not as main.py

I have a Pico 2 with two Display Pack V2.8’s. Also in use are various sensors.
RV3028
BME680
BME280
VEML6075
LTR-599
It’s a weather station build that displays the sensor info on the displays. Custom wired so I can use the two Display packs independently and simultaneously.

The following wall of code works fine when run from Thonny. Both displays display correctly. But it doesn’t run correctly when saved to the Pico as main.py. The second “R” right display doesn’t display anything. The file is running, I can see the time increment on the working “L” left display. But nothing ever shows on the right display. This did work on boot up with a Pico (RP2040), that was my original setup. I didn’t have all the sensors wired up then, just the BME680 for indoor info. Once I added the BME280 and light sensors, the RP2040 wasn’t up to the task. It just froze. I then swapped in the RP2350 and my code would run. All was good until i tried to run it stand alone from boot up.

# MicroPython feature/psram, pico2_rp2350 v0.0.5 on 2024-08-22; Raspberry Pi Pico with RP2350
# Display Left, Pico Display Pack v2.8
# Display Right, Pico Display Pack v2.8

import time
import pimoroni_bus
import picographics
import veml6075
#import breakout_icp10125

from machine import ADC, Pin
#from pimoroni import Button
#from pimoroni import RGBLED
from pimoroni_i2c import PimoroniI2C
from breakout_ltr559 import BreakoutLTR559
from breakout_bme280 import BreakoutBME280
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from breakout_rtc import BreakoutRTC
from machine import RTC

i2c = PimoroniI2C(sda=(0), scl=(1))
bme_out = BreakoutBME280(i2c, 0x76)
bme_in = BreakoutBME68X(i2c, 0x77)
ltr = BreakoutLTR559(i2c)
uv = veml6075.VEML6075(i2c)
connected = uv.initUV()
#icp10125 = breakout_icp10125.BreakoutICP10125(i2c)
RV3028 = BreakoutRTC(i2c)
rtc = BreakoutRTC(i2c)

if rtc.is_12_hour:
    rtc.set_24_hour()

from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, get_buffer_size, PEN_RGB332
buffer = bytearray(get_buffer_size(DISPLAY_PICO_DISPLAY_2, PEN_RGB332))

from pimoroni_bus import SPIBus
spibus_R = SPIBus(cs=17, dc=16, sck=18, mosi=19, bl=20)
spibus_L = SPIBus(cs=22, dc=16, sck=18, mosi=19, bl=21)

display_R = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, rotate=90, buffer = buffer, bus=spibus_R, pen_type=PEN_RGB332)
display_L = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, rotate=90, buffer = buffer, bus=spibus_L, pen_type=PEN_RGB332)

display_R.set_font("bitmap8")
display_L.set_font("bitmap8")

display_R.set_backlight(0.5)
display_L.set_backlight(0.5)

def colour(R,G,B): # Convert RGB888 to RGB332
    b = int(B/64)
    g = int(G/32)
    r = int(R/64)
    return b + g * 4 +r * 64

white = colour(224,224,224)
black = colour(0,0,0)
red = colour(255,0,0)
green = colour(0,255,0)
blue = colour(0,0,255)
yellow = colour(255,255,0)
orange = colour(255,140,0)
grey = colour(175,175,175)
violet = colour(255,0,255)
aqua = colour(255,0,255)


display_R.set_pen(black)
display_R.clear()
display_L.set_pen(black)
display_L.clear()
    
def describe_month(month):
    month = rtc.get_month()
    if month == 1:
        description = "Jan"
    elif month == 2:
        description = "Feb"  
    elif month == 3:
        description = "Mar"
    elif month == 4:
        description = "Apr"              
    elif month == 5:
        description = "May"              
    elif month == 6:
        description = "Jun"              
    elif month == 7:
        description = "Jul"              
    elif month == 8:
        description = "Aug"              
    elif month == 9:
        description = "Sep"
    elif month == 10:
        description = "Oct"             
    elif month == 11:
        description = "Nov"              
    elif month == 12:
        description = "Dec"            
    return description

def describe_date(date):
    date = rtc.get_date()
    if date == 1:
        description = "st"
    elif date == 2:
        description = "nd"     
    elif date == 3:
        description = "rd" 
    elif date == 21:
        description = "st"      
    elif date == 22:
        description = "nd"  
    elif date == 23:
        description = "rd"
    elif date == 31:
        description = "st"
    else:
        description = "th"
    return description

temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)
temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)
temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)

if rtc.read_periodic_update_interrupt_flag():
    rtc.clear_periodic_update_interrupt_flag()

if rtc.update_time():
    rtc_date = rtc.string_date()
    rtc_time = rtc.string_time()

while True:
    
    hour = rtc.get_hours()
    minute = rtc.get_minutes()
    month = rtc.get_month()
    date = rtc.get_date()        
        
    if rtc.read_periodic_update_interrupt_flag():
        rtc.clear_periodic_update_interrupt_flag()

        if rtc.update_time():
            rtc_date = rtc.string_date()
            rtc_time = rtc.string_time()

    display_L.set_pen(black)
    display_L.clear()
                
    display_L.set_pen(white)
    display_L.text(f"{describe_month(month)} {date}{describe_date(date)}",125,0,scale=3)
    
    if hour == 0:
        display_L.text(f"{12}:{minute:02} AM", 0, 0, scale=3)    
    elif 0 < hour < 10:
        display_L.text(f"{hour:1}:{minute:02} AM", 0, 0, scale=3)
    elif 10 <= hour < 12:
        display_L.text(f"{hour:2}:{minute:02} AM", 0, 0, scale=3)
    elif hour == 12:
        display_L.text(f"{hour:2}:{minute:02} PM", 0, 0, scale=3)    
    elif hour > 12:
        hour = hour - 12
        if hour < 10:
            display_L.text(f"{hour:1}:{minute:02} PM", 15, 0, scale=3)
        elif 10 <= hour < 12:
            display_L.text(f"{hour:2}:{minute:02} PM", 0, 0, scale=3)
        elif hour == 12:
            display_L.text(f"{hour:2}:{minute:02} AM", 0, 0, scale=3)
            
            
    temp_out, press_out, hum_out = bme_out.read()
    temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
    heater = "Stable" if status & STATUS_HEATER_STABLE else "Unstable"
    pressuremb = press_in / 100
                
    display_L.set_pen(aqua)
    display_L.text("Indoor", 10, 35, scale = 3)
    display_L.text("Outdoor", 125, 35, scale = 3)
            
    temp_in = round(temp_in)
        
    if temp_in < 0:
        display_L.set_pen(white)
    elif 0 <= temp_in < 12:
        display_L.set_pen(blue)
    elif 12 <= temp_in < 17:
        display_L.set_pen(yellow)
    elif 17 <= temp_in < 25:
        display_L.set_pen(green)
    elif 25 <= temp_in < 30:
        display_L.set_pen(orange)
    elif temp_in >= 30:
        display_L.set_pen(red)
            
    display_L.text('{:.0f}°C'.format(temp_in), 20, 70, scale = 4)
    
    
    temp_out = round(temp_out)
        
    if temp_out < 0:
        display_L.set_pen(white)
    elif 0 <= temp_out < 12:
        display_L.set_pen(blue)
    elif 12 <= temp_out < 17:
        display_L.set_pen(yellow)
    elif 17 <= temp_out < 25:
        display_L.set_pen(green)
    elif 25 <= temp_out < 30:
        display_L.set_pen(orange)
    elif temp_out >= 30:
        display_L.set_pen(red)
            
    display_L.text('{:.0f}°C'.format(temp_out), 140, 70, scale = 4)
    
    
    hum_in = round(hum_in)
        
    if hum_in < 30:
        display_L.set_pen(red)
    elif 30 <= hum_in < 61:
        display_L.set_pen(green)
    elif 61 <= hum_in < 81:
        display_L.set_pen(yellow)
    elif hum_in >= 81:
        display_L.set_pen(orange)
            
    display_L.text('{:.0f}%'.format(hum_in), 20, 115, scale = 4)
    
    
    hum_out = round(hum_out)
    
    if hum_out < 30:
        display_L.set_pen(red)
    elif 30 <= hum_out < 61:
        display_L.set_pen(green)
    elif 61 <= hum_out < 81:
        display_L.set_pen(yellow)
    elif hum_out >= 81:
        display_L.set_pen(orange)
            
    display_L.text('{:.0f}%'.format(hum_out), 140, 115, scale = 4)
    
    '''
    t, p, status = icp10125.measure(icp10125.NORMAL)
    if status == icp10125.STATUS_OK:
        icptemp = t
        icppress = p / 100
        #print('ICP Pressure {:05.2f}mb'.format(icppress))    
    '''
    pressuremb = round(pressuremb)
        
    if pressuremb < 982:
        display_L.set_pen(red)
        display_L.text('{:.0f}mb'.format(pressuremb), 60, 160, scale = 4)
        display_L.text("Very Low", 30, 205, scale = 4)
    elif 982 <= pressuremb < 1004:
        display_L.set_pen(yellow)
        display_L.text('{:.0f}mb'.format(pressuremb), 60, 160, scale = 4)
        display_L.text("Low", 80, 205, scale = 4)
    elif 1004 <= pressuremb < 1026:
        display_L.set_pen(green)
        display_L.text('{:.0f}mb'.format(pressuremb), 55, 160, scale = 4)
        display_L.text("Unsettled", 30, 205, scale = 4)
    elif 1026 <= pressuremb < 1048:
        display_L.set_pen(blue)
        display_L.text('{:.0f}mb'.format(pressuremb), 50, 160, scale = 4)
        display_L.text("High", 35, 205, scale = 4)
    elif pressuremb >= 1048:
        display_L.set_pen(orange)
        display_L.text('{:.0f}mb'.format(pressuremb), 50, 160, scale = 4)
        display_L.text("Very High", 20, 205, scale = 4)
    
    display_L.update()
    display_L.set_pen(black)
    display_L.clear()
    
    display_R.set_pen(black)
    display_R.clear()
    
    display_R.set_pen(white)
    display_R.text("Outside Light", 15, 0, scale = 3)
    display_R.text("Rain Fall", 40, 80, scale = 3)
    display_R.text("Wind", 65, 160, scale = 3)
  
    
    reading = ltr.get_reading()
    if reading is not None:
        light = reading[BreakoutLTR559.LUX]
        
        if light < 50:
            display_R.set_pen(grey)
            display_R.text("Dark", 20, 35, scale = 4)
        elif 50 <= light < 100:
            display_R.set_pen(orange)
            display_R.text("Dim", 40, 35, scale = 4)
        elif 100 <= light < 500:
            display_R.set_pen(yellow)
            display_R.text("Light", 0, 35, scale = 4)
        elif light >= 500:
            display_R.set_pen(blue)
            display_R.text("Bright", 0, 35, scale = 4)
            
        
    UVI, UVIA, UVIB = uv.readUV()
    u = UVI    
        
    if UVI >= 0 and UVI < 3:
        display_R.set_pen(green)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)
    elif UVI >= 3 and UVI < 6:
        display_R.set_pen(yellow)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)        
    elif UVI >= 6 and UVI < 8:
        display_R.set_pen(orange)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)        
    elif UVI >= 8 and UVI < 11:
        display_R.set_pen(red)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4) 
    elif UVI >= 11:
        display_R.set_pen(violet)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)
          
    display_R.set_pen(green)
    display_R.text("10" + 'mm', 0, 115, scale = 4)
    display_R.text("2" + 'mm/h', 110, 115, scale = 4)
  
    display_R.set_pen(green)
    display_R.text("NE @", 0, 195, scale = 4)
    display_R.text("22 kmh", 110, 195 , scale = 4)
    display_R.text("Gusting 25", 20, 240, scale = 4)
    
    display_R.update()
    
    display_R.set_pen(black)
    display_R.clear()

    time.sleep(1.0)
    

I would try adding external pullups to the CS lines of both displays (10K should be fine). I had this sort of problem with multiple devices on the same SPI-bus in the past and adding pullups solved it.

Floating pins lead to all sorts of strange behavior, so this might not really be related to the difference you see.

1 Like

I may try that. This issue only showed after swapping in a Pico 2. I’ve been tinkering with this setup off and on for a while now. Pico with two Display Packs, then Display Pack 2’s and now Display pack 2.8’s. The code posted below runs just fine on a Pico. All is fine until I un remark out the outside weather code. If I add that back in it just stops working. It puts all the info up on screen but the clock stops and nothing is updated.

# Pimoorni MicroPython, picow v1.20.3 on 2023-06-19; Raspberry Pi Pico W with RP2040
# Display Left, Pico display Pack 2.8
# Display Right, Pico display Pack 2.8

import time
import pimoroni_bus
import picographics

#import network
import veml6075

from machine import ADC, Pin
from pimoroni import Button
from pimoroni import RGBLED
from pimoroni_i2c import PimoroniI2C
from breakout_ltr559 import BreakoutLTR559
#from breakout_bme280 import BreakoutBME280
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from breakout_rtc import BreakoutRTC
from machine import RTC

i2c = PimoroniI2C(sda=(0), scl=(1))
#bme_out = BreakoutBME280(i2c, 0x76)
bme_in = BreakoutBME68X(i2c, 0x77)
ltr = BreakoutLTR559(i2c)
uv = veml6075.VEML6075(i2c)
connected = uv.initUV()
RV3028 = BreakoutRTC(i2c)
rtc = BreakoutRTC(i2c)

if rtc.is_12_hour:
    rtc.set_24_hour()

from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, get_buffer_size, PEN_RGB332
from pimoroni_bus import SPIBus

spibus_R = SPIBus(cs=17, dc=16, sck=18, mosi=19, bl=20)
spibus_L = SPIBus(cs=22, dc=16, sck=18, mosi=19, bl=21)
buffer = bytearray(get_buffer_size(DISPLAY_PICO_DISPLAY_2, PEN_RGB332))
display_R = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, rotate=90, buffer = buffer, bus=spibus_R, pen_type=PEN_RGB332)
display_L = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, rotate=90, buffer = buffer, bus=spibus_L, pen_type=PEN_RGB332)
display_R.set_backlight(1.0)
display_L.set_backlight(1.0)



def colour(R,G,B): # Convert RGB888 to RGB332
    b = int(B/64)
    g = int(G/32)
    r = int(R/64)
    return b + g * 4 +r * 64

white = colour(224,224,224)
black = colour(0,0,0)
red = colour(255,0,0)
green = colour(0,255,0)
blue = colour(0,0,255)
yellow = colour(255,255,0)
orange = colour(255,140,0)
grey = colour(175,175,175)
violet = colour(255,0,255)
aqua = colour(255,0,255)

display_R.set_font("bitmap8")
display_L.set_font("bitmap8")

display_R.set_pen(black)
display_R.clear()
display_L.set_pen(black)
display_L.clear()
    
def describe_month(month):
    month = rtc.get_month()
    if month == 1:
        description = "Jan"
    elif month == 2:
        description = "Feb"  
    elif month == 3:
        description = "Mar"
    elif month == 4:
        description = "Apr"              
    elif month == 5:
        description = "May"              
    elif month == 6:
        description = "Jun"              
    elif month == 7:
        description = "Jul"              
    elif month == 8:
        description = "Aug"              
    elif month == 9:
        description = "Sep"
    elif month == 10:
        description = "Oct"             
    elif month == 11:
        description = "Nov"              
    elif month == 12:
        description = "Dec"            
    return description

def describe_date(date):
    date = rtc.get_date()
    if date == 1:
        description = "st"
    elif date == 2:
        description = "nd"     
    elif date == 3:
        description = "rd" 
    elif date == 21:
        description = "st"      
    elif date == 22:
        description = "nd"  
    elif date == 23:
        description = "rd"
    elif date == 31:
        description = "st"
    else:
        description = "th"
    return description

start_time = time.time()

#temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)
#temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)
#temp_out, press_out, hum_out = bme_out.read()
temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
time.sleep(0.3)

if rtc.read_periodic_update_interrupt_flag():
    rtc.clear_periodic_update_interrupt_flag()

if rtc.update_time():
    rtc_date = rtc.string_date()
    rtc_time = rtc.string_time()

while True:
    
    time_elapsed = time.time() - start_time
    hour = rtc.get_hours()
    minute = rtc.get_minutes()
    month = rtc.get_month()
    date = rtc.get_date()        
        
    if rtc.read_periodic_update_interrupt_flag():
        rtc.clear_periodic_update_interrupt_flag()

        if rtc.update_time():
            rtc_date = rtc.string_date()
            rtc_time = rtc.string_time()
            
    display_L.set_pen(white)
    display_L.text(f"{describe_month(month)} {date}{describe_date(date)}",125,0,scale=3)
    
    if hour == 0:
        display_L.text(f"{12}:{minute:02} AM", 0, 0, scale=3)    
    elif 0 < hour < 10:
        display_L.text(f"{hour:1}:{minute:02} AM", 0, 0, scale=3)
    elif 10 <= hour < 12:
        display_L.text(f"{hour:2}:{minute:02} AM", 0, 0, scale=3)
    elif hour == 12:
        display_L.text(f"{hour:2}:{minute:02} PM", 0, 0, scale=3)    
    elif hour > 12:
        hour = hour - 12
        if hour < 10:
            display_L.text(f"{hour:1}:{minute:02} PM", 15, 0, scale=3)
        elif 10 <= hour < 12:
            display_L.text(f"{hour:2}:{minute:02} PM", 0, 0, scale=3)
        elif hour == 12:
            display_L.text(f"{hour:2}:{minute:02} AM", 0, 0, scale=3)
            
            
    #temp_out, press_out, hum_out = bme_out.read()
    temp_in, press_in, hum_in, gas, status, _, _ = bme_in.read()
    heater = "Stable" if status & STATUS_HEATER_STABLE else "Unstable"
    pressuremb = press_in / 100
                
    display_L.set_pen(aqua)
    display_L.text("Indoor", 10, 35, scale = 3)
    display_L.text("Outdoor", 125, 35, scale = 3)
            
    temp_in = round(temp_in)
        
    if temp_in < 0:
        display_L.set_pen(white)
    elif 0 <= temp_in < 12:
        display_L.set_pen(blue)
    elif 12 <= temp_in < 17:
        display_L.set_pen(yellow)
    elif 17 <= temp_in < 25:
        display_L.set_pen(green)
    elif 25 <= temp_in < 30:
        display_L.set_pen(orange)
    elif temp_in >= 30:
        display_L.set_pen(red)
    else:
        display_L.set_pen(black)
        
    display_L.text('{:.0f}°C'.format(temp_in), 20, 70, scale = 4)
    
    '''
    temp_out = round(temp_out)
        
    if temp_out < 0:
        display_L.set_pen(white)
    elif 0 <= temp_out < 12:
        display_L.set_pen(blue)
    elif 12 <= temp_out < 17:
        display_L.set_pen(yellow)
    elif 17 <= temp_out < 25:
        display_L.set_pen(green)
    elif 25 <= temp_out < 30:
        display_L.set_pen(orange)
    elif temp_out >= 30:
        display_L.set_pen(red)
    else:
        display_L.set_pen(black)
        
    display_L.text('{:.0f}°C'.format(temp_out), 140, 70, scale = 4)
    '''
    
    hum_in = round(hum_in)
        
    if hum_in < 30:
        display_L.set_pen(red)
    elif 30 <= hum_in < 61:
        display_L.set_pen(green)
    elif 61 <= hum_in < 81:
        display_L.set_pen(yellow)
    elif hum_in >= 81:
        display_L.set_pen(orange)
    else:
        display_L.set_pen(black)
        
    display_L.text('{:.0f}%'.format(hum_in), 20, 115, scale = 4)
    
    '''
    hum_out = round(hum_out)
    
    if hum_out < 30:
        display_L.set_pen(red)
    elif 30 <= hum_out < 61:
        display_L.set_pen(green)
    elif 61 <= hum_out < 81:
        display_L.set_pen(yellow)
    elif hum_out >= 81:
        display_L.set_pen(orange)
    else:
        display_L.set_pen(black)
        
    display_L.text('{:.0f}%'.format(hum_out), 140, 115, scale = 4)
    '''
    
    pressuremb = round(pressuremb)
        
    if pressuremb < 982:
        display_L.set_pen(red)
        display_L.text('{:.0f}mb'.format(pressuremb), 60, 160, scale = 4)
        display_L.text("Very Low", 30, 205, scale = 4)
    elif 982 <= pressuremb < 1004:
        display_L.set_pen(yellow)
        display_L.text('{:.0f}mb'.format(pressuremb), 60, 160, scale = 4)
        display_L.text("Low", 80, 205, scale = 4)
    elif 1004 <= pressuremb < 1026:
        display_L.set_pen(green)
        display_L.text('{:.0f}mb'.format(pressuremb), 55, 160, scale = 4)
        display_L.text("Unsettled", 30, 205, scale = 4)
    elif 1026 <= pressuremb < 1048:
        display_L.set_pen(blue)
        display_L.text('{:.0f}mb'.format(pressuremb), 50, 160, scale = 4)
        display_L.text("High", 35, 205, scale = 4)
    elif pressuremb >= 1048:
        display_L.set_pen(orange)
        display_L.text('{:.0f}mb'.format(pressuremb), 50, 160, scale = 4)
        display_L.text("Very High", 20, 205, scale = 4)
    else:
        display_L.set_pen(black)
        display_L.text('{:.0f}mb'.format(pressuremb), 50, 160, scale = 4)
        display_L.text("", 25, 205, scale = 4)    

    display_L.update()
    display_L.set_pen(black)
    display_L.clear()
        
    display_R.set_pen(white)
    display_R.text("Outside Light", 25, 0, scale = 3)
    display_R.text("Rain Fall", 45, 80, scale = 3)
    display_R.text("Wind", 70, 160, scale = 3)
  
    
    reading = ltr.get_reading()
    if reading is not None:
        light = reading[BreakoutLTR559.LUX]
        
        if light < 50:
            display_R.set_pen(grey)
            display_R.text("Dark", 20, 35, scale = 4)
        elif 50 <= light < 100:
            display_R.set_pen(orange)
            display_R.text("Dim", 40, 35, scale = 4)
        elif 100 <= light < 500:
            display_R.set_pen(yellow)
            display_R.text("Light", 0, 35, scale = 4)
        elif light >= 500:
            display_R.set_pen(blue)
            display_R.text("Bright", 0, 35, scale = 4)
            
        
    UVI, UVIA, UVIB = uv.readUV()
    u = UVI    
        
    if UVI >= 0 and UVI < 3:
        display_R.set_pen(green)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)
    elif UVI >= 3 and UVI < 6:
        display_R.set_pen(yellow)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)        
    elif UVI >= 6 and UVI < 8:
        display_R.set_pen(orange)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)        
    elif UVI >= 8 and UVI < 11:
        display_R.set_pen(red)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4) 
    elif UVI >= 11:
        display_R.set_pen(violet)
        display_R.text('UV:{:.0f}'.format(UVI), 145, 35, scale = 4)
          
    display_R.set_pen(green)
    display_R.text("10" + 'mm', 0, 115, scale = 4)
    display_R.text("2" + 'mm/h', 110, 115, scale = 4)
  
    display_R.set_pen(green)
    display_R.text("NE @", 0, 195, scale = 4)
    display_R.text("22 kmh", 110, 195 , scale = 4)
    display_R.text("Gusting 25", 20, 240, scale = 4)
    
    display_R.update()
    display_R.set_pen(black)
    display_R.clear()

    time.sleep(1.0)
    

The only other thing which is strange: why do you use a single framebuffer shared between both displays?

If I don’t I run out of memory. On a Pico anyway.
Trying to run dual independent displays on a Pi PICO - Support - Pimoroni Buccaneers
Pico Display Pack V2 x 2? · Issue #299 · pimoroni/pimoroni-pico (github.com)

I have some head scratching things going on here. Might be more than one issue.
Yesterday I remarked out the BME680 code and added back in the BME280 code. It ran for a minute or so and then locked up. So I unplugged the BME280 and did the following. The BME280 has been running fine all night hooked up to another Pico setup. And my Weather Station setup has been running all night with everything except that BME280 connected to it.
So, either I have an error in my code? Or the BME280 and 680 don’t play well together? I think I have another 680 here I can try instead.

Have you tried with two buffers on a Pico2? There should be plenty of RAM available now.

I would really start with the pullups. I checked the Pimoroni source-code: when you create the SPIBus-objects, the code just records the pins but does not pull cs high. Next you initialize your displays. Both are on the same SPI-bus. Now if cs=22 for the second bus is floating low, then the display_L will receive initialization command you meant only to send to display_R.

This might not be the only problem you have. But I don’t believe the theory that a BME280 and BME680 don’t play well together. Both are I2C devices and if their I2C address is different, than they don’t interfere.

What could be the case: you have many I2C breakouts on your bus, and every one of these breakouts brings their own I2C-pullups so the total pull is very strong (many pullups in parallel will lower the total resistance). So this could in fact disturb the I2C bus and a hanging I2C could cause the lockup you see.

So another thing to try is to use both I2C busses that the Pico provides.

1 Like

It’s on my list of things to do. I had thought about trying it.

@bablokb
I had all the breakouts plugged in, and just edited my code to use one or the other BME’s. I will do some more testing shortly. Both displays work fine on a Pico (RP2040) so I’ll stay with that for now. My plan is to move to a Pico 2. A Pico 2 W ultimately.

Ok, with a second BME680 replacing the BME280, my code runs fine. Ran it for half an hour from Thonny. Then saved it to the Pico as main.py and its been running for 20 minutes + with no lock ups. Some progress made. =)

Time to go find my stash or resistors and get the soldering iron heated up.

Could it maybe be the cs pin I used? Should I use GP 21 instead of 22?
And then use GP 22 for the backlight?

EDIT: Never mind, it’s the R right display that’s not working with the Pico 2.

@bablokb Adding the pullups to the cs pins seems to have fixed the one display not working issue. I just swapped in the Pico 2, uploaded my files and did a reset. All is good so far, both displays are working and no lockups. Will let it run for a while to see what happens. A big thank you for your help with this. =)

Glad it helped! (and some random characters because a post can’t be shorter than 20 chars)

1 Like

This is what I’m tinkering with. The Wind and Rain info is just text place holders for now. That info and the Outside weather info will come in over WIFI from a station outside. Right now it’s the bits stuck on top and connected via the QWICC cable. Power source and battery state will be displayed at the bottom of the LCD screens.


1 Like