Reading from SHT4x humidity and temperature sensor

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Zokinko
Posts: 1
Joined: Wed Apr 06, 2022 12:37 pm

Reading from SHT4x humidity and temperature sensor

Post by Zokinko » Wed Apr 06, 2022 1:51 pm

Hello,
I am new to world of MicroPython, so I am sorry if it's something obvious, but I can't figure it out.
I have problem with reading from SHT4x sensor. It's connected through X9 and X10 as SoftI2C. It is connected with 3 other sensors on same interface. I can write commands but when I want to read, it shows "OSError: [Errno 19] ENODEV". scan() can see this device and writeinto() also sees it. When I use readinto() it reads all bytes as 0xff, but I want to read from specific address because there are more sensors on interface. I tried different pullup resistors(4.7k,3.3k,1.8k) and all do the same, but with 3.3k sometimes even writeinto() gets "OSError: [Errno 19] ENODEV"

Link to datasheet:https://download.mikroe.com/documents/d ... asheet.pdf

This is simplified version of code:

Code: Select all

SHT4x_ADDRESS = const(0x44)
SHT4X_MEASURE = bytearray('\xFD')  

sht4x_device = SoftI2C(scl = Pin('X9'), sda = Pin('X10'), freq = 400000)
scan = sht4x_device.scan()
print(scan)
print(sht4x_device)

sht4x_device.writeto(SHT4x_ADDRESS, SHT4X_MEASURE)
pyb.delay(10)
unit = sht4x_device.readfrom(SHT4x_ADDRESS, 6)

temp_data = unit[0:2]
temp_crc = unit[2]
humidity_data = unit[3:5]
humidity_crc = unit[5]
Prints in code return this:
[68, 108, 109]
SoftI2C(scl=B14, sda=B15, freq=500000)

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: Reading from SHT4x humidity and temperature sensor

Post by tepalia02 » Thu Apr 07, 2022 2:16 pm

Here is a discussion regarding this error 19 :viewtopic.php?t=1855

Post Reply