I have set up 2 DHT22 sensors and 2 BMP280 sensors with an Arduino Uno SMD R3 board. The DHTs are working fine and are outputting correct temperature and humidity values to the Serial monitor. The BMPs are connected via I2C and do not. I assigned the standard address (0x77) to one of them, and set the other to 0x76 by placing a jumper between GND and SDO. However, in the Serial output, both devices are detected and connected (this is checked in the loop() by using the Wire library), but only one of them (0x77) shows up with the correct pressure and temperature. The other address is recognized, but it seems not to be able to transmit data. There are already pullups on the SCL and SDA lines to the +5V terminal. Both BMP280 sensors work, by reversing their position, it is still address 0x77 that works, however, once I change the jumper, neither works. Might this be simply an issue with the breadboard or is there an address conflict somehow? Also, I have tried several values for the pullup resistors (4.7 kOhm, 10kOhm and 140kOhm), they all seem to have the same effect.

The output looks like this:

Found address: 118 (0x76)
Found address: 119 (0x77)
Found 2 device(s).
DHT22_1: hum1 = 28.00 %, temp1 = 24.80 C
DHT22_2: hum2 = 24.80 %, temp2 = 24.70 C
BMP280_0x77: t_77 = 25.83 Cp_77 = 100039.43 Pa
BMP280_0x76: t_76 = 0.00 Cp_76 = 0.00 Pa

and I used the following code:

#include <DHT.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

// Constants
#define DHTPIN_1 5     // pin for data
#define DHTPIN_2 4
#define DHTTYPE DHT22   // what type of sensor: DHT 22  (AM2302)

DHT dht1(DHTPIN_1, DHTTYPE); // initializes sensor
DHT dht2(DHTPIN_2, DHTTYPE); // initializes sensor

Adafruit_BMP280 bm77; // I2C
Adafruit_BMP280 bm76(0x76); // I2C

// Variables
int chk;
float hum1;  // stores humidity
float temp1; // stores temperature
float hum2;  // stores humidity
float temp2; // stores temperature

// --- Setup --- //
void setup()

void loop()
  byte count = 0;
  for (byte i = 1; i < 120; i++)
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");

  hum1 = dht1.readHumidity(); // reads and stores hum
  temp1= dht1.readTemperature(); // reads and stores temp
  hum2 = dht2.readHumidity(); // reads and stores hum
  temp2= dht2.readTemperature(); // reads and stores temp
  // serial output commands

  delay(2000); // reading needs to be delayed by at least 2000ms
  Serial.print("DHT22_1: ");
  Serial.print("hum1 = ");
  Serial.print(" %, temp1 = ");
  Serial.println(" C");

  Serial.print("DHT22_2: ");
  Serial.print("hum2 = ");
  Serial.print(" %, temp2 = ");
  Serial.println(" C");
  Serial.print("BMP280_0x77: ");
  Serial.print("t_77 = ");
  Serial.print(" C");
  Serial.print("p_77 = ");
  Serial.println(" Pa");
  Serial.print("BMP280_0x76: ");
  Serial.print("t_76 = ");
  Serial.print(" C");
  Serial.print("p_76 = ");
  Serial.println(" Pa");



The setup I used. red = +5V, black = GND, green = SCL, blue = SDA, yellow = DHT data lines, white = jumper between GND and SDO. Pictured is a different model of the BMP series, but in my case, I used the BMP280 and did not connect the other connectors. Edit: seems to be missing in the diagram, but of course, the positive and ground terminal are connected to the breadboard.



According to the datasheet:

SDA and SCL are not pure open drain. Both pads contain ESD protection diodes to VDDIO and GND. As the devices does not perform clock stretching, the SCL structure is a high-Z input without drain capability.

I'm not sure if this affects the operation with two together as you have them, but I must say that your debugging seems very thorough. :)

The words "without drain capability" are a bit worrying. There is a thread on the Adafruit forum about this, where they suggest an I2C multiplexer.

On my page about I2C I have a schematic and code for a simple multiplexer using the CD4051 multiplexer chip (reply #11).

The schematic is this:

Multiplexed I2C

  • I am basically just interested in connecting and reading both BMP sensors simultaneously, not necessarily over I2C. However, I cant get the SPI connection to work, I2C seems like the best option so far. Is there maybe a possibility without such a multiplexer? – ahemmetter Apr 29 '16 at 8:18
  • Judging by what you found, no. The multiplexer is, like, a $1 chip. – Nick Gammon Apr 30 '16 at 6:13
  • Alright, thank you. As an update, I have not tried it with this I2C multiplexer, but instead returned to using only one BMP sensor with an SPI connection. According to what the internet says on this topic, it seems that indeed such a multiplexer is the only reliable solution. – ahemmetter Apr 30 '16 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.