ENV III Causes CoreS3 to restart.



  • @M5Stack @IAMLIUBO 0_1685261428869_Screenshot 2023-05-28 at 09.10.07.png

    The shown examples causes the Core S3 to restart every time its "Run" from UIFLow2



  • @ajb2k3 I don't have an ENV III but no problem with the ENV II

    0_1685275056061_ENVII-CoresS3.jpg



  • Hello @ajb2k3

    have you tied with the Init buit-in hardware at beginning block a the top of setup? (Or without it?)

    Thanks
    Felix



  • @felmue said in ENV III Causes CoreS3 to restart.:

    Hello @ajb2k3

    have you tied with the Init buit-in hardware at beginning block a the top of setup? (Or without it?)

    Thanks
    Felix

    That's strange, why did the block end up at the bottom.
    That would make sense it being at the top.

    EDIT: nope still crashes when querying the sensor.



  • Anybody got this working?

    I am facing the same issue.

    I tried to use Port B instead or port A, but the behavior is exactly the same: the device reboots when init is invoked...



  • I have exactly the same issue. The ENV call from the unit library to initialise it causes the reboot:

    env3_0 = ENV(i2c=i2c0, type=3)

    I can remove that, then do a scan on i2c0 and fetch the addresses of the sensors: [68, 112]

    I can then interface with I2C directly to read from the correct address and pull data from the buffer. That proves the ENV3 is connected correctly and that I2C isn't broken.

    It looks like a library issue for ENV3 I guess?

    I've also tried sending a command on I2C to the sensor to initiate a temperature measurement (writing 0x2C06) however I must be doing something wrong there as it then fails to allow me to read from the device any more and I have to hard reset it before I can continue.



  • I’ve reported it to M5STACK and they are looking into it



  • A workaround is to use Core or Core2 with Env III and UI Flow
    No problem



  • @ajb2k3 Ok thanks.

    FYI and anyone else that would like to get the ENV III data on CoreS3, I managed to get it working using I2C directly.

    Here is the code to go in your loop assuming I2C has been initialised as the default i2c0 variable:

    i2c0.writeto(68, '\x2C\x06', True)
    time.sleep_ms(100)
    data = i2c0.readfrom(68, 6, True)

    temp = (((data[0] << 8 | data[1]) * 175) / 0xFFFF) - 45
    hum = (((data[3] << 8 | data[4]) * 100.0) / 0xFFFF)

    I then output this Temperature (C) and Humidity (%) formatted using (assuming you've initialised label fields already):

    label_t.setText(f'{temp:#.1f}C ')
    label_h.setText(f'{hum:#.0f}%')



  • @ajb2k3

    When I add the ENVIII unit to my CoreS3 on port A, and start it, I get the exception at line 98 of qmp6988.py (the call of reset() )

    0_1694933407426_718d4a1d-c795-4781-a6c1-f91479da1434-image.png

    The issue seems to have been noticed and fixed 8 months ago though, by some guy named Gandro:

    https://github.com/gandro/micropython-m5stamp-c3u/commit/fe3ddc3d0c09cca4096dcfc37bbbf57e7b4a1271

    It was (seemingly) caused by the QMP6988 chip in the ENVIII resetting in the middle of an I2c transaction during a requested reset (from line 97 of drivers/qmp6988.py), and the driver file not handling the timeout exception causing the exception/crash.

    0_1694932494144_919af751-40ab-4af5-9fce-7e3ce72bbbf8-image.png

    The fix was to just put a try/except around the transaction in reset(), and if the timeout is generated, ignore/handle it.

    0_1694932524877_9855c7fb-ab8f-4ddf-a6d9-ff1c01d040f8-image.png

    I found this with 5 minutes of googling. Not sure why M5Stack hasnt fixed it yet for all products that use the QMP6988



  • @mtylerjr I am not so sure about that...

    Even with that change, the module will reset at this line...

    What works for me is to bypass the reset(), after that I get correct temperature/pressure; but once you reset, the next readfrom_mem() will reset the MCU



  • @amedee I think you are right. I think that fix has already been pushed, and the exception is on the readfrom_mem() now, like you say.

    It seems like the same approach would work for that line as well.



  • If you are desperate to get it running, I have forked the micropython-m5stamp-c3u library and removed the QMP6988 reset().

    Unfortunately I have not found a way to override the built-in libraries, so it needs some code blocks in UiFlow...

    First install the libraries:

    import mip
    mip.install("https://raw.githubusercontent.com/AmedeeBulle/micropython-m5stamp-c3u/main/lib/sht30.py", target="/flash/libs")
    mip.install("https://raw.githubusercontent.com/AmedeeBulle/micropython-m5stamp-c3u/main/lib/checksum.py", target="/flash/libs")
    mip.install("https://raw.githubusercontent.com/AmedeeBulle/micropython-m5stamp-c3u/main/lib/qmp6988.py", target="/flash/libs")
    

    Once done you can query both sensors -- e.g:

    0_1695141051212_Screenshot 2023-09-19 at 18.24.06.png

    There are basically 3 code blocks:

    Import libraries:

    import sht30
    import qmp6988
    

    Initialize sensors:

    sht = sht30.SHT30(i2c0)
    qmp = qmp6988.QMP6988(i2c0)
    

    Get data:

    temperature, pressure = qmp.measure()
    pressure = pressure / 100
    temperature2, humidity = sht.measure()
    

    Note that in the above example, my ENV-III is plugged in the Port B, if you use Port A, adjust SCL/SDA accordingly!