summaryrefslogtreecommitdiff
path: root/esp/BMP280.ino
diff options
context:
space:
mode:
authorGustavoeklund01 <eklundgu@gmail.com>2025-10-19 20:54:33 -0300
committerGustavoeklund01 <eklundgu@gmail.com>2025-10-19 20:54:33 -0300
commit15827f74f1ce8d428d3c3bb7f6eaf4e245cdad42 (patch)
tree0cc02cbb4f68fc4bcac824631b4aac8daaf41dce /esp/BMP280.ino
parent72bc657b9647f9dd679015d60956b9bc9a3289f5 (diff)
mais sensores
Diffstat (limited to 'esp/BMP280.ino')
-rw-r--r--esp/BMP280.ino29
1 files changed, 29 insertions, 0 deletions
diff --git a/esp/BMP280.ino b/esp/BMP280.ino
new file mode 100644
index 0000000..417edb1
--- /dev/null
+++ b/esp/BMP280.ino
@@ -0,0 +1,29 @@
+#include <Wire.h>
+#include <Adafruit_Sensor.h>
+#include <Adafruit_BMP280.h>
+
+Adafruit_BMP280 bmp; // cria o objeto do sensor
+
+void setup() {
+ Serial.begin(115200);
+ Wire.begin(21, 22); // SDA e SCL
+ Serial.println("Teste do Sensor BMP280 - Pressão e Temperatura");
+
+ if (!bmp.begin(0x76)) { // endereço I2C padrão
+ Serial.println("Erro: BMP280 não encontrado!");
+ while (1);
+ }
+}
+
+void loop() {
+ float temp = bmp.readTemperature();
+ float press = bmp.readPressure() / 100.0F; // converte Pa para hPa
+
+ Serial.print("Temperatura: ");
+ Serial.print(temp);
+ Serial.print(" °C | Pressão: ");
+ Serial.print(press);
+ Serial.println(" hPa");
+
+ delay(2000); // leitura a cada 2 segundos
+} \ No newline at end of file