Änderung 2023-05-04

Temperartur Koreckturfakor eingeführt.
This commit is contained in:
hans-jurgen 2023-05-14 15:28:36 +02:00
parent ec9927f8f1
commit 9a20ff2825
4 changed files with 21 additions and 23 deletions

View File

@ -9,6 +9,7 @@
// Eppingem 195 m über NN
Adafruit_BMP280 bmp; // I2C
float K_BMP280 = -1.30;
bool F_BMP280;
@ -47,6 +48,7 @@ void read_BMP_280() {
Serial.print("Temperature (BMP280):\t");
float t = bmp.readTemperature();
t = t + K_BMP280;
dtostrf(t,7,1,BMP280Data.temperature);
Serial.print(BMP280Data.temperature);
Serial.println(" °C");

View File

@ -12,10 +12,9 @@ float getBattery(float kor = 1.000)
return 3.05;
#endif
float valA0 = analogRead(A0);
valA0 = valA0 * 5.7; // (R1 + r1 + r2) / r2
// R1= Vorwiderstand 100k,
valA0 = valA0 * 3.7; // (R1 + r1 + r2) / r2
// r1 und r2 Spannungsteiler
// r1 = 220k, r2 = 100k
// r1 = 270k, r2 = 100k
// Spannungsbereich = 5.2 Volt
valA0= valA0 / 1024;
valA0 = valA0 * kor;

View File

@ -6,6 +6,7 @@
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
bool F_HTU_21D;
float K_HTU= -1.30;
struct {
char temperature[15] = {0};
@ -24,6 +25,7 @@ void init_HTU21(){
void read_HTU21D() {
float t = htu.readTemperature();
t = t + K_HTU;
dtostrf(t,7,1,htuData.temperature);
float h = htu.readHumidity();
dtostrf(h,7,1,htuData.humity);

View File

@ -86,18 +86,22 @@ void setup() {
WiFi.forceSleepBegin();
pulse_pin(TRIGGER_PIN); // ==> 1
Serial.println();
if (!LittleFS.begin()) {
//Serial.println("Testpunkt 1");
/* if (!LittleFS.begin()) {
Serial.println("LittleFS mount failed");
delay(5000);
return;
}
Dir dir = LittleFS.openDir("/data");
} */
//Serial.println("Testpunkt 2");
/* Dir dir = LittleFS.openDir("/data");
while (dir.next()) {
Serial.print(dir.fileName());
if(dir.fileSize()) {
File f = dir.openFile("r");
Serial.println(f.size());
}
}
} */
//Serial.println("Testpunkt 3");
Serial.println();
Serial.println();
Serial.println();
@ -105,16 +109,16 @@ void setup() {
//korectur = readKorectur();
//Serial.print("Korektur: "); Serial.println(korectur,6);
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
digitalWrite(BUILTIN_LED, LOW);
//digitalWrite(BUILTIN_LED, LOW);
//digitalWrite(BUILTIN_LED, HIGH);
//Serial.print("STATUS (Systemmeldung): "); Serial.println(SystemStatus);
#if (MQTT == 0)
init_HTU21();
Init_BMP280();
initADS();
init_MCP9808();
//initADS();
//init_MCP9808();
#endif
//AKKU = getBattery(korectur); // ca. 170 ms
AKKU = getBattery(korectur); // ca. 170 ms
// ca. 280 ms
if (F_HTU_21D == true){
read_HTU21D();
@ -125,7 +129,7 @@ void setup() {
// ca. 12ms
// ---------------------------------
// Status ändern !!! 0
datenSave(0);
//datenSave(0);
// ---------------------------------
//digitalWrite(BUILTIN_LED, HIGH);
deviceId = ESP.getChipId();
@ -151,24 +155,15 @@ void loop() {
previousMillis = currentMillis;
read_HTU21D();
read_BMP_280();
valTemp = getTemperature_MCP9808();
#if(NOADS== 1)
MessungADS();
//valTemp = getTemperature_MCP9808();
dtostrf(AKKU,8,2,ADSData.Akku);
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/battery" );
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)
M2M_HTU21D(hostname.c_str());
M2M_BMP280(hostname.c_str());
M2M_Temperatur_MCP9808(hostname.c_str());
#endif
#if(NOBATT == 0)
AKKU = atof(ADSData.Akku);
#else
AKKU = 2.95;
#endif
long int Feldstaerke = WiFi.RSSI();
sprintf(msg,"%ld", Feldstaerke);
sprintf(topic, "%s%s%s", "hjk/devices/", hostname.c_str(), "/telemetry/RSSI" );