Hi, we are doing a project about the air pressure sensor. Measure barometric pressure, temperature and altitude with mega2560 and bmp280 connection. The compilation result shows sensor initialization failure, why?
Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
Sorry, I am a new user. They only let me upload 1 picture. The program has no error warnings, but the serial monitor always shows initialization failure when interacting with the MEGA2560.
Don't upload pictures. Copy the code using "Copy for forum" in the IDE and post it here. The IDE will add the code tags for you. Copy the Serial monitor output and paste it here adding the code tags yourself
I just re-checked the datasheet of this sensor: https://cdn-shop.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf
You should be able to use yours in either I2C or SPI mode. So SPI mode should also work, provided that you've made the right connections, AND you make sure that the interface selection procedure on startup involving the CSB pin is performed correctly. See section 5.1 on page 28 of the datasheet. You'd have to check the Adafruit library if this indeed performs the correct sequence.