Änderung 2023-05-04
Temperartur Koreckturfakor eingeführt.
This commit is contained in:
parent
ec9927f8f1
commit
9a20ff2825
|
@ -9,6 +9,7 @@
|
||||||
// Eppingem 195 m über NN
|
// Eppingem 195 m über NN
|
||||||
|
|
||||||
Adafruit_BMP280 bmp; // I2C
|
Adafruit_BMP280 bmp; // I2C
|
||||||
|
float K_BMP280 = -1.30;
|
||||||
|
|
||||||
bool F_BMP280;
|
bool F_BMP280;
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ void read_BMP_280() {
|
||||||
|
|
||||||
Serial.print("Temperature (BMP280):\t");
|
Serial.print("Temperature (BMP280):\t");
|
||||||
float t = bmp.readTemperature();
|
float t = bmp.readTemperature();
|
||||||
|
t = t + K_BMP280;
|
||||||
dtostrf(t,7,1,BMP280Data.temperature);
|
dtostrf(t,7,1,BMP280Data.temperature);
|
||||||
Serial.print(BMP280Data.temperature);
|
Serial.print(BMP280Data.temperature);
|
||||||
Serial.println(" °C");
|
Serial.println(" °C");
|
||||||
|
|
|
@ -12,10 +12,9 @@ float getBattery(float kor = 1.000)
|
||||||
return 3.05;
|
return 3.05;
|
||||||
#endif
|
#endif
|
||||||
float valA0 = analogRead(A0);
|
float valA0 = analogRead(A0);
|
||||||
valA0 = valA0 * 5.7; // (R1 + r1 + r2) / r2
|
valA0 = valA0 * 3.7; // (R1 + r1 + r2) / r2
|
||||||
// R1= Vorwiderstand 100k,
|
|
||||||
// r1 und r2 Spannungsteiler
|
// r1 und r2 Spannungsteiler
|
||||||
// r1 = 220k, r2 = 100k
|
// r1 = 270k, r2 = 100k
|
||||||
// Spannungsbereich = 5.2 Volt
|
// Spannungsbereich = 5.2 Volt
|
||||||
valA0= valA0 / 1024;
|
valA0= valA0 / 1024;
|
||||||
valA0 = valA0 * kor;
|
valA0 = valA0 * kor;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
||||||
|
|
||||||
bool F_HTU_21D;
|
bool F_HTU_21D;
|
||||||
|
float K_HTU= -1.30;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char temperature[15] = {0};
|
char temperature[15] = {0};
|
||||||
|
@ -24,6 +25,7 @@ void init_HTU21(){
|
||||||
|
|
||||||
void read_HTU21D() {
|
void read_HTU21D() {
|
||||||
float t = htu.readTemperature();
|
float t = htu.readTemperature();
|
||||||
|
t = t + K_HTU;
|
||||||
dtostrf(t,7,1,htuData.temperature);
|
dtostrf(t,7,1,htuData.temperature);
|
||||||
float h = htu.readHumidity();
|
float h = htu.readHumidity();
|
||||||
dtostrf(h,7,1,htuData.humity);
|
dtostrf(h,7,1,htuData.humity);
|
||||||
|
|
35
src/main.cpp
35
src/main.cpp
|
@ -86,18 +86,22 @@ void setup() {
|
||||||
WiFi.forceSleepBegin();
|
WiFi.forceSleepBegin();
|
||||||
pulse_pin(TRIGGER_PIN); // ==> 1
|
pulse_pin(TRIGGER_PIN); // ==> 1
|
||||||
Serial.println();
|
Serial.println();
|
||||||
if (!LittleFS.begin()) {
|
//Serial.println("Testpunkt 1");
|
||||||
|
/* if (!LittleFS.begin()) {
|
||||||
Serial.println("LittleFS mount failed");
|
Serial.println("LittleFS mount failed");
|
||||||
|
delay(5000);
|
||||||
return;
|
return;
|
||||||
}
|
} */
|
||||||
Dir dir = LittleFS.openDir("/data");
|
//Serial.println("Testpunkt 2");
|
||||||
|
/* Dir dir = LittleFS.openDir("/data");
|
||||||
while (dir.next()) {
|
while (dir.next()) {
|
||||||
Serial.print(dir.fileName());
|
Serial.print(dir.fileName());
|
||||||
if(dir.fileSize()) {
|
if(dir.fileSize()) {
|
||||||
File f = dir.openFile("r");
|
File f = dir.openFile("r");
|
||||||
Serial.println(f.size());
|
Serial.println(f.size());
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
//Serial.println("Testpunkt 3");
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
@ -105,16 +109,16 @@ void setup() {
|
||||||
//korectur = readKorectur();
|
//korectur = readKorectur();
|
||||||
//Serial.print("Korektur: "); Serial.println(korectur,6);
|
//Serial.print("Korektur: "); Serial.println(korectur,6);
|
||||||
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
|
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
|
||||||
digitalWrite(BUILTIN_LED, LOW);
|
//digitalWrite(BUILTIN_LED, LOW);
|
||||||
//digitalWrite(BUILTIN_LED, HIGH);
|
//digitalWrite(BUILTIN_LED, HIGH);
|
||||||
//Serial.print("STATUS (Systemmeldung): "); Serial.println(SystemStatus);
|
//Serial.print("STATUS (Systemmeldung): "); Serial.println(SystemStatus);
|
||||||
#if (MQTT == 0)
|
#if (MQTT == 0)
|
||||||
init_HTU21();
|
init_HTU21();
|
||||||
Init_BMP280();
|
Init_BMP280();
|
||||||
initADS();
|
//initADS();
|
||||||
init_MCP9808();
|
//init_MCP9808();
|
||||||
#endif
|
#endif
|
||||||
//AKKU = getBattery(korectur); // ca. 170 ms
|
AKKU = getBattery(korectur); // ca. 170 ms
|
||||||
// ca. 280 ms
|
// ca. 280 ms
|
||||||
if (F_HTU_21D == true){
|
if (F_HTU_21D == true){
|
||||||
read_HTU21D();
|
read_HTU21D();
|
||||||
|
@ -125,7 +129,7 @@ void setup() {
|
||||||
// ca. 12ms
|
// ca. 12ms
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// Status ändern !!! 0
|
// Status ändern !!! 0
|
||||||
datenSave(0);
|
//datenSave(0);
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
//digitalWrite(BUILTIN_LED, HIGH);
|
//digitalWrite(BUILTIN_LED, HIGH);
|
||||||
deviceId = ESP.getChipId();
|
deviceId = ESP.getChipId();
|
||||||
|
@ -151,24 +155,15 @@ void loop() {
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
read_HTU21D();
|
read_HTU21D();
|
||||||
read_BMP_280();
|
read_BMP_280();
|
||||||
valTemp = getTemperature_MCP9808();
|
//valTemp = getTemperature_MCP9808();
|
||||||
#if(NOADS== 1)
|
dtostrf(AKKU,8,2,ADSData.Akku);
|
||||||
MessungADS();
|
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/battery" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/battery" );
|
||||||
client.publish(topic, ADSData.Akku, true);
|
client.publish(topic, ADSData.Akku, true);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/solar" );
|
|
||||||
client.publish(topic, ADSData.Solar, true);
|
|
||||||
#endif
|
|
||||||
#if(MQTT == 0)
|
#if(MQTT == 0)
|
||||||
M2M_HTU21D(hostname.c_str());
|
M2M_HTU21D(hostname.c_str());
|
||||||
M2M_BMP280(hostname.c_str());
|
M2M_BMP280(hostname.c_str());
|
||||||
M2M_Temperatur_MCP9808(hostname.c_str());
|
M2M_Temperatur_MCP9808(hostname.c_str());
|
||||||
#endif
|
#endif
|
||||||
#if(NOBATT == 0)
|
|
||||||
AKKU = atof(ADSData.Akku);
|
|
||||||
#else
|
|
||||||
AKKU = 2.95;
|
|
||||||
#endif
|
|
||||||
long int Feldstaerke = WiFi.RSSI();
|
long int Feldstaerke = WiFi.RSSI();
|
||||||
sprintf(msg,"%ld", Feldstaerke);
|
sprintf(msg,"%ld", Feldstaerke);
|
||||||
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );
|
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user