esp32_bme280_w_arduino_ide
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
esp32_bme280_w_arduino_ide [2025/03/06 21:04] – created bruno | esp32_bme280_w_arduino_ide [2025/03/10 15:27] (current) – bruno | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== ESP32 + BME280 w/ Arduino IDE ===== | ===== ESP32 + BME280 w/ Arduino IDE ===== | ||
- | Sketch > Include Library > Manage Libraries > adafuit bme280 | ||
- | (Sketch > Include Library > Manage Libraries > adafuit unified sensor) | + | [[https:// |
**BMP280 vs BME280** -> https:// | **BMP280 vs BME280** -> https:// | ||
Line 9: | Line 9: | ||
**5V vs 3.3V** -> https:// | **5V vs 3.3V** -> https:// | ||
- | ** BME280 5V :** | + | **J'ai un BME280 5V :** |
Connexion BME -> ESP | Connexion BME -> ESP | ||
Line 19: | Line 19: | ||
| SCL | GPIO22| | | SCL | GPIO22| | ||
+ | * Sketch > Include Library > Manage Libraries > adafuit bme280 | ||
+ | * (Sketch > Include Library > Manage Libraries > adafuit unified sensor) | ||
+ | * File > Examples > Adafruit BME280 library > bme280test | ||
+ | * Comment lines (ligne 20) ''# | ||
+ | * Ajouter 0x76 (ligne 46) -> '' | ||
- | File > Examples > Adafruit BME280 library > bme280test | ||
- | Comment lines | + | === Code === |
- | <code c> | + | |
- | //#include < | + | |
- | </ | + | |
- | et | + | |
<code c> | <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 | + | #include < |
+ | #include < | ||
+ | #include < | ||
+ | Adafruit_BME280 bme; // I2C | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | while(!Serial); | ||
+ | |||
+ | unsigned status; | ||
+ | | ||
+ | status = bme.begin(0x76); | ||
+ | if (!status) { | ||
+ | Serial.println(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | while (1) delay(10); | ||
+ | } | ||
+ | Serial.println(); | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop() { | ||
+ | printValues(); | ||
+ | delay(1000); | ||
+ | } | ||
+ | |||
+ | |||
+ | 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.readHumidity()); | ||
+ | Serial.println(" | ||
+ | |||
+ | Serial.println(); | ||
+ | } | ||
+ | |||
+ | </ |
esp32_bme280_w_arduino_ide.1741295084.txt.gz · Last modified: 2025/03/06 21:04 by bruno