Pico W Micro Python for SHT30 Temp/Humidity HELP!

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Roberthh » Wed Aug 17, 2022 8:28 am

###Check if shield is connected

###Read sensor status

#The status register can be cleared with

###Reset the sensor
These should work, as they just use the existing I2C exchange method. The only thing I could verify without a SHT30 was:
"Check if shield is connected".

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Rissy » Wed Aug 17, 2022 9:15 am

Roberthh wrote:
Wed Aug 17, 2022 8:28 am
###Check if shield is connected

###Read sensor status

#The status register can be cleared with

###Reset the sensor
These should work, as they just use the existing I2C exchange method. The only thing I could verify without a SHT30 was:
"Check if shield is connected".
Oh right. They didn't work when we were (i see we, but really mean YOU :lol: ) working on this at the weekend. I'll unhash each section tonight one at a time and double check back here with the results in each case for better clarity.

iceelon
Posts: 30
Joined: Tue Jul 12, 2022 11:42 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by iceelon » Wed Aug 17, 2022 10:05 am

Perhaps it is not relevant, but I have found on several boards sensors marked as sht30 mounted gxht30 or gxht3L verify that they are compatible with the sht30 drivers....

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Roberthh » Wed Aug 17, 2022 11:59 am

As far as I could guess from the chinese Data sheet, the gxht30 seems compatible to the SHT30. if you have that sensor, just give it a try.

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Rissy » Wed Aug 17, 2022 1:00 pm

Oh, I wasn't even aware that there was cheap copies out there. I bought this sensor from what appears to be quite a reputable vendor (The PiHut), and they advertised it as being a SHT30 (SHT-30D to be precise) temperature/humidity sensor.

https://thepihut.com/collections/temper ... ity-sensor

So i'm expecting mine to be the "real deal" rather than a chinese imitation. :!: :!: :|

iceelon
Posts: 30
Joined: Tue Jul 12, 2022 11:42 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by iceelon » Fri Aug 19, 2022 9:36 am

both tested, they work with the sht3x class when i2c hard is read at 12-13 cyclic measurements (1 second intervals) it shows that there is no sensor, but with soft there is no such problem

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Rissy » Mon Nov 07, 2022 9:33 am

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

Code: Select all

from sht30 import SHT30
with

Code: Select all

from sht30 import SHT30Error
, 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

Code: Select all

print("SHT30 Error: "+ex+", ")
(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?

jahr
Posts: 11
Joined: Fri Apr 02, 2021 1:20 pm

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by jahr » Tue Nov 08, 2022 8:10 am

Hello Rissy, remove (or comment out) all lines

Code: Select all

self.i2c.start()
and

Code: Select all

self.i2c.stop()
from the library. You may also clean up semicolons at end of lines ;-)

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Rissy » Tue Nov 08, 2022 8:28 am

jahr wrote:
Tue Nov 08, 2022 8:10 am
Hello Rissy, remove (or comment out) all lines

Code: Select all

self.i2c.start()
and

Code: Select all

self.i2c.stop()
from the library. You may also clean up semicolons at end of lines ;-)
Oh, hi jahr,

Thanks!

I see one instances of "self.i2c.start();" and two instances of "self.i2c.stop();", both within "def send_cmd".

I didn't see the semicolons ";" at all, but of course I wasn't looking for errors when trying to understand how it works.

What do I replace these lines with? What do they actually do (presumably even if they had the normal colon ":" at the end instead of a semicolon ";")

I'm still not very good at understanding "self" stuff in Python yet. Even after watching umpteen videos on the matter.

There's actually 14 instances of ";" throughout this library file. Are they all wrong? I've never seen ";" being used before, and I've never used it in any of my own code....!!?

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W Micro Python for SHT30 Temp/Humidity HELP!

Post by Rissy » Tue Nov 08, 2022 8:34 am

Now i'm looking for errors!

Is line 70 correct?

Code: Select all

 crc ^= b;
. I read that "^" is a bitwise operator, but with the "=" is this correct? What does that all mean if it is correct?

Post Reply