Multiple Sensors at once

I have used:

  1. BMP280
  2. BMP390
  3. AHT20
  4. DS3231
  5. LPS22HB
  6. HS3001

Board used : Arduino Nano Ble Sense Rev 2

Connected everything using I2C protocol on breadboard.
image
Code is fine but I am facing issues with output of 3rd and 6th sensors.

#include <Arduino_LPS22HB.h>
#include <Arduino_HS300x.h>
#include <DS3231.h>
#include "Adafruit_BMP3XX.h"
#include <Adafruit_BMP280.h>
#include <Adafruit_AHTX0.h>

DS3231 rtc;
Adafruit_BMP3XX bmp390;
Adafruit_BMP280 bmp280;
Adafruit_AHTX0 aht;

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)
      ;
  }
}
void loop() {
  sensors_event_t humidity, ahttemp;
  aht.getEvent(&humidity, &ahttemp);

  float temperature = BARO.readTemperature();
  float HStemperature = HS300x.readTemperature();
  float rtcTemp = rtc.getTemperature();
  float bmp390Temp = bmp390.readTemperature();
  float bmp280Temp = bmp280.readTemperature();



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

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

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

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

  Serial.println();

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

  Serial.println();

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

  Serial.println();

  Serial.println();

  Serial.println();

  delay(1000);
}

Welcome to the forum.

The "BARO" seems to be the onboard the LPS22HB pressure sensor and it is at the second I2C bus. It uses Wire1 here.

Is the Nano BLE Sense Rev 2 running Mbed ? I think so.
That is not fully compatible with libraries written for other Arduino boards.

Can you disconnect everything from the board and then run a I2C Scanner on both I2C buses ? Then add the extra sensors one by one and identify each sensor.

If you re-arrange your sensors, does the error stay with #3 and #6 or move with the sensor?

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