summaryrefslogtreecommitdiff
path: root/esp/src
diff options
context:
space:
mode:
Diffstat (limited to 'esp/src')
-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
5 files changed, 90 insertions, 0 deletions
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;
+}