User Tools

Site Tools


esp32_bme280_w_arduino_ide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
esp32_bme280_w_arduino_ide [2025/03/06 21:05] brunoesp32_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://www.wiki.lesfabriquesduponant.net/index.php?title=Capteur_BME280#Comment_distinguer_BME280_et_BMP280_.3F 
- 
-**5V vs 3.3V** -> https://www.wiki.lesfabriquesduponant.net/index.php?title=Capteur_BME280#Connecter_BME_280_.C3.A0_l.27arduino 
- 
-** 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 <SPI.h> 
-</code> 
-et 
-<code c> 
-/*#define BME_SCK 13 
-#define BME_MISO 12 
-#define BME_MOSI 11 
-#define BME_CS 10*/ 
-</code> 
-et ajoute 0x76 (ligne 46) 
-<code c> 
-status = bme.begin(0x76); 
-</code> 
- 
-/!\ Serial monitor @ 9600 baud 
- 
- 
-=== Code === 
- 
-<code c> 
-#include <Wire.h> 
-//#include <SPI.h> 
-#include <Adafruit_Sensor.h> 
-#include <Adafruit_BME280.h> 
- 
-/*#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 
-//Adafruit_BME280 bme(BME_CS); // hardware SPI 
-//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI 
- 
-unsigned long delayTime; 
- 
-void setup() { 
-    Serial.begin(9600); 
-    while(!Serial);    // time to get serial running 
-    Serial.println(F("BME280 test")); 
- 
-    unsigned status; 
-     
-    // default settings 
-    status = bme.begin(0x76);   
-    // You can also pass in a Wire library object like &Wire2 
-    // status = bme.begin(0x76, &Wire2) 
-    if (!status) { 
-        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"); 
-        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16); 
-        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n"); 
-        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n"); 
-        Serial.print("        ID of 0x60 represents a BME 280.\n"); 
-        Serial.print("        ID of 0x61 represents a BME 680.\n"); 
-        while (1) delay(10); 
-    } 
-     
-    Serial.println("-- Default Test --"); 
-    delayTime = 1000; 
- 
-    Serial.println(); 
-} 
- 
- 
-void loop() {  
-    printValues(); 
-    delay(delayTime); 
-} 
- 
- 
-void printValues() { 
-    Serial.print("Temperature = "); 
-    Serial.print(bme.readTemperature()); 
-    Serial.println(" °C"); 
- 
-    Serial.print("Pressure = "); 
- 
-    Serial.print(bme.readPressure() / 100.0F); 
-    Serial.println(" hPa"); 
- 
-    Serial.print("Approx. Altitude = "); 
-    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); 
-    Serial.println(" m"); 
- 
-    Serial.print("Humidity = "); 
-    Serial.print(bme.readHumidity()); 
-    Serial.println(" %"); 
- 
-    Serial.println(); 
-} 
-</code> 
esp32_bme280_w_arduino_ide.1741295150.txt.gz · Last modified: 2025/03/06 21:05 by bruno