Disclaimer: I'm an extreme noob.
I've been trying to get my BMP280 to measure temperature and pressure, and display it on the Serial Monitor. I've been using the example code from the BMP280 library, but just added a 'while(!Serial);' in the void.setup()
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
//#define BMP_SCK (7)
//#define BMP_MISO (5)
//#define BMP_MOSI (3)
//#define BMP_CS (2)
Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println(F("BMP280 test"));
status=bmp.begin();
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while(1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}
void loop() {
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print(F("Approx altitude = "));
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
Serial.println(" m");
Serial.println();
delay(1000);
}
When I run this code, the Serial Monitor displays the error message ("Could not find a valid BMP280 sensor, check wiring!")
I did the circuit using Adafruit's guide. Specifically, the VIN is connected to VCC (I've also tried connecting it to RAW), the GND is connected to GND, the SCK is connected to 3 and SDI is connected to 2. I tried both the I2C and SPI protocol (changing the code to match) but it didn't work.
I've tried changing the USB cable, the Pro Micro and the computer. I haven't tried changing the BMP280 itself because I don't have another one.
When I ran the I2C scanner, initially, it said the device was at 0x77 so I changed the i2c location in the BMP280 library. It still didn't work, so I tried other troubleshooting things like the changes listed above. Now, when I run the I2C scanner, it says that no I2C devices were found.
I'd be extremely grateful for any advice because I've been trying to get this to work for a while now and from what I understand this is supposed to be relatively straightforward.