BMP280-arduino-library
BMP280-arduino-library copied to clipboard
BMP280 Xiao SAMD21 compatibility issue
Hi,
I'm using the adafruit bmp 280 for some pressure measurements for a rocket launch. The problem is that when I run the below code nothing gets printed to the serial monitor at all. I know this is an issue with the bmp 280s because upon removal of their code it works just fine. Interestingly, everything I'm doing works on the Arduino Uno, which is somewhat strange. I also ran an I2C scan and the bmps are found on 0x76 and 0x77, so I feel like this might be a communication or wiring problem. I posted this same issue on the specific adafruit bmp 280 github.
Below is the code and a photo of my wiring. Any help would be greatly appreciated!
#include <Adafruit_BMP280.h> #include <Wire.h> #include <SD.h> #include <SPI.h>
Adafruit_BMP280 bmp; // Sensor 1 Adafruit_BMP280 bmp2; // Sensor 2 File dataFile;
void setup() { Serial.begin(9600); delay(500); Serial.println("starting!!!");
Wire.begin(); // Initialize I2C communication
if (!bmp.begin(0x76)) { Serial.println("Could not find a valid BMP280 sensor 1, check wiring!"); while (1); }
if (!bmp2.begin(0x77)) { Serial.println("Could not find a valid BMP280 sensor 2, check wiring!"); while (1); }
Serial.println("Both BMP280 sensors initialized successfully.");
if (!SD.begin(7)) { // Initialize SD card Serial.println("SD card initialization failed!"); while (1); } Serial.println("SD card initialized."); }
void loop() { float temperature1 = bmp.readTemperature(); float temperature2 = bmp2.readTemperature(); float altitude1 = bmp.readAltitude(1005); float altitude2 = bmp2.readAltitude(1005); float pressure1 = bmp.readPressure(); float pressure2 = bmp2.readPressure();
// Print sensor data to Serial Monitor Serial.print("Temperature 1: "); Serial.println(temperature1); Serial.print("Temperature 2: "); Serial.println(temperature2); Serial.print("Altitude 1: "); Serial.println(altitude1); Serial.print("Altitude 2: "); Serial.println(altitude2); Serial.print("Pressure 1: "); Serial.println(pressure1); Serial.print("Pressure 2: "); Serial.println(pressure2); Serial.println("-------------------------");
// Write data to SD card dataFile = SD.open("data.txt", FILE_WRITE); if (dataFile) { dataFile.print("Temperature 1: "); dataFile.println(temperature1); dataFile.print("Temperature 2: "); dataFile.println(temperature2); dataFile.print("Altitude 1: "); dataFile.println(altitude1); dataFile.print("Altitude 2: "); dataFile.println(altitude2); dataFile.print("Pressure 1: "); dataFile.println(pressure1); dataFile.print("Pressure 2: "); dataFile.println(pressure2); dataFile.println("-------------------------"); dataFile.close(); // Save the file } else { Serial.println("Error opening data.txt for writing."); }
delay(1000); }