-->
Page 1 of 1

Wemos D1 mini - I2C not working.

PostPosted: Sat Jun 16, 2018 5:10 am
by terenceang
Hi,

I2C don't seems to work on Wemos D1 mini and BMP180 shield, running an i2c scanner sketch works if you search a range of address but it if you only search for 1(or 2) address it returns a NACK.

BMP180 is on 0x77. error code return was 2.

Been trying various different ways to get it to work without success. any help is appreciated.

Terence.

Sketch for testing.

Code: Select all#include <Wire.h>
void setup()
{
   //D1 - SCL
   //D2 - SDA
   Wire.begin();
   Serial.begin(9600);
   while (!Serial);             // Leonardo: wait for serial monitor
   Serial.print("\nI2C Scanner : ");
}

//0:success
//1 : data too long to fit in transmit buffer
//2 : received NACK on transmit of address
//3 : received NACK on transmit of data
//4 : other error

void loop()
{
   byte error, address;
   int nDevices;

   Serial.println("Scanning...");

   nDevices = 0;
   for (address = 0x75; address < 0x78; address++)
   {
      Wire.beginTransmission(address);
      error = Wire.endTransmission();
      Serial.print("error = ");
      Serial.println(error);
      Wire.flush();
      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("Unknown 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
}

Re: Wemos D1 mini - I2C not working.

PostPosted: Sat Jun 16, 2018 8:44 pm
by QuickFix
Have you tried (8-bit) addres 0xEE, instead of 0x77 (7-bit), yet? :idea: