esp32_bme280_w_arduino_ide
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
esp32_bme280_w_arduino_ide [2025/03/06 21:05] – bruno | esp32_bme280_w_arduino_ide [2025/08/29 14:07] (current) – removed bruno | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== ESP32 + BME280 w/ Arduino IDE ===== | ||
- | Sketch > Include Library > Manage Libraries > adafuit bme280 | ||
- | |||
- | (Sketch > Include Library > Manage Libraries > adafuit unified sensor) | ||
- | |||
- | **BMP280 vs BME280** -> https:// | ||
- | |||
- | **5V vs 3.3V** -> https:// | ||
- | |||
- | ** BME280 5V :** | ||
- | |||
- | Connexion BME -> ESP | ||
- | |||
- | ^ BME280 ^ ESP32 | | ||
- | | VCC | 5V | | ||
- | | GND | GND | | ||
- | | SDA | GPIO21| | ||
- | | SCL | GPIO22| | ||
- | |||
- | |||
- | File > Examples > Adafruit BME280 library > bme280test | ||
- | |||
- | Comment lines | ||
- | <code c> | ||
- | //#include < | ||
- | </ | ||
- | et | ||
- | <code c> | ||
- | /*#define BME_SCK 13 | ||
- | #define BME_MISO 12 | ||
- | #define BME_MOSI 11 | ||
- | #define BME_CS 10*/ | ||
- | </ | ||
- | et ajoute 0x76 (ligne 46) | ||
- | <code c> | ||
- | status = bme.begin(0x76); | ||
- | </ | ||
- | |||
- | /!\ Serial monitor @ 9600 baud | ||
- | |||
- | |||
- | === Code === | ||
- | |||
- | <code c> | ||
- | #include < | ||
- | //#include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | /*#define BME_SCK 13 | ||
- | #define BME_MISO 12 | ||
- | #define BME_MOSI 11 | ||
- | #define BME_CS 10*/ | ||
- | |||
- | #define SEALEVELPRESSURE_HPA (1013.25) | ||
- | |||
- | Adafruit_BME280 bme; // I2C | ||
- | // | ||
- | // | ||
- | |||
- | unsigned long delayTime; | ||
- | |||
- | void setup() { | ||
- | Serial.begin(9600); | ||
- | while(!Serial); | ||
- | Serial.println(F(" | ||
- | |||
- | unsigned status; | ||
- | | ||
- | // default settings | ||
- | status = bme.begin(0x76); | ||
- | // You can also pass in a Wire library object like &Wire2 | ||
- | // status = bme.begin(0x76, | ||
- | if (!status) { | ||
- | Serial.println(" | ||
- | Serial.print(" | ||
- | Serial.print(" | ||
- | Serial.print(" | ||
- | Serial.print(" | ||
- | Serial.print(" | ||
- | while (1) delay(10); | ||
- | } | ||
- | | ||
- | Serial.println(" | ||
- | delayTime = 1000; | ||
- | |||
- | Serial.println(); | ||
- | } | ||
- | |||
- | |||
- | void loop() { | ||
- | printValues(); | ||
- | delay(delayTime); | ||
- | } | ||
- | |||
- | |||
- | void printValues() { | ||
- | Serial.print(" | ||
- | Serial.print(bme.readTemperature()); | ||
- | Serial.println(" | ||
- | |||
- | Serial.print(" | ||
- | |||
- | Serial.print(bme.readPressure() / 100.0F); | ||
- | Serial.println(" | ||
- | |||
- | Serial.print(" | ||
- | Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | ||
- | Serial.println(" | ||
- | |||
- | Serial.print(" | ||
- | Serial.print(bme.readHumidity()); | ||
- | Serial.println(" | ||
- | |||
- | Serial.println(); | ||
- | } | ||
- | </ |
esp32_bme280_w_arduino_ide.1741295150.txt.gz · Last modified: 2025/03/06 21:05 by bruno