9 years, 11 months ago.

ST Nucleo F401RE GY-30 I2C problem

Hello Guys,

I have quite big trouble with my Nucleo board and cooperation with GY-30 board (BH1750FVI breakout board). I found piece of code for Arduino. Transfer this code to mbed is quite simple but I'm not able to go through init process because of non-ack signal in initiation method. This is my setup:

/media/uploads/vrabec/img_6720.jpg

This is code (basically just init method):

#include "mbed.h"

I2C i2c(I2C_SDA, I2C_SCL);
int BH1750address = 0x23;
char buff[2];

DigitalOut myled(LED1);

int BH1750_Init(int address)
{
    buff[0] = 0x10;
    return i2c.write(address, buff, 1, false);
}

int main()
{
    myled = 0;
    int status = BH1750_Init(BH1750address);
    int time_ms = 200;  //non success
    if(status == 0) {   //success
        time_ms = 1000;
    }
    while(1) {
        myled = !myled;
        wait_ms(time_ms);
    }

}

Please help me. It seems i'm not able to get I2C work on my Nucleo board and I don't know what i'm doing wrong. (btw.: no jumper was change, i'm using default setup).

1 Answer

9 years, 11 months ago.

I guess the address is wrong. Arduino uses a 7bit address whereas mbed libs use an 8 bit address. Try shifting the address 0x23 by one bit to the left: 0x46

Accepted Answer

This helps, thanks a lot!

posted by Michal Stehlik 11 May 2014