Go Down

Topic: BH1750 and MLX90614 do not work together on I2C, why? (Read 78 times) previous topic - next topic

cevepe

I only have BH1750, MLX90614 on I2C and both do not work on the same line. When I tested the MLX90614 separately, everything worked fine. After connecting the bH1750, everything worked for a few minutes and then I started getting crap over the serial line.
4.00
4.003.00
5.006.00

While the sun is shining, the lux from the BH1750 should measure over 30,000 lux and the MLX90614 should throw -40 in clear skies.

Will you help me how to make it work? My code is below:

Code: [Select]

#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <BH1750FVI.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

BH1750FVI LightSensor(BH1750FVI::k_DevModeContLowRes);
uint16_t lux;


void setup() {
  Serial.begin(9600);
  Wire.begin();
 
  mlx.begin();
  LightSensor.begin();
}

void loop() {
 
  if(Serial.available())
  {
    byte value = Serial.read();
     if(value == '1')
     {
      lux = LightSensor.GetLightIntensity();
      Serial.print(lux);
      Serial.print("|");
      Serial.print(mlx.readObjectTempC());
     }
  }

}

Koepel

Which Arduino board do you use ?
Which MLX90614 do you use ? The 3V version or the 5V version ?
The BH1750 is only for 3.3V. Can you give a link to where you bought the module ?
Do you use pullup resistors for the I2C bus and what is their value and are they pullups to 5V or to 3.3V ?

This is the MLX90614 library that you use: https://github.com/adafruit/Adafruit-MLX90614-Library. The function readObjectTempC() returns a 'double'.
Which BH1750FVI library do you use ?

When there is a problem with printing the "|", then use a comma. Also print a new line.
Why wait for the serial input ? You can make a test-sketch with this:
Code: [Select]

void loop()
{
  lux = LightSensor.GetLightIntensity();
  Serial.print(lux);
  Serial.print(", ");
  double temperature = mlx.readObjectTempC();
  Serial.print( temperature);
  Serial.println();
 
  delay( 500);
}


Both sensors should not be pointed towards the sun.

Go Up