This variable is used to estimate the altitude for a given pressure by comparing it with the sea level pressure. This variable saves the pressure at the sea level in hectopascal (is equivalent to milibar). SPIĪ variable called SEALEVELPRESSURE_HPA is created. For SPI communication on the ESP32 you can use either the HSPI or VSPI pins, as shown in the following table. Note: if you’re using SPI communication, you use the ESP32 SPI pins. #include Īs we’re going to use I2C communication, the following lines that define the SPI pins are commented: /*#include 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. ArchivesCategories |