Page 1 of 1

si7021 [RESOLVED]

Posted: Fri Aug 05, 2022 7:39 am
by iceelon
I have recently acquired the si7020 type sensor, and I encounter the following problem


Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 8, in <module>
  File "/lib/si7021.py", line 35, in temperature
  File "/lib/si7021.py", line 70, in _get_data
OSError: [Errno 5] EIO
I use the driver

Code: Select all

https://github.com/robert-hh/SI7021.git
detect ...

Code: Select all

Scan i2c bus...
i2c devices found: 2
Decimal address:  64  | Hexa address:  0x40        -> this
Decimal address:  72  | Hexa address:  0x48

Re: si7021

Posted: Fri Aug 05, 2022 9:46 am
by Roberthh
The default address used by the driver is 0x40. And I recently used that driver for a SI7021 device. According to the data sheets, the SI7020 and SI7021 have the same interface.
Since EIO indicates an communication error. please check the wiring:

- GND & Vcc connection.
- Presence of Pull-Up resistors
- I2C Address (is right at 0x40)
- Cables & breadboard

Do you have two devices attached to the I2C bus? If not, the second address must not show up.

Re: si7021

Posted: Fri Aug 05, 2022 10:07 am
by iceelon
thanks for the answer, if it is an lm75 together with the pull-up resistors

What really catches my attention is that when I ask for the humidity parameter it shows it to me instead when I ask for the temperature parameter it gives me that error

Re: si7021

Posted: Fri Aug 05, 2022 10:31 am
by Roberthh
So the communication part is fine. You could try SofI12C instead of HardI2C. Sometimes that work better.

Re: si7021

Posted: Fri Aug 05, 2022 11:26 am
by iceelon
ummm code ;

Code: Select all

Serial:              30147226694142036
Identifier:          unknown
Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
  File "/lib/si7021.py", line 35, in temperature
  File "/lib/si7021.py", line 70, in _get_data
OSError: [Errno 19] ENODEV
this source

Code: Select all


from machine import Pin, SoftI2C
from si7021 import Si7021
i2c = SoftI2C(scl=machine.Pin(17), sda=machine.Pin(16) ,freq=100_000)
temp_sensor = Si7021(i2c)
print('Serial:              {value}'.format(value=temp_sensor.serial))
print('Identifier:          {value}'.format(value=temp_sensor.identifier))
print('Temperature:         {value}'.format(value=temp_sensor.temperature))
print('Relative Humidity:   {value}'.format(value=temp_sensor.relative_humidity))

temp_sensor.reset()
print('\nModule reset.\n')

print('Temperature:         {value}'.format(value=temp_sensor.temperature))
print('Relative Humidity:   {value}'.format(value=temp_sensor.relative_humidity))

print('Fahrenheit:          {value}'.format(value=si7021.convert_celcius_to_fahrenheit(temp_sensor.temperature)))
and lib

Code: Select all

https://github.com/chrisbalmer/micropython-si7021/raw/master/si7021.py

Re: si7021

Posted: Fri Aug 05, 2022 12:19 pm
by Roberthh
Hm. Read temperature uses the command 0xF3. You could try 0xE3, which uses clock stretching if the device is not yet ready.

Re: si7021

Posted: Fri Aug 05, 2022 12:43 pm
by Roberthh
I tried again with a Pico and both variants of the script here: https://github.com/robert-hh/SI7021
Using a Adafruit SI7021 sensor. Works fine.

Re: si7021

Posted: Fri Aug 05, 2022 1:06 pm
by iceelon
works !!!! Thanks a lot !!!!