Skip to content
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

I2C issue while reading from HTU21DF #399

Closed
hmms opened this issue Nov 4, 2015 · 16 comments
Closed

I2C issue while reading from HTU21DF #399

hmms opened this issue Nov 4, 2015 · 16 comments

Comments

@hmms
Copy link

hmms commented Nov 4, 2015

i was trying to read the HTU21DF using the Adafruit library (https://github.com/adafruit/Adafruit_HTU21DF_Library) the 'begin' function works and the chip is detected, but the data requested using the Wire.requestFrom() doesnt seem to work and returns zero bytes, also Wire.Available() doesn't seem to work and returns zero. are there any work arounds? I would be glad to contribute to help solve this issue, pointers appreciated!

@avr39-ripe
Copy link
Contributor

I think I2C bug WAS resolved by this commit eb95d30

What version of Sming do you use? Try to update to latest release. If issue remains - feel free to ask for help here!

@comino
Copy link

comino commented Nov 4, 2015

I have the same issue with a BMP180 - returns only zeros.

@flexiti
Copy link
Contributor

flexiti commented Nov 4, 2015

BMP 180 works ok on Esp12 end esp01 , I am using develop version of Sming (2 weeks old).

@hmms
Copy link
Author

hmms commented Nov 4, 2015

@avr39-ripe I think i am using an older build as you suspected, I will give it a try tonight with eb95d30 and will let you know of the results.

@hmms
Copy link
Author

hmms commented Nov 5, 2015

I tried with the latest build( afe5393 ) Issue still persists. I dont have a DSO or a scope to see exactly whats going on but a friend of mine has a Logic analyzer will borrow that and check what might be going wrong. Thanks again for the help :)

@avr39-ripe
Copy link
Contributor

One more thought: may be you use wrong I2C pins? Are you sure, that you connect your device to right pins? Try to specify pins directly before Wire.begin() in init() syntax is void pins(int pinSCL, int pinSDA); // Can be called only before begin():

        Wire.pins(0, 2);
        Wire.begin();

@comino
Copy link

comino commented Nov 5, 2015

I also still have the problem. BMP180 works with Arduino dode. Smite BMP180 example with newest version is not working. Im using the correct pins, also tried "Wire.pins(0,2)" and a lot of other stuff. I dont get whats wrong. I only get zeros what-ever I do.

Increased the delay between pulling up the lines and starting the transmisson. No difference.

@avr39-ripe
Copy link
Contributor

@comino by "Arduino code" you mean real AVR-based arduino+its code, or esp8266-based Arduino software platform?
Still can't understand, why you have problems. I use Sming + DS3231 RTC and Sming + I2C based LCD (via PCF8574 port expander) without any problems.

@flexiti
Copy link
Contributor

flexiti commented Nov 5, 2015

@comino

Try:

    BMP180 barometer;
Wire.pins(0,2);  // I am using (12,13)
Wire.begin();
if(!barometer.EnsureConnected())
    Serial.println("Could not connect to BMP180.");
    barometer.Initialize();
long currentPressure = barometer.GetPressure();

Serial.print("Pressure: ");
Serial.print(currentPressure);
Serial.print(" Pa");     

Maybe You switched ports ?? 0 <-> 2
Some board BMP180 require a 5V power supply (they have their own power supply 3v3), Have you checked yours?

@comino
Copy link

comino commented Nov 5, 2015

ESP8266 WROOM-2 + Arduino + same board its working. Checked several times if BMP still works on adurino - works perfect. So the hardware should be fine. Tried what you menitoned @flexiti but still no success. But since its working for you guys, the problem must either be on my computer or sitting in front of it and not in Sming ;).Im just armed myself with a oscilloscope. If I find the error and its relevant for the community I will share. Thanks for your support.

@wal-stefan
Copy link

Here is my complete initialization sequence. Maybe, not everything is needed, but it is working fine for me. I am using the default pins. In this case, remember to remove the "flash enable" jumper after flashing - at least on ESP-12 it shares the SCL pin of he I2C-bus.

BMP180 barometer;

void initBarometer()
{
  Wire.begin();
  if(!barometer.EnsureConnected()) {
    LOG("Could not connect to BMP180");
    return;
  }

  LOG("Connected to BMP180");
  barometer.SoftReset();
  barometer.Initialize();
  barometer.PrintCalibrationData();
}

@hmms
Copy link
Author

hmms commented Nov 9, 2015

I got the logic analyzer and here's the results, the sensor works fine, the screen grab shows the "read temperate" command(0x40, the chip I2C ID followed by 0xE3) being sent out. the adafruit library works fine with the uno, but when i try it with Sming it fails to read data from the HTU21DF sensor. could it be something with the SCL line?
image

@tprochazka
Copy link

I personally think that grab the SPI and I2C implementation from the Arduino ESP8266 project would be best way how to fix a lot of issues in quite small time, they will fix issues instead of us. Arduiono ESP8266 project has much more programmers on the project. But I personally like network API on Sming much more, so I hope that Sming doesn't die.

@hmms
Copy link
Author

hmms commented Nov 25, 2015

@comino I tried the BMP180, and it seems to work, the issue might be in the HTU21DF Adafruit library(i suspect the delay and timing function maybe), The HTU21DF works fine with Arduino for the ESP8266, just not with sming.

@alonewolfx2
Copy link
Member

Bmp180 example working fine for me but I can't read data from attiny85 on i2cbus too.

@hreintke
Copy link
Contributor

closed due to low activity

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

8 participants