summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--esp/AS5600.ino47
-rw-r--r--esp/BH1750.ino21
-rw-r--r--esp/BMP280.ino29
-rw-r--r--esp/DHT11.ino26
-rw-r--r--esp/LM393.ino42
-rw-r--r--esp/include/as5600.h0
-rw-r--r--esp/include/bh1750.h0
-rw-r--r--esp/include/bmp280.h0
-rw-r--r--esp/include/dht11.h0
-rw-r--r--esp/include/lm393.h0
-rw-r--r--esp/src/as5600.cpp0
-rw-r--r--esp/src/bh1750.cpp0
-rw-r--r--esp/src/bmp280.cpp0
-rw-r--r--esp/src/dht11.cpp0
-rw-r--r--esp/src/estacao_principal.ino39
-rw-r--r--esp/src/lm393.cpp0
16 files changed, 39 insertions, 165 deletions
diff --git a/esp/AS5600.ino b/esp/AS5600.ino
deleted file mode 100644
index 233aa13..0000000
--- a/esp/AS5600.ino
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <Wire.h>
-
-#define AS5600_ADDR 0x36 // endereço I2C do AS5600
-#define RAW_ANGLE_REG 0x0C
-
-unsigned long lastTime = 0;
-
-String direcaoCardinal(float angulo) {
- if (angulo >= 337.5 || angulo < 22.5) return "Norte";
- else if (angulo < 67.5) return "Nordeste";
- else if (angulo < 112.5) return "Leste";
- else if (angulo < 157.5) return "Sudeste";
- else if (angulo < 202.5) return "Sul";
- else if (angulo < 247.5) return "Sudoeste";
- else if (angulo < 292.5) return "Oeste";
- else return "Noroeste";
-}
-
-uint16_t readRawAngle() {
- Wire.beginTransmission(AS5600_ADDR);
- Wire.write(RAW_ANGLE_REG);
- Wire.endTransmission();
- Wire.requestFrom(AS5600_ADDR, 2);
- uint16_t high = Wire.read();
- uint16_t low = Wire.read();
- return (high << 8) | low;
-}
-
-void setup() {
- Serial.begin(115200);
- Wire.begin(); // SDA e SCL padrão do ESP32 (21 e 22)
- Serial.println("Leitura do AS5600 - Direcao do Vento");
-}
-
-void loop() {
- uint16_t raw = readRawAngle();
- // O AS5600 fornece 12 bits (0–4095) para 0–360°
- float angulo = (raw & 0x0FFF) * 360.0 / 4096.0;
-
- if (millis() - lastTime >= 1000) {
- Serial.print("Angulo: ");
- Serial.print(angulo, 2);
- Serial.print("° | Direcao: ");
- Serial.println(direcaoCardinal(angulo));
- lastTime = millis();
- }
-}
diff --git a/esp/BH1750.ino b/esp/BH1750.ino
deleted file mode 100644
index 9d4f9c9..0000000
--- a/esp/BH1750.ino
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <Wire.h>
-#include <BH1750.h>
-
-BH1750 lightMeter;
-
-void setup(){
- Serial.begin(115200);
- Wire.begin(21, 22);
- lightMeter.begin();
- Serial.println("Teste sensor luminosidade");
-}
-void loop(){
- float lux =
- lightMeter.readLightLevel();
-
- Serial.print("Luminosidade: ");
- Serial.print(lux);
- Serial.println(" lux");
-
- delay(1000);
-} \ No newline at end of file
diff --git a/esp/BMP280.ino b/esp/BMP280.ino
deleted file mode 100644
index 417edb1..0000000
--- a/esp/BMP280.ino
+++ /dev/null
@@ -1,29 +0,0 @@
-#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
diff --git a/esp/DHT11.ino b/esp/DHT11.ino
deleted file mode 100644
index e0f0342..0000000
--- a/esp/DHT11.ino
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "DHT.h"
-#define DHTPIN 32
-#define DHTTYPE DHT11
-
-DHT dht(DHTPIN, DHTTYPE);
-
-void setup() {
- Serial.begin(115200);
- dht.begin();
- Serial.println("Teste sensor DHT11 Temperatura e humidade");
-}
-void loop(){
- float h = dht.readHumidity();
- float t = dht.readTemperature();
-
- if (isnan(h) || isnan(t)){
- Serial.println("ERRO de leitura");
- return;
- }
- Serial.print("Humidade: ");
- Serial.print(h);
- Serial.print("% | Temperatura:");
- Serial.print(t);
- Serial.println(" °C");
- delay(2000);
-} \ No newline at end of file
diff --git a/esp/LM393.ino b/esp/LM393.ino
deleted file mode 100644
index 6e6a5d5..0000000
--- a/esp/LM393.ino
+++ /dev/null
@@ -1,42 +0,0 @@
-#define SENSOR_PIN 35 // pino de sinal (DO)
-
-unsigned long lastTime = 0;
-unsigned int pulsos = 0;
-int estadoAnterior = HIGH; // começa em HIGH (sem interrupção)
-
-// Configurações do sensor
-const int PULSOS_POR_VOLTA = 10; // 10 furos = 10 pulsos por volta
-const float FATOR_KMH = 2.4; // km/h por rotação por segundo (ajuste conforme calibração)
-
-void setup() {
- Serial.begin(115200);
- pinMode(SENSOR_PIN, INPUT);
- Serial.println("Anemômetro LM393 - Velocidade do vento");
-}
-
-void loop() {
- int estadoAtual = digitalRead(SENSOR_PIN);
-
- // Detecta borda de descida: HIGH → LOW
- if (estadoAnterior == HIGH && estadoAtual == LOW) {
- pulsos++;
- }
-
- estadoAnterior = estadoAtual; // atualiza para próxima leitura
-
- // A cada 1 segundo calcula RPM e velocidade
- if (millis() - lastTime >= 1000) {
- float rps = (float)pulsos / PULSOS_POR_VOLTA;
- float rpm = rps * 60.0;
- float velocidade = rps * FATOR_KMH;
-
- Serial.print("RPM: ");
- Serial.print(rpm);
- Serial.print(" | Velocidade: ");
- Serial.print(velocidade);
- Serial.println(" km/h");
-
- pulsos = 0;
- lastTime = millis();
- }
-} \ No newline at end of file
diff --git a/esp/include/as5600.h b/esp/include/as5600.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/include/as5600.h
diff --git a/esp/include/bh1750.h b/esp/include/bh1750.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/include/bh1750.h
diff --git a/esp/include/bmp280.h b/esp/include/bmp280.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/include/bmp280.h
diff --git a/esp/include/dht11.h b/esp/include/dht11.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/include/dht11.h
diff --git a/esp/include/lm393.h b/esp/include/lm393.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/include/lm393.h
diff --git a/esp/src/as5600.cpp b/esp/src/as5600.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/src/as5600.cpp
diff --git a/esp/src/bh1750.cpp b/esp/src/bh1750.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/src/bh1750.cpp
diff --git a/esp/src/bmp280.cpp b/esp/src/bmp280.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/src/bmp280.cpp
diff --git a/esp/src/dht11.cpp b/esp/src/dht11.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/src/dht11.cpp
diff --git a/esp/src/estacao_principal.ino b/esp/src/estacao_principal.ino
new file mode 100644
index 0000000..65f155c
--- /dev/null
+++ b/esp/src/estacao_principal.ino
@@ -0,0 +1,39 @@
+#include <Wire.h>
+#include "dht11.h"
+#include "bh1750.h"
+#include "bmp280.h"
+#include "lm393.h"
+#include "as5600.h"
+
+void setup() {
+ Serial.begin(115200);
+ Wire.begin(21, 22); // SDA, SCL
+
+ setupDHT11();
+ setupBH1750();
+ setupBMP280();
+ setupLM393();
+ setupAS5600();
+
+ Serial.println("Estacao iniciada");
+}
+
+void loop() {
+ float tempDHT = lerTemperaturaDHT11();
+ float umid = lerUmidadeDHT11();
+ float lux = lerBH1750();
+ float tempBMP = lerTemperaturaBMP280();
+ float press = lerPressaoBMP280();
+ int pulsos = lerLM393();
+ float angulo = lerAS5600();
+
+ Serial.println("----");
+ Serial.print("Umid: "); Serial.print(umid); Serial.println(" %");
+ Serial.print("Temp DHT: "); Serial.print(tempDHT); Serial.println(" C");
+ Serial.print("Temp BMP: "); Serial.print(tempBMP); Serial.println(" C");
+ Serial.print("Pressao: "); Serial.print(press); Serial.println(" hPa");
+ Serial.print("Lux: "); Serial.print(lux); Serial.println(" lx");
+ Serial.print("Pulsos: "); Serial.println(pulsos);
+ Serial.print("Angulo: "); Serial.println(angulo);
+ delay(30000);
+}
diff --git a/esp/src/lm393.cpp b/esp/src/lm393.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/esp/src/lm393.cpp