12. Input devices
BMP280 and Arduino
I decided to the the Adafruit BMP280 Barometric Pressure + Temperature Sensor as it was an I2C enabled sensor we had in the lab.
First of all I found the data sheet here
In the data sheet there is a clear pint out
;
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();
void setup() {
Serial.begin(9600);
while ( !Serial ) delay(100); // wait for native usb
Serial.println(F("BMP280 Sensor event test"));
unsigned status;
//status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
status = bmp.begin();
if (!status) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
"try a different address!"));
Serial.print("SensorID was: 0x"); Serial.println(bmp.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);
}
/* 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. */
bmp_temp->printSensorDetails();
}
void loop() {
sensors_event_t temp_event, pressure_event;
bmp_temp->getEvent(&temp_event);
bmp_pressure->getEvent(&pressure_event);
Serial.print(F("Temperature = "));
Serial.print(temp_event.temperature);
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(pressure_event.pressure);
Serial.println(" hPa");
Serial.println();
delay(2000);
}
I got the following error
16:19:39.376 -> BMP280 Sensor event test 16:19:40.949 -> Could not find a valid BMP280 sensor, check wiring or try a different address! 16:19:40.997 -> SensorID was: 0x0 16:19:41.030 -> ID of 0xFF probably means a bad address, a BMP 180 or BMP 085 16:19:41.096 -> ID of 0x56-0x58 represents a BMP 280, 16:19:41.128 -> ID of 0x60 represents a BME 280. 16:19:41.193 -> ID of 0x61 represents a BME 680. 16:20:11.940 -> BMP280 Sensor event test 16:20:11.974 -> Could not find a valid BMP280 sensor, check wiring or try a different address!
I reinspected my wiring and while it matched the once for the data sheet I did notice that I had put the I2C wires into the wrong place in the Arduino .... a quick correction and we are off to the races.
16:20:12.236 -> ID of 0x61 represents a BME 680. 16:20:47.963 -> BMP280 Sensor event test 16:20:48.086 -> ------------------------------------ 16:20:48.119 -> Sensor: BMP280 16:20:48.119 -> Type: Ambient Temp (C) 16:20:48.185 -> Driver Ver: 1 16:20:48.185 -> Unique ID: 280 16:20:48.217 -> Min Value: -40.00 16:20:48.217 -> Max Value: 85.00 16:20:48.250 -> Resolution: 0.01 16:20:48.283 -> ------------------------------------ 16:20:48.316 -> 16:20:48.316 -> Temperature = 27.73 *C 16:20:48.349 -> Pressure = 991.60 hPa 16:20:48.349 -> 16:20:50.315 -> Temperature = 27.67 *C 16:20:50.315 -> Pressure = 991.53 hPa
No I wanted to check the temp and so start blowing hot air on the sensor and quickly say the temp start to climb
16:35:41.981 -> Temperature = 23.54 *C 16:35:41.981 -> Pressure = 991.40 hPa 16:35:42.041 -> 16:35:43.962 -> Temperature = 23.54 *C 16:35:43.995 -> Pressure = 991.41 hPa 16:35:44.037 -> 16:35:45.998 -> Temperature = 23.53 *C 16:35:45.998 -> Pressure = 991.42 hPa 16:35:46.037 -> 16:35:47.984 -> Temperature = 24.20 *C 16:35:48.034 -> Pressure = 991.42 hPa 16:35:48.076 -> 16:35:50.007 -> Temperature = 25.51 *C 16:35:50.007 -> Pressure = 991.43 hPa 16:35:50.049 -> 16:35:51.982 -> Temperature = 26.59 *C 16:35:52.014 -> Pressure = 991.43 hPa 16:35:52.060 -> 16:35:53.994 -> Temperature = 27.44 *C 16:35:54.025 -> Pressure = 991.48 hPa 16:35:54.070 -> 16:35:55.996 -> Temperature = 28.02 *C 16:35:56.029 -> Pressure = 991.50 hPa 16:35:56.073 -> 16:35:58.035 -> Temperature = 28.32 *C 16:35:58.035 -> Pressure = 991.52 hPa 16:35:58.079 -> 16:36:00.042 -> Temperature = 28.68 *C 16:36:00.042 -> Pressure = 991.55 hPa 16:36:00.082 -> 16:36:02.045 -> Temperature = 29.02 *C 16:36:02.045 -> Pressure = 991.58 hPa 16:36:02.090 -> 16:36:04.032 -> Temperature = 29.14 *C 16:36:04.065 -> Pressure = 991.60 hPa 16:36:04.108 -> 16:36:06.051 -> Temperature = 29.19 *C 16:36:06.097 -> Pressure = 991.61 hPa 16:36:06.097 -> 16:36:08.046 -> Temperature = 29.27 *C 16:36:08.078 -> Pressure = 991.61 hPa 16:36:08.122 -> 16:36:10.069 -> Temperature = 29.75 *C 16:36:10.069 -> Pressure = 991.61 hPa 16:36:10.115 -> 16:36:12.075 -> Temperature = 30.21 *C 16:36:12.075 -> Pressure = 991.68 hPa 16:36:12.118 -> 16:36:14.074 -> Temperature = 30.77 *C 16:36:14.120 -> Pressure = 991.68 hPa
BMP280 moving to the RP2040
I set up the basic connection with the using the following pinout
Made the connections to the sensor
And we are live:
BMP280 and Fab Xiao
I wanted to hook up the sensor the to board I made based on the fab xiao. It was pretty straight forward following the same code I used with the the RP2040 stand alone
The pinout for the board is
I hooked up the sensor
and here you go as I blow hot air the temp goes up:
You can find the code here