summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--esp/include/as5600.h3
-rw-r--r--esp/include/bh1750.h3
-rw-r--r--esp/include/bmp280.h4
-rw-r--r--esp/include/dht11.h4
-rw-r--r--esp/include/lm393.h3
-rw-r--r--esp/src/as5600.cpp13
-rw-r--r--esp/src/bh1750.cpp13
-rw-r--r--esp/src/bmp280.cpp20
-rw-r--r--esp/src/dht11.cpp18
-rw-r--r--esp/src/lm393.cpp26
10 files changed, 107 insertions, 0 deletions
diff --git a/esp/include/as5600.h b/esp/include/as5600.h
index e69de29..059ae01 100644
--- a/esp/include/as5600.h
+++ b/esp/include/as5600.h
@@ -0,0 +1,3 @@
+#pragma once
+void setupAS5600();
+float lerAS5600();
diff --git a/esp/include/bh1750.h b/esp/include/bh1750.h
index e69de29..289d82a 100644
--- a/esp/include/bh1750.h
+++ b/esp/include/bh1750.h
@@ -0,0 +1,3 @@
+#pragma once
+void setupBH1750();
+float lerBH1750();
diff --git a/esp/include/bmp280.h b/esp/include/bmp280.h
index e69de29..43ae83e 100644
--- a/esp/include/bmp280.h
+++ b/esp/include/bmp280.h
@@ -0,0 +1,4 @@
+#pragma once
+void setupBMP280();
+float lerTemperaturaBMP280();
+float lerPressaoBMP280();
diff --git a/esp/include/dht11.h b/esp/include/dht11.h
index e69de29..84af67f 100644
--- a/esp/include/dht11.h
+++ b/esp/include/dht11.h
@@ -0,0 +1,4 @@
+#pragma once
+void setupDHT11();
+float lerTemperaturaDHT11();
+float lerUmidadeDHT11();
diff --git a/esp/include/lm393.h b/esp/include/lm393.h
index e69de29..2b8d983 100644
--- a/esp/include/lm393.h
+++ b/esp/include/lm393.h
@@ -0,0 +1,3 @@
+#pragma once
+void setupLM393();
+int lerLM393();
diff --git a/esp/src/as5600.cpp b/esp/src/as5600.cpp
index e69de29..1dfdb71 100644
--- a/esp/src/as5600.cpp
+++ b/esp/src/as5600.cpp
@@ -0,0 +1,13 @@
+#include <Wire.h>
+#include <AS5600.h>
+#include "as5600.h"
+
+AS5600 as5600;
+
+void setupAS5600() {
+ as5600.begin(21, 22);
+}
+
+float lerAS5600() {
+ return as5600.readAngle();
+}
diff --git a/esp/src/bh1750.cpp b/esp/src/bh1750.cpp
index e69de29..196705c 100644
--- a/esp/src/bh1750.cpp
+++ b/esp/src/bh1750.cpp
@@ -0,0 +1,13 @@
+#include <Wire.h>
+#include <BH1750.h>
+#include "bh1750.h"
+
+BH1750 lightMeter;
+
+void setupBH1750() {
+ lightMeter.begin();
+}
+
+float lerBH1750() {
+ return lightMeter.readLightLevel();
+}
diff --git a/esp/src/bmp280.cpp b/esp/src/bmp280.cpp
index e69de29..0ba749a 100644
--- a/esp/src/bmp280.cpp
+++ b/esp/src/bmp280.cpp
@@ -0,0 +1,20 @@
+#include <Wire.h>
+#include <Adafruit_BMP280.h>
+#include "bmp280.h"
+
+Adafruit_BMP280 bmp;
+
+void setupBMP280() {
+ if (!bmp.begin(0x76)) {
+ Serial.println("BMP280 nao achado");
+ while (1);
+ }
+}
+
+float lerTemperaturaBMP280() {
+ return bmp.readTemperature();
+}
+
+float lerPressaoBMP280() {
+ return bmp.readPressure() / 100.0F;
+}
diff --git a/esp/src/dht11.cpp b/esp/src/dht11.cpp
index e69de29..9900363 100644
--- a/esp/src/dht11.cpp
+++ b/esp/src/dht11.cpp
@@ -0,0 +1,18 @@
+#include "DHT.h"
+#include "dht11.h"
+
+#define DHTPIN 32
+#define DHTTYPE DHT11
+DHT dht(DHTPIN, DHTTYPE);
+
+void setupDHT11() {
+ dht.begin();
+}
+
+float lerTemperaturaDHT11() {
+ return dht.readTemperature();
+}
+
+float lerUmidadeDHT11() {
+ return dht.readHumidity();
+}
diff --git a/esp/src/lm393.cpp b/esp/src/lm393.cpp
index e69de29..5eb4bdf 100644
--- a/esp/src/lm393.cpp
+++ b/esp/src/lm393.cpp
@@ -0,0 +1,26 @@
+#include <Arduino.h>
+#include "lm393.h"
+
+#define SENSOR_PIN 32 // ou 35 se preferir
+
+void setupLM393() {
+ pinMode(SENSOR_PIN, INPUT);
+}
+
+int lerLM393() {
+ static int contagem = 0;
+ static unsigned long lastTime = 0;
+
+ if (digitalRead(SENSOR_PIN) == LOW) {
+ contagem++;
+ delay(10);
+ }
+
+ if (millis() - lastTime >= 1000) {
+ int pulsos = contagem;
+ contagem = 0;
+ lastTime = millis();
+ return pulsos;
+ }
+ return 0;
+}