I am trying to interface the new Nano RP2040 connect with an Adafruit BMP280 pressure sensor. So far I have been unsuccessful. Has anyone else managed to do this or can confirm whether the sensor is incompatible please?
This is the code I have been using showing the initialised features and set up. It compiles successfully, and loads but reports the sensor is not there. I have rechecked all the wiring and tried a substitute:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Arduino_LSM6DSOX.h>
#include <math.h> //library includes mathematical functions
#include <SD.h> //sd card
#define CS 8 //sd card
#define button 4 //end data button
#define BMP_SCK (13) //Pressure sensor connections
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
Adafruit_BMP280 bmp; // I2C
/*
const int MPU=0x68; //I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ; //16-bit integers
int AcXcal,AcYcal,AcZcal,GyXcal,GyYcal,GyZcal; //Set axis calibration variables
*/
int button_state = 0; //end data button
int i = 0; //SD card - counter
File logFile; //SD card log file name
const int m = 60000; // 1 Min delay value
// SD card function.
boolean initCard()
{
Serial.print(F("Starting SD card..."));
if (!SD.begin(CS))
{
// An error occurred.
Serial.println(F("SD card FAILED!")); // Sound !Failed Card!
lF();
lC();
delay(t * 20);
return false;
}
else // The SD card works.
Serial.println(F("SD card ready!")); // Sound !Ok Card!
lO();
lC();
delay(t * 20);
return true;
}
void setup()
{
// Starting up... Sound !Starting Up!
lS();
lU();
delay(t * 20);
// Serial monitor setup
Serial.begin(9600);
while (!Serial);
//IMU setup
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!"); // Sound ! Failed Gyro!
lF();
lG();
delay(t * 20);
while (1);
}
//Pressure Setup
Serial.println(F("Testing pressure sensor..."));
if (!bmp.begin()) {
Serial.println(F("Pressure sensor NOT detected!")); // Sound !Failed Pressure!
lF();
lP();
delay(t * 20);
while (1);
}
else
lO(); // Sound !Ok Pressure!
lP();
delay(t *20);
}
'''
Can you please modify your post to ensure the source code is in a single box. It should look like this.
// Your example source code
You need three ' at the beginning and end in the edit window? When you click on this icon </> you get.
```
type or paste code here
```
This ensures we can get all the source code. Right now if you copy the code there are invisible characters that prevent successful compilation and parts might be missing. An extract of your code is often not useful as the issue can be in the code you did not post.
I tested the BME280 with the RP2040 connected over I2C in combination with WiFi and separately with BLE successfully.