Skip to content

I2C not communicating with slave device #11

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
bbx10 opened this issue Oct 8, 2016 · 16 comments
Closed

I2C not communicating with slave device #11

bbx10 opened this issue Oct 8, 2016 · 16 comments

Comments

@bbx10
Copy link
Contributor

bbx10 commented Oct 8, 2016

I tried an HTU21DF (temperature and humidity) and a BMP180 (barometric pressure) but the drivers do not get past the first I2C transmission. Both sensors work on an ESP8266.

The first thing the HTU21DF driver does is send a RESET command like this. Writing to this register forces the sensor to factory defaults.

  Wire.beginTransmission(HTU21DF_I2CADDR);  // addr 0x40
  Wire.write(HTU21DF_RESET);                // 0xFE
  Wire.endTransmission();

This is what it looks like on an Uno.

uno_htu21df_small

Here is what happens on my ESP32. If other people have I2C working, the problem must be in my setup or ESP32.

esp32_htu21df_small

Since there is a NAK, the driver aborts the rest of the transmission.

I am trying various changes to esp32-hal-i2c.c but have not made any progress.

@me-no-dev
Copy link
Member

I have HTU21 here, no clue if it's DF though... will try the code above, but please share the rest of it so I can test both sensors here.

@me-no-dev
Copy link
Member

I'm looking deeper into it and can see other issues also
I have it working as is with TPM102 temp sensor and SSD1306 oled, but if I run scan... things go to hell because transmissions happen without delay in between

@me-no-dev
Copy link
Member

I fixed much of the code (not pushed yet) but what I see with my SHT21 is that it can not pull SDA enough to register the ACK

pic_105_1

@me-no-dev
Copy link
Member

I've done what I can in my latest commit. From all of the devices that I tested, only that device and AM2320 do not respond. I tested IMUs, barometers, oled and 1602 screens, RTC and some more. All showed in scan.

@comcat
Copy link

comcat commented Oct 9, 2016

My testing result:

BMP085, BMP180, SSD1306 OLED can be found by scanning i2c
SHT20, TSL2561, PCF8563 can not be found

@me-no-dev
Copy link
Member

please try the latest commit! it should be all good now :)

@sorscode
Copy link
Contributor

I'm unable to find my PCF8563, but was able to find some old DS1307, even though it gave me a weird reading, and printed out it found a dozen devices when I was searching for the DS1307. I'm going to test other i2c devices this evening.

@ladyada
Copy link
Contributor

ladyada commented Nov 22, 2016

testing today:
SSD1306, PCF8523, HT16K33, HDC100x, SHT31-D works
but others like PCA9685, DS3231, Si7021, BMP280 and TCS34725 are not seeming to work with drivers for classic arduino/esp8266

the sensors have 10K pullups on SDA/SCL

@me-no-dev
Copy link
Member

this get's more and more interesting :D
@ladyada from the ones you listed as non-working I have only the DS and I'll give it a go, but is there any way that you can give some more info on what is failing?
Is it not getting ACK? Does the transmission fail in the middle? Can you look at a scope/logic analyser and tell what is going wrong?

@ladyada
Copy link
Contributor

ladyada commented Nov 23, 2016

yeah i will bring home a salae logic over the holiday and see if i can see what is up

me-no-dev added a commit that referenced this issue Dec 9, 2016
wait for data to be latched and increase timeout in attempt to fix clock stretch issues
Connected issues:
http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801
#81
#53
#11
@me-no-dev
Copy link
Member

try the latest commit please :)

@me-no-dev
Copy link
Member

@ladyada is there any way that you can prepare a pack of the most used i2c/spi devices/sensors that I can purchase from you? Having the most common devices to test could greatly help to improve libraries. I have PayPal that I can use to pay.

@me-no-dev
Copy link
Member

many many things have been fixed in I2C. I'm closing this issue now, if someone still has problems, feel free to reopen

@ladyada
Copy link
Contributor

ladyada commented Mar 19, 2017

oof apologies i didnt see your reply - i did just retest with a wide variety of i2c sensors and all are working now. once i have more than one ESP32 feather ill get you a kit!

@me-no-dev
Copy link
Member

Thanks :) That would be great!

@sansillusion
Copy link

Can anyone give me some instruction on using a DS3231 with a nodeMCU-32S (pins and library to use) ?
I tried many things but nothing seems to work.

Lzw655 pushed a commit to Lzw655/arduino-esp32 that referenced this issue Oct 12, 2023
Add missing '!' to shebang line in some bash scripts
blue-2357 pushed a commit to blue-2357/arduino-esp32 that referenced this issue Jul 17, 2024
wait for data to be latched and increase timeout in attempt to fix clock stretch issues
Connected issues:
http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801
espressif/arduino-esp32#81
espressif/arduino-esp32#53
espressif/arduino-esp32#11
dash0820 added a commit to dash0820/arduino-esp32-stripped that referenced this issue Mar 10, 2025
wait for data to be latched and increase timeout in attempt to fix clock stretch issues
Connected issues:
http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801
espressif/arduino-esp32#81
espressif/arduino-esp32#53
espressif/arduino-esp32#11
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

6 participants