I'm using an ESP12-E module with an I2C device (H3LIS331DL). I hooked everything up and used the I2C scanner code, which you can see here:
#include <Wire.h>
void setup()
{
Wire.begin(19,20);
Serial.begin(9600);
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.print(address,HEX);
Serial.println(" !");
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); // wait 5 seconds for next scan
}
It basically just scans for I2C devices in your lane and if it found something you'll get a message. Anyway when I upload it onto my board I get this error instead.
The reason I used
Wire.begin(19,20);
https://www.kloppenborg.net/images/blog/esp8266/esp8266-esp12e-specs.pdf the pins on SDA and SCL are 19 and 20. If I leave it blank it wont work. I actually get the message "No I2C device found" on the serial monitor.
I also tried to solder a wire bridge from GPIO 4 to GPIO 2 and GPIO 5 to GPIO 14 and changed the arguments of Wire.begin accordingly. Because the datasheet on page 12 said that its using that I2C lane. Unfortunately that didnt help either. I get the same error as in
Wire.begin(19,20);
I also attached a picture of how I wired everything up.
I also checked that the Wire.h library supports ESP8266 boards.
These are my Arduino IDE settings:
- Windows 10 64bit
- Arduino IDE 1.8.5
- NodeMCU1.0(ESP12-E)
- Flash Size: 4M
- CPU Frequency: 80Mhz
- Upload Speed: 115200
I also tried changing upload speed and choosing another ESP8266 board. But I keep getting the same error.
At this point I dont know if it's a hardware issue or a software issue.
I hope I didnt forget to mention anything important.
Any help would be appreciated
Thanks in advance.