11 years, 2 months ago.

Cant get it to work

I've tried to use the proposed code, but I simply cant get around to make it work. The code only returns -1. Can you help me somehow?

Question relating to:

You should share more information. How can we help you? What's your app code? Share a snippet or the application. Otherwise you won't get any help, only guesses which leads nowhere.

Regards,
0xc0170

posted by Martin Kojtal 08 Oct 2014

Thank you Martin, for your response. I'm quite new to the mbed community and still getting used to it. I've tried running the commented code in the library, the one that follows. There is noting going on on the SCL or SDA after plugging it all in and getting the code running (I tested the waveform with an osciloscope). I know there is nothing wrong with the mbed board or the I2C pins, since they work with other codes (pins 27 and 28) I really have the feeling that I'm missing out something huge here. The serial out I get is "Light intensity: -1 Lux" or something like that. And oh.. i'm using mbed LPC1768 Thank you again for your time and patience.

  1. include "mbed.h"
  2. include "BH1750.h" BH1750 lightSensor(I2C_SDA, I2C_SCL); Serial pc(SERIAL_TX, SERIAL_RX);

int main() { lightSensor.init(); while(1) { pc.printf("Light intensity: %.4f Lux\r\n", lightSensor.readIntesity()); wait(5); } }

posted by Davi Rego 08 Oct 2014
Be the first to answer this question.