Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 6 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:
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).