Merge branch 'tempsensor' into 'master'

Tempsensor

See merge request lukas/pumpensteuerung!1
This commit is contained in:
Lukas Heiligenbrunner 2020-08-22 10:36:01 +00:00
commit 7e1dc425c4
4 changed files with 60 additions and 1 deletions

View File

@ -12,3 +12,8 @@
platform = espressif8266 platform = espressif8266
board = esp07 board = esp07
framework = arduino framework = arduino
lib_deps =
SPI
Wire
DHT sensor library

33
src/Temperature.cpp Normal file
View File

@ -0,0 +1,33 @@
//
// Created by lukas on 22.08.20.
//
#include "Temperature.h"
void Temperature::init() {
dht.begin();
}
double Temperature::getTemp() {
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
return -1;
}
else {
return event.temperature;
}
}
double Temperature::getHum() {
sensors_event_t event;
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
return -1;
}
else {
return event.relative_humidity;
}
}

21
src/Temperature.h Normal file
View File

@ -0,0 +1,21 @@
//
// Created by lukas on 22.08.20.
//
#pragma once
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
class Temperature {
public:
Temperature(): dht(4, DHT22){};
void init();
double getTemp();
double getHum();
private:
DHT_Unified dht;
};

View File

@ -4,7 +4,7 @@
#include "WifiManager.h" #include "WifiManager.h"
#define VERSION "v1.0" #define VERSION "v1.1"
bool allow; bool allow;
bool error = false; bool error = false;