ENV III Causes CoreS3 to restart.
-
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}%') -
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() )
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.
The fix was to just put a try/except around the transaction in reset(), and if the timeout is generated, ignore/handle it.
I found this with 5 minutes of googling. Not sure why M5Stack hasnt fixed it yet for all products that use the QMP6988
-
-
@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:
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!
-
I have the same issue with the env III unit and m5paper.
I do not have the time and energy to start patching libraries and modules.
The built in SHT30 of the m5paper is not supported by UIFlow 2 and the external unit does not work as well.
This is a bummer.
Hoping m5stack will fix this and update the module/library.
Is there any issue tracker where we can document and queue this for fixing? -
@romor001
Have you update your UiFlow firmware to the newest version?