Hello,
I'm trying to connect 3 bme280 sensors in an Arduino UNO board, my code apparently does not have any problems, but when i connect the sensors it does not give me any error messages, just it don't display any readings that i want.
The sensors are working, they have been tested individually. I'm using a breadboard and jumper cables for the wiring at the moment.
#include <Time.h>
#include <TimeLib.h>
#include <DS1307.h>
#include <Wire.h>
#include <SD.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
//Pinos Sensores
const int Sensor1=A1;
const int Sensor2=A2;
const int Sensor3=A3;
unsigned long delayTime;
void setup()
{
Serial.begin(9600);
unsigned status;
Serial.println(("Antes"));
status = bme.begin();
Serial.println(("Depois do begin"));
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}
Serial.println("-- Começando Medição --");
delayTime = 1000;
Serial.println();
}
void loop() {
LerSensoresV2(1,0,0);
LerSensoresV2(0,1,0);
LerSensoresV2(0,0,1);
delay(36000); // Intervalo de 1h para a 2 medição
}
/***********************************************************************************
* Funções de apoio ao programa
*
*
*/
/************************
* Função para ler os sensores
*
*/
void LerSensoresV2(int E1, int E2, int E3)
{
unsigned status;
digitalWrite(Sensor1, E1); // Liga o sensor 1
digitalWrite(Sensor2, E2); // Desliga o sensor 2
digitalWrite(Sensor3, E3); // Desliga o sensor 3
status = bme.begin(0x76); // Ativa o sensor
delay(200);
Serial.println(" Sensor ");
printValues(); // Lê os valores e os informa pelo serial
delay (200);
digitalWrite(Sensor1, LOW); // Liga o sensor 1
digitalWrite(Sensor2, LOW); // Desliga o sensor 2
digitalWrite(Sensor3, LOW); // Desliga o sensor 3
delay(200);
}
/*
* Função para imprimir os valores e gravar no SD
*/
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
I have tried multiples codes and i do not have any idea why it is not working. Can anyone give some advice?
Sorry for any mistake in my posting, this is my first one. Thanks