It's connecting, but only outputting 0C and 0HPA, (and then calculating an altitude of 43km presumably from the 0 air pressure) or it displays "Failed to perform reading ".
I've wired the VIN to the 5V on the arduino, SCK to SCK, SDI to MI, and SDO to MOSI, and CS to SS. I've tried swapping the MOSI and MISO around (I'm new to arduino so not sure which way round they should be); checked the wiring tried using the digital pins, and I've tried using the I2C and SPI part of the code but don't understand the difference in the wiring; I'm just out of ideas.
In this case you fried the BMP388 as it's a 3.3V device, connecting it to 5V may destroy it.
The same applies to all SPI signals.
If you didn't connect the chip but some breakout board you failed to tell us that important detail and you failed to provide a link to the board's schematics.
Adafruit's BMP388 breakout board uses +5V to +3.3V level-shifters on the SCK and MOSI/SDI pins, but unfortunately not on MISO/SDO. Therefore care must be taken ensure that MOSI and MISO connections are correct before powering up, otherwise the Arduino Micro will drive its +5V MOSI signal into the BMP388's +3.3V SDO output with the potential for damaging the barometer device.
The correct connections should be:
MOSI --> SDI
MISO --> SDO
I've written a BMP388 library called BMP388_DEV (https://github.com/MartinL1/BMP388_DEV) that's availaible from the Arduino IDE library manager, (Sketch->Include Library->Manage Libraries...). To check that your barometer's working OK simply install the library and upload the sketch below on to your Arduino Micro:
///////////////////////////////////////////////////////////////////////////////
// BMP388_DEV - SPI Communications, Default Configuration, Normal Conversion
///////////////////////////////////////////////////////////////////////////////
#include <BMP388_DEV.h> // Include the BMP388_DEV.h library
float temperature, pressure, altitude; // Create the temperature, pressure and altitude variables
BMP388_DEV bmp388(10); // Instantiate (create) a BMP388_DEV object and set-up for SPI operation on digital pin D10
void setup()
{
Serial.begin(115200); // Initialise the serial port
bmp388.begin(); // Default initialisation, place the BMP388 into SLEEP_MODE
bmp388.setTimeStandby(TIME_STANDBY_1280MS); // Set the standby time to 1.3 seconds
bmp388.startNormalConversion(); // Start BMP388 continuous conversion in NORMAL_MODE
}
void loop()
{
if (bmp388.getMeasurements(temperature, pressure, altitude)) // Check if the measurement is complete
{
Serial.print(temperature); // Display the results
Serial.print(F("*C "));
Serial.print(pressure);
Serial.print(F("hPa "));
Serial.print(altitude);
Serial.println(F("m"));
}
}
I've tested it with my Arduino Micro and Adafruit BMP388 breakout board and can comfirm that it works:
The BMP388_DEV library will also handle the BMP388 interrupts (INT pin) and store up to 72 temperature and pressure measurements using the barometer's on-chip 512 byte FIFO buffer.