0

Errno19 after few minutes running
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Errno19 after few minutes running

by cw1812 on Tue Mar 30, 2021 10:24 am

I am happy to introduce my new IAQ device:

FeatherS2 (CircuitPython 6.2.0-beta.4)
Adafruit Grayscale 1.5" 128x128 OLED
Adafruit SCD-30 for CO2
Adafruit SGP30 for TVOC
Adafruit MS8607 for Temperture, RH & pressure
Adafruit PMAS300I for PM2.5

It looks fine at first but after few minutes run, sometimes few hours, error comes:

File "adafruit_scd30.py", line 183, in CO2
File "adafruit_scd30.py", line 234, in _read_data
File "adafruit_scd30.py", line 221, in _send_command
File "adafruit_scd30.py", line 221, in _send_command
OSError: [Errno 19] Unsupported operation


Any idea?

Here is my code:

Code: Select all | TOGGLE FULL SIZE
import time
import board

#Setup for 2nd LDO
import feathers2
feathers2.enable_LDO2(True)

#Setup for onboard LED
import adafruit_dotstar
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.05, auto_write=True)

i2c = board.I2C()

#Setup for OLED Display
import displayio
import terminalio
import adafruit_ssd1327
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font

displayio.release_displays()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3d)
display = adafruit_ssd1327.SSD1327(display_bus, width=128, height=128, auto_refresh=False, rotation=180)
#font = bitmap_font.load_font("/fonts/Helvetica-Bold-16.bdf")
font = terminalio.FONT
colour1 = 0xFFFFFF
colour2 = 0xBFBFBF
colour3 = 0xA3A3A3

#Define display_start
display_start = displayio.Group()
label_start1 = label.Label(font, text=" "*20, color=colour1, scale=1, x=0, y=3)
label_start1.text = "hello world!"
display_start.append(label_start1)
display.show(display_start)
display.refresh()
time.sleep(2)

#Define display_MS8607
display_ms = displayio.Group(x=0, y=0)
label_ms1 = label.Label(font, text="  ", color=colour2, scale=2, x=0, y=6) #display temperature
label_ms2 = label.Label(font, text="o", color=colour2, scale=1, x=54, y=2)
label_ms3 = label.Label(font, text="C", color=colour2, scale=2, x=60, y=6)
label_ms4 = label.Label(font, text="   ", color=colour2, scale=2, x=84, y=6) #display RH%
label_ms5 = label.Label(font, text="%", color=colour2, scale=2, x=111, y=6)
label_ms6 = label.Label(font, text="pressure:", color=colour2, scale=1, x=0, y=30)
label_ms7 = label.Label(font, text="    ", color=colour2, scale=1, x=60, y=30) #display pressure
label_ms8 = label.Label(font, text="hPa", color=colour2, scale=1, x=87, y=30)
display_ms.append(label_ms1)
display_ms.append(label_ms2)
display_ms.append(label_ms3)
display_ms.append(label_ms4)
display_ms.append(label_ms5)
display_ms.append(label_ms6)
display_ms.append(label_ms7)
display_ms.append(label_ms8)

#Define display_scd30
display_scd = displayio.Group(x=0, y=45)
label_scd1 = label.Label(font, text="C02:", color=colour2, scale=1, x=0, y=3)
label_scd2 = label.Label(font, text="    ", color=colour2, scale=1, x=0, y=15) #display CO2
label_scd3 = label.Label(font, text="ppm", color=colour2, scale=1, x=25, y=15)
display_scd.append(label_scd1)
display_scd.append(label_scd2)
display_scd.append(label_scd3)

#Define display_sgp30
display_sgp = displayio.Group(x=64, y=45)
label_sgp1 = label.Label(font, text="TVOC:", color=colour2, scale=1, x=0, y=3)
label_sgp2 = label.Label(font, text="    ", color=colour2, scale=1, x=0, y=15) #display TVOC
label_sgp3 = label.Label(font, text="ppb", color=colour2, scale=1, x=25, y=15)
display_sgp.append(label_sgp1)
display_sgp.append(label_sgp2)
display_sgp.append(label_sgp3)

#Define display_PMSA003I PM1.0
display_pm10 = displayio.Group(x=0, y=75)
label_pm101 = label.Label(font, text="PM1.0:", color=colour2, scale=1, x=0, y=3)
label_pm102 = label.Label(font, text="    ", color=colour2, scale=1, x=0, y=15) #display PM1.0
label_pm103 = label.Label(font, text="ug/m3", color=colour2, scale=1, x=25, y=15)
display_pm10.append(label_pm101)
display_pm10.append(label_pm102)
display_pm10.append(label_pm103)

#Define display_PMSA003I PM2.5
display_pm25 = displayio.Group(x=64, y=75)
label_pm251 = label.Label(font, text="PM2.5:", color=colour2, scale=1, x=0, y=3)
label_pm252 = label.Label(font, text="    ", color=colour2, scale=1, x=0, y=15) #display PM2.5
label_pm253 = label.Label(font, text="ug/m3", color=colour2, scale=1, x=25, y=15)
display_pm25.append(label_pm251)
display_pm25.append(label_pm252)
display_pm25.append(label_pm253)


#Define display_running
display_run = displayio.Group(x=0, y=0)
display_run.append(display_ms)
display_run.append(display_scd)
display_run.append(display_sgp)
display_run.append(display_pm10)
display_run.append(display_pm25)

#Setup for SCD30
import adafruit_scd30
scd = adafruit_scd30.SCD30(board.I2C())

#Setup for MS8607
from adafruit_ms8607 import MS8607
ms = MS8607(i2c)

#Setup for SGP30
import adafruit_sgp30
sgp = adafruit_sgp30.Adafruit_SGP30(i2c)

#Setup for PMSA003I
from adafruit_pm25.i2c import PM25_I2C
reset_pin = None
pmsa = PM25_I2C(i2c, reset_pin)

#Main Programme
while True:

    #Read MS8607
    TC_Cal = ms.temperature #Calibration
    label_ms1.text = str(round(TC_Cal,1))
    label_ms4.text = str(int(round(ms.relative_humidity,0)))
    label_ms7.text = str(int(round(ms.pressure,0)))
    print("Pressure: %.2f hPa" % ms.pressure)
    print("Temperature: %.2f C" % TC_Cal)
    print("Humidity: %.2f rH" % ms.relative_humidity)

    #Read SGP30
    label_sgp2.text = str(int(round(sgp.TVOC,0)))
    print("TVOC: %.2f ppb" % sgp.TVOC)

    #Read SCD30
    if scd.data_available :
        label_scd2.text = str(int(scd.CO2))
        print("CO2:", scd.CO2, "ppm")

    #Read PMSA003I
    try:
        aqdata = pmsa.read()
    except RuntimeError:
        feathers2.led_set(True)
        continue
    label_pm102.text = str(int(round(aqdata["pm10 standard"],0)))
    label_pm252.text = str(int(round(aqdata["pm25 standard"],0)))
    print("PM 1.0: %.2f" % aqdata["pm10 standard"])
    print("PM 2.5: %.2f" % aqdata["pm25 standard"])
    print("PM 10: %.2f" % aqdata["pm100 standard"])

    #Set onboard LED colour1
    if aqdata["pm25 standard"] <= 10 :
        dotstar[0] = (55, 255, 255)
    elif aqdata["pm25 standard"] <= 20 :
        dotstar[0] = (0, 0, 255)
    elif aqdata["pm25 standard"] <= 25 :
        dotstar[0] = (0, 255, 0)
    elif aqdata["pm25 standard"] <= 50 :
        dotstar[0] = (255, 255, 55)
    elif aqdata["pm25 standard"] <= 75 :
        dotstar[0] = (255, 0, 0)
    else :
        dotstar[0] = (255, 0, 255)

    display.show(display_run)
    display.refresh()
    time.sleep(10)

    pass

Attachments
IMG_7691.jpg
IAQ device
IMG_7691.jpg (400.58 KiB) Viewed 352 times

cw1812
 
Posts: 3
Joined: Sun Jun 24, 2018 9:40 am

Re: Errno19 after few minutes running

by cw1812 on Tue Mar 30, 2021 10:35 am

My guess is something on:

Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL, board.SDA)


which is difference to other code example:

Code: Select all | TOGGLE FULL SIZE
i2c = board.I2C()

cw1812
 
Posts: 3
Joined: Sun Jun 24, 2018 9:40 am

Re: Errno19 after few minutes running

by adafruit_support_carter on Wed Mar 31, 2021 12:28 pm

Nice sensor cluster! With that many items, it could be a simple intermittent hiccup on the I2C bus or something similar. Those two I2C setup code lines are equivalent, so that's not the issue.

Are you always hitting that same error message? It's always about the SCD-30 and an Errno 19?

adafruit_support_carter
 
Posts: 20286
Joined: Tue Nov 29, 2016 2:45 pm

Re: Errno19 after few minutes running

by cw1812 on Fri Apr 02, 2021 5:55 am

I am using the similar method discussed in https://github.com/adafruit/circuitpython/pull/4387 and problem solved

cw1812
 
Posts: 3
Joined: Sun Jun 24, 2018 9:40 am

Re: Errno19 after few minutes running

by kevinjwalters on Fri Apr 16, 2021 4:12 pm

Did you try this on any other boards? I'm curious about Feather nRF52840 Express as I'm using one of those now with the SCD30. It's working so far reading every 1.6 seconds. I'll leave it running overnight at a lower read rate to see what happens.

kevinjwalters
 
Posts: 959
Joined: Sun Oct 01, 2017 3:15 pm

Re: Errno19 after few minutes running

by kevinjwalters on Tue Apr 20, 2021 10:09 am

BTW the scd.data_available test is superfluous as it's already in the library code, plus you have a 10 second wait at end of the loop and the sensor produces a new value every 2 seconds by default.

Code: Select all | TOGGLE FULL SIZE
    #Read SCD30
    if scd.data_available :
        label_scd2.text = str(int(scd.CO2))
        print("CO2:", scd.CO2, "ppm")


It would be interesting if you still get the errors with the if removed.

kevinjwalters
 
Posts: 959
Joined: Sun Oct 01, 2017 3:15 pm

Re: Errno19 after few minutes running

by kevinjwalters on Wed Apr 21, 2021 8:49 am

I'm running similar code on a FeatherS2 running 6.2.0 with Pimoroni Enviro+ FeatherWing and SCD-30 connected with a 20cm cable. I've run this for a few hours and not seen any problems so far. I'll leave it running and see what happens with longer run times.

kevinjwalters
 
Posts: 959
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.