Problems with i2c in esp8266 (MPU9250 [GY-91])

Posted on
  • Hello,

    I'm trying to read a gyroscope (GY-91), that have an MPU-9250 inside with an BMP-280. I'm using this library But I have some problems.

    When I'm run the code throw the next error:

    Uncaught InternalError: I2CWrite: No ACK 0
    

    I'm trying with a LCD i2c, in case that if is the module that is wrong, but got the same error. Also, doesn't work with D pins (D0, D1, D2...) only with numbers

    //This doesn't work
    I2C1.setup({ scl: D4, sda: D5 });
    //This works
    I2C1.setup({ scl: 2, sda: 14 });
    

    After change the numbers the LCD works, but the MPU still don't.

    Edit: A full log of the error:

    Init MPU...
    Uncaught InternalError: I2CWrite: No ACK 0
     at line 1 col 15
    a.writeTo(12,c);return a.readFrom(12,d)
                  ^
    in function "rmag" called from line 1 col 49
    ...ew Uint8Array(this.rmag(3,7))).buffer),b=49120/32760;return{...
                                  ^
    in function "readMag" called from line 1 col 63
    ...eadGyro(),mag:this.readMag(),new:this.dataReady()}
                                  ^
    in function "read" called from line 3 col 23
          data = mpu.read();
                          ^
    in function called from system
    Uncaught Error: Unhandled promise rejection: InternalError: I2CWrite: No ACK 0
    
  • Please check the nodemcu class to get the correct pin names.

    http://www.espruino.com/Reference#t_NodeMCU

  • Check the wires and check the id of the i2c device.

  • Espruino have some function for scan all i2c devices connected?

  • I tested it, detects two devices in 0x68 (that is MPU) and 0x76 (Is the BMP).

    Here a full log of the error:

    Init MPU...
    Uncaught InternalError: I2CWrite: No ACK 0
     at line 1 col 15
    a.writeTo(12,c);return a.readFrom(12,d)
                  ^
    in function "rmag" called from line 1 col 49
    ...ew Uint8Array(this.rmag(3,7))).buffer),b=49120/32760;return{...
                                  ^
    in function "readMag" called from line 1 col 63
    ...eadGyro(),mag:this.readMag(),new:this.dataReady()}
                                  ^
    in function "read" called from line 3 col 23
          data = mpu.read();
                          ^
    in function called from system
    Uncaught Error: Unhandled promise rejection: InternalError: I2CWrite: No ACK 0
    
  • Check the module and try some simple calls.

  • I'm trying to call WHO_AM_I, don't know if this is the correct way to read data, but this is how it works the module, the example in page doesn't explain well, I mean, how to read 8 bits from device 0x68 to the address 0x75 :

    I2C1.setup( {scl: NodeMCU.D4, sda: NodeMCU.D5} );
    
    I2C1.writeTo(0x68,0x75);
    var data = I2C1.readFrom(0x75,8);
    console.log(data);
    

    But still got the same error:

    Uncaught InternalError: I2CRead: No ACK 0
     at line 5 col 33
      var data = I2C1.readFrom(0x3B,8);
                                    ^
    in function called from system
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Problems with i2c in esp8266 (MPU9250 [GY-91])

Posted by Avatar for user136941 @user136941

Actions