Hey all,
I've been a bit quiet lately, but i've never stopped doing my project work. I've been honing my coding some what, and admit i think I'm getting better at it.
I'm still suffering a seemingly wet weather issue with my Pico and SHT-30 sensor discussed throughout this thread. As a reminder, This is the library code i'm using:
https://github.com/rsc1975/micropython- ... r/sht30.py
On this parent page with examples of who to use this, I'm having trouble with the sensor soft reset functionality.
https://github.com/rsc1975/micropython-sht30
Code: Select all
from sht30 import SHT30
sensor = SHT30()
sensor.reset()
This throws up an error and i'm not sure how to fix it. It doesn't reset the sensor.
I had a similar issue with the exception code too. It tells you:
Code: Select all
from sht30 import SHT30
sensor = SHT30()
try:
t, h = sensor.measure()
except SHT30Error as ex:
print('Error:', ex)
But I found this didn't work either. I hade to replace
with
, then it worked. However, I can't seem to get my code to print the error to a .txt log file.
I've got it printing a general part of the error message to the .txt file depending on what part of the code it fails on (different try-except parts of my code generate a unique string message to log to the .txt file), and this has proven to me that my error which causes my code to crash is an SHT30 read error. I just don't know which one of the three potentials it is, although I suspect it's a bus error. I can successfully print the SHT30Error (ex) to the screen in Thonny no problem, but it wont go to a .txt file even though i've said
(it only prints "SHT30 Error: " to the .txt file so i never get to see the actual message "ex" causing it to fail unless my laptop is connected, which of course, it isn't (I forced an error to test it by changing the slave id designation of the sensor i'm trying to read. i.e 67 instead of the correct 68)
I wanted to try doing the sensor reset on the occurrence of an SHT30 message read failure, and this is what's prompted me to discover I want may that work. Instead, I've employed the built in watchdog timer function, but it's quite a nasty situation to get back into your code in Thonny once that's running. Lucky for me i had a copy of my code on my laptop because the only way i've found of getting back access to my Pico is to VERY VERY quickly delete main.py upon rebooting the Pico! Nasty!
Can anyone help me with these things?