si7021 [RESOLVED]

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
iceelon
Posts: 21
Joined: Tue Jul 12, 2022 11:42 am

si7021 [RESOLVED]

Post by iceelon » Fri Aug 05, 2022 7:39 am

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
Last edited by iceelon on Fri Aug 05, 2022 1:37 pm, edited 1 time in total.

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

Re: si7021

Post by Roberthh » Fri Aug 05, 2022 9:46 am

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.

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

Re: si7021

Post by iceelon » Fri Aug 05, 2022 10:07 am

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

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

Re: si7021

Post by Roberthh » Fri Aug 05, 2022 10:31 am

So the communication part is fine. You could try SofI12C instead of HardI2C. Sometimes that work better.

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

Re: si7021

Post by iceelon » Fri Aug 05, 2022 11:26 am

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

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

Re: si7021

Post by Roberthh » Fri Aug 05, 2022 12:19 pm

Hm. Read temperature uses the command 0xF3. You could try 0xE3, which uses clock stretching if the device is not yet ready.

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

Re: si7021

Post by Roberthh » Fri Aug 05, 2022 12:43 pm

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.

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

Re: si7021

Post by iceelon » Fri Aug 05, 2022 1:06 pm

works !!!! Thanks a lot !!!!

Post Reply