So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By DCRaiDaN
#77582 Hi everyone,

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:
Code: Select all#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.
Error.PNG


The reason I used
Code: Select allWire.begin(19,20);
is because according to the datasheet of the ESP12-E
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
Code: Select allWire.begin(19,20);


I also attached a picture of how I wired everything up.
I2C Lane2.PNG


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. :-)
You do not have the required permissions to view the files attached to this post.
User avatar
By schufti
#77642 you can't use physical pin# by default.
The numbers expected are the gpio"X" numbers.
Depending on the board setting, they default to 0,2 or 4,5.
And be also aware that for NodeMcu boards the printed numbers are not the gpio!