The code starts by including the needed libraries: the wire library to use I2C, and the Adafruit_Sensor and Adafruit_BME280 libraries to interface with the BME280 sensor. ![]() How the Code WorksĬontinue reading this section to learn how the code works, or skip to the “Demonstration” section. We’ve made a few modifications to the sketch to make it fully compatible with the ESP32. Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)) Serial.print(bme.readPressure() / 100.0F) Serial.print(1.8 * bme.readTemperature() + 32) Serial.println("Could not find a valid BME280 sensor, check wiring!") (you can also pass in a Wire library object like &Wire2) ![]() Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK) // software SPI Adafruit_BME280 bme(BME_CS) // hardware SPI ![]() After installing the BME280 library, and the Adafruit_Sensor library, open the Arduino IDE and, go to File > Examples > Adafruit BME280 library > bme280 test.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2023
Categories |