Skip to content

SHT21 I2C unable to read #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kyjak opened this issue Jun 24, 2017 · 11 comments
Closed

SHT21 I2C unable to read #464

kyjak opened this issue Jun 24, 2017 · 11 comments

Comments

@kyjak
Copy link

kyjak commented Jun 24, 2017

I'm trying to get to work the Sensirion SHT21 I2C sensor on ESP32 without luck.
Using pins 21,22 as wire interface.
I tried all libraries I could find for SHT2x.
On arduino uno the code works, ESP does not.
It reads wrong sensor data = bogus.
It might be connected to the hal i2c library of esp32.
Do not have oscilloscope to show log :(

@architmuchhal12
Copy link

I am having the same issue #462 with the ADXL345 sensor. Works well with ESP8266 but fails to initialize I2C with ESP32.

@kyjak
Copy link
Author

kyjak commented Jun 26, 2017

I did solve it partially by using this library https://github.com/markbeee/SHT21/tree/master/examples/SHT21_Demo
however, that does not answer, why we cannot use ANY library, I still see an I2C issue with esp's.
Something is wrong probably with the timings.

@me-no-dev
Copy link
Member

It's not timings, it's something with the slaves themselves. ESP32's I2C bus is way more complex than the one found in AVR arduinos, so something somewhere is going wrong ;)
So I tested with 8 slaves on the I2C bus and all but one responded every time. That one was the SHT21.

@architmuchhal12
Copy link

I have switched to SPI communication for time being and it is working okay. I am using just one slave (ADXL345) and still, it does not respond.
So, is there a solution to counter ESP32's I2C @me-no-dev ?

@kyjak
Copy link
Author

kyjak commented Jun 26, 2017

Hmm, even if I have only 1 sensor, so it's not a slave?

@stonie08
Copy link

stonie08 commented Jul 20, 2017

Are you using the SHT21 in the "hold master mode"? I'm not using the arduino core, but on my ESP32 I get a correct reading from the SHT21 if I'm using the "no-hold-master" mode.
So for me the ESP32 ignores that the SHT21 is holding down the SCL line to force it into a wait state.

@stickbreaker
Copy link
Contributor

@kyjak @architmuchhal12 @stonie08 I have posted a fix for the I2C subsystem that may be at the root of your problems, See #839 .

@stonie08 The ESP32's I2C subsytem enforces a bit TIMEOUT, at maximum it is around 12ms or 2^20 cpu clocks @ 80mhz. How long is the hold period during this conversion? If it is anywhere near 5ms the ESP32 will react badly.

Chuck.

@kyjak
Copy link
Author

kyjak commented Nov 17, 2017 via email

@electroZ-microsystems
Copy link

Thank you stickbreaker, I installed you version of arduio-esp32 and I can read my SHT21, it was almost not working with espressif.

@stickbreaker
Copy link
Contributor

@manymany-many your welcome.

Chuck.

@copercini
Copy link
Contributor

The I2C core was changed to @stickbreaker code officially after 13dcfe5 (thanks @stickbreaker), Let's close issues with old code and if have problems with the new code, open new issues =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants