AverageGuy
Well-known member
I'm trying to get an I2C board working. It doesn't. Neither do two other boards. The LC doesn't see anything on the I2C bus. I'm using the following code to test:
The first board I tried was an HCU21D using a sample code from SparkFun. It printed 998 for temp and humidity. That said it wasn't working. So I tried the above code. It responded with:
printing the "Unknow" line for each address fro 0x01 to 0x7e. I don't English is the native tongue of the author of the code.
So I went off and grabbed a brand new gy21 p. Same result. A gy68 (bmp180) also doesn't work.
I have the devices connected as
Teensy LC pin 18 - Module SDA
pin 19 - Module SDC
pin 3V - Module VCC
pin GND - Module GND
I have two 4.7K pullups connected to the SDA and SDC pin from pin 3V.
To further complicate things, I also attempted to use both an ESP32 and ESP8266 to connect to the I2C devices with similar results.
I also removed the pullups
All parts were in their static shielded envelops before they were removed and tested.
I'm at a loss and thought this forum has some of the brightest folks I know, so here I am.
Any ideas?
Thanks,
Jim
Code:
/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com
*********/
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(115200);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address,HEX);
nDevices++;
}
else if (error==4) {
Serial.print("Unknow error at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address,HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
}
else {
Serial.println("done\n");
}
delay(5000);
}
Code:
canning...
Unknow error at address 0x01
Unknow error at address 0x02
Unknow error at address 0x03
...
Unknow error at address 0x7D
Unknow error at address 0x7E
No I2C devices found
So I went off and grabbed a brand new gy21 p. Same result. A gy68 (bmp180) also doesn't work.
I have the devices connected as
Teensy LC pin 18 - Module SDA
pin 19 - Module SDC
pin 3V - Module VCC
pin GND - Module GND
I have two 4.7K pullups connected to the SDA and SDC pin from pin 3V.
To further complicate things, I also attempted to use both an ESP32 and ESP8266 to connect to the I2C devices with similar results.
I also removed the pullups
All parts were in their static shielded envelops before they were removed and tested.
I'm at a loss and thought this forum has some of the brightest folks I know, so here I am.
Any ideas?
Thanks,
Jim