For anyone interested, I finally figured it out. First, it seems that the RP2040 uses the TwoWire library by default so some of the standard Wire commands don't work. I you do want to use Wire (as opposed to Wire1) in
think you have to specify which pins to use. Or at least I did. Here's how I did it for the BME688:
Code: Select all
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
Adafruit_BME680 bme; // I2C
void setup() {
Serial.begin(9600);
// Here's where the Wire pins are set for the TwoWire library
Wire.setSDA(28); // this is the A2 pin
Wire.setSCL(29); // this is the A3 pin
////////////////////
// Begin the BME sensor
while (!bme.begin()) {
Serial.println("Could not find the BME680 sensor, checking again");
delay(1000);
}
}
void loop() {
////////////////////
// BME reads
if (! bme.performReading()) {
Serial.println("BME reading failed");
return;
}
float bme_temp = bme.temperature; // Celcius
float bme_pres = bme.pressure / 100.0; // hPa
float bme_humd = bme.humidity; // %
float bme_gasR = bme.gas_resistance/ 1000.0; //KOhms
Serial.print(bme_temp); Serial.print(", ");
Serial.print(bme_pres); Serial.print(", ");
Serial.print(bme_humd); Serial.print(", ");
Serial.println(bme_gasR);
delay(1000);
}