SEN0390 ambient light lux sensor with multiple I2C
When using a single SEN0390 with a MKR1010 board I get good readings from the sensor. When I also connect an HDC1080 sensor via I2C I am getting a lux value of -1 and the default non reading on the HDC1080. If I use the HDC1080 by itself it works fine.
When I do an I2C scan using https://playground.arduino.cc/Main/I2cScanner/ the address for the SEN0390 seems to be 0x4A (I thought it would be 0x94 based on library on GitHub (line 35 of DFROBOT_B_LUX_V30B.h) at https://github.com/DFRobot/DFRobot_B_LUX_V30B
Not sure what else to try - any suggestions?
Code I am trying on MKR1010 is below:
#include <DFRobot_B_LUX_V30B.h>
#include <Wire.h> // used for HDC1080 temp / hum sensor
#include "Adafruit_HDC1000.h"
DFRobot_B_LUX_V30B myLux(13);
Adafruit_HDC1000 hdc = Adafruit_HDC1000();
void setup() {
Serial.begin(115200);
myLux.begin();
if (!hdc.begin()) {
Serial.println("Couldn't find sensor!");
while (1);
}
}
void loop() {
Serial.print("Light: ");
Serial.print(myLux.lightStrengthLux());
Serial.print(" - Temperature: ");
Serial.print(hdc.readTemperature());
Serial.print(" - Humidity: ");
Serial.println(hdc.readHumidity());
delay(1000);
}
SEN0390 is sealed by software IIC, and can not be used with other equipment or sensors using hardware IIC. Its address is 0x94.
jennaI checked the library and this function can define the sensor pins.
For example:
sensor ——> board
VCC——>VCC
GND——>GND
SCL——> 7(digital pin)
SDA——> 8(digital pin)
EN——> 13(digital pin)
#include <DFRobot_B_LUX_V30B.h>
#include <Wire.h> // used for HDC1080 temp / hum sensor
#include "Adafruit_HDC1000.h"
DFRobot_B_LUX_V30B myLux(13,7,8);
Adafruit_HDC1000 hdc = Adafruit_HDC1000();
void setup() {
Serial.begin(115200);
myLux.begin();
if (!hdc.begin()) {
Serial.println("Couldn't find sensor!");
while (1);
}
}
void loop() {
Serial.print("Light: ");
Serial.print(myLux.lightStrengthLux());
Serial.print(" - Temperature: ");
Serial.print(hdc.readTemperature());
Serial.print(" - Humidity: ");
Serial.println(hdc.readHumidity());
delay(1000);
}
Ah! Thanks for the tip. That works beautifully!
Hello jenna, i try it but not work for me..
Can u help me for this??
I think you have to look inside the "Adafruit_HDC1000.h" and DFRobot_B_LUX_V30B.h libraries. Maybe somewhere these two libraries are conflicting.Verify that the SEN0390 and HDC1080 have different I2C addresses. The I2C address of the SEN0390 should be 0x4A based on your I2C scan, and the HDC1080 default address is 0x40. If they have conflicting addresses, you might need to change the address of one of the sensors.
bidrohini.bidrohiniThanks - have confirmed that SEN0390 seems to be 0x4A and HDC is 0x40 - therefore I believe that means they are not conflicting.