Multiple Sensors in one Board.s

I have used:

  1. BMP280
  2. BMP390
  3. AHT20
  4. DS3231
  5. LPS22HB
  6. HS3001
  7. MPU6050
  8. MPU9250

Board used : Arduino Nano Ble Sense Rev 2

Connected everything using I2C protocol on breadboard.
Facing issues with #5 , #7 and #8 sensors.

My Code :

#include <Arduino_LPS22HB.h>
#include <Arduino_HS300x.h>
#include <DS3231.h>
#include "Adafruit_BMP3XX.h"
#include <Adafruit_BMP280.h>
#include <Adafruit_AHTX0.h>
#include <Adafruit_MPU6050.h>
#include <MPU9250.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

DS3231 rtc;
Adafruit_BMP3XX bmp390;
Adafruit_BMP280 bmp280;
Adafruit_AHTX0 aht;
Adafruit_MPU6050 mpu6050;
MPU9250 mpu9250;



void setup() {
  Serial.begin(9600);
  while (!Serial) {
  }
  

  if (!BARO.begin()) {
    Serial.println("Failed to initialize pressure sensor!");
    while (1)
      ;
  }
  
  if (!HS300x.begin()) {
    Serial.println("Failed to initialize humidity temperature sensor!");
    while (1)
      ;
  }
  if (!bmp390.begin_I2C()) {
    Serial.println("Could not find a valid BMP390 sensor!");
    while (1)
      ;
  }
  if (!bmp280.begin()) {
    Serial.println("Could not find a valid BMP280 sensor!");
    while (1)
      ;
  }
  if (!aht.begin()) {
    Serial.println("AHT20 is not connected!");
    while (1)
      ;
  }
  /*
  if(!mpu6050.begin()){
    Serial.println("Error in mpu6050");
    while(1);
  }*/
  if(!mpu9250.setup(0x68)){
    Serial.println("Error in mpu9250");
  }
  
}
void loop() {
  
  sensors_event_t humidity, ahttemp;
  aht.getEvent(&humidity, &ahttemp);
/*
  sensors_event_t a, g, temp6050;
	mpu6050.getEvent(&a, &g, &temp6050);
*/
  mpu9250.update();

  Serial.print("Baro temperature : ");
  Serial.print(BARO.readTemperature());
  Serial.print("°C");

  Serial.println();
  Serial.print("HS300X temperature : ");
  Serial.print(HS300x.readTemperature());
  Serial.print("°C");

  Serial.println();
  Serial.print("RTC temperature : ");
  Serial.print(rtc.getTemperature());
  Serial.print("°C");

  Serial.println();
  Serial.print("BMP390 temperature : ");
  Serial.print(bmp390.readTemperature());
  Serial.print("°C");

  Serial.println();

  Serial.print("BMP280 temperature : ");
  Serial.print(bmp280.readTemperature());
  Serial.print("°C");

  Serial.println();

  Serial.print("AHT20 temperature : ");
  Serial.print(ahttemp.temperature);
  Serial.print("°C");

  Serial.println();

  Serial.print("MPU9250 temperature : ");
  Serial.print(mpu9250.getTemperature());
  Serial.print("°C");

  Serial.println();
/*
  Serial.print("MPU6050 temperature : ");
  Serial.print(temp6050.temperature);
  Serial.print("°C");

  Serial.println();
*/
  Serial.println();

  Serial.println();

  delay(1000);
}

Commented MPU6050 because it was giving some error.

Output :

image

Tried testing individual sensors.. It was working.

It will help others to help you if you can explain what the issues / errors are.

Without looking up the datasheets for these devices, could the issue(s) be related to a clash of I2C addresses?

Are these sensors on breakout boards? Do several of them have pull up resistors on the I2C bus?

you have a large number of sensors? how are you powering them?
the Arduino Nano Ble Sense Rev 2 is a 3.3V logic device
if you are connecting sensors which use 5V logic use level shifts or potential dividers

I forgot to add that you could try and run an I2C scanner to check that all your devices are detected.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.