2025-11-1300
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//#include <Wire.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
@@ -20,7 +20,7 @@ struct {
|
||||
} BME280Data;
|
||||
|
||||
|
||||
TwoWire I2CBME = TwoWire(1);
|
||||
//TwoWire I2CBME = TwoWire(1);
|
||||
Adafruit_BME280 bme;
|
||||
|
||||
unsigned long delayTime;
|
||||
@@ -28,13 +28,13 @@ unsigned long delayTime;
|
||||
void Init_BME280() {
|
||||
Serial.begin(115200);
|
||||
Serial.println(F("BME280 test"));
|
||||
I2CBME.begin(I2C_SDA, I2C_SCL, 100000);
|
||||
//I2CBME.begin(I2C_SDA, I2C_SCL, 100000);
|
||||
|
||||
bool status;
|
||||
|
||||
// default settings
|
||||
// (you can also pass in a Wire library object like &Wire2)
|
||||
status = bme.begin(0x76, &I2CBME);
|
||||
status = bme.begin(0x76);
|
||||
if (!status) {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
} else {Serial.println("BME280 Ok");
|
||||
@@ -46,6 +46,8 @@ void Read_BME280(){
|
||||
L_Druck = bme.readPressure();
|
||||
L_Druck = L_Druck + KorrekturLuftdruck;
|
||||
Feuchte = bme.readHumidity();
|
||||
Feuchte = Feuchte + KorrekturFeuchte;
|
||||
Serial.printf("BME 280: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", Temp, Feuchte );
|
||||
|
||||
|
||||
}
|
||||
@@ -48,19 +48,23 @@ build_flags = ${env.build_flags}
|
||||
-DHTU_Korrectur=0.00
|
||||
-DBME_Korrectur=-2.30
|
||||
-DKorrekturLuftdruck=0.00
|
||||
-DKorrekturFeuchte=0.00
|
||||
-DAKKU_GREZWERT=2.90
|
||||
|
||||
|
||||
[env:hjk] ; Sulzfeld
|
||||
build_flags = ${env.build_flags}
|
||||
-DCO2Wert=\"hjk/devices/257923/telemetry/co2\"
|
||||
-DAKKU=\"hjk/devices/WETTERSTATION/telemetry/battery\"
|
||||
-DWETTER=\"hjk/devices/WETTERSTATION/telemetry/temperature_Htu_21\"
|
||||
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION/telemetry/pressure\"
|
||||
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION/telemetry/humity\"
|
||||
-DAKKU=\"hjk/devices/WETTERSTATION2/telemetry/battery\"
|
||||
-DWETTER=\"hjk/devices/WETTERSTATION2/telemetry/temperature_Htu_21\"
|
||||
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION2/telemetry/pressure\"
|
||||
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION2/telemetry/humity\"
|
||||
-DHELL=\"hjk/devices/WETTERSTATION/telemetry/Lux\"
|
||||
-DHTU_Korrectur=0.00
|
||||
-DBME_Korrectur=-1.55
|
||||
-DHTU_Korrectur=-0.75
|
||||
-DBME_Korrectur=-0.00
|
||||
-DKorrekturLuftdruck=0.00
|
||||
-DKorrekturFeuchte=0.00
|
||||
-DAKKU_GREZWERT=3.00
|
||||
|
||||
|
||||
|
||||
|
||||
144
src/main.cpp
144
src/main.cpp
@@ -114,6 +114,9 @@ uint8_t hell = 255;
|
||||
u_int16_t StartderAbdunklung = 20;
|
||||
u_int16_t EndederAbdunklung = 7;
|
||||
|
||||
//------ Speicher für Sekunden ------
|
||||
uint8_t SekOld = 99;
|
||||
|
||||
// Wifi
|
||||
char ssid[] = "MagentaWLAN-RGDO"; // your network SSID (name)
|
||||
char pass[] = "93329248424922704583"; // your network password
|
||||
@@ -546,11 +549,11 @@ void ZeigeInnenFeuchtigkeit(float Luftfeuchtigkeit){
|
||||
void ZeigeInnenCO(int Co2){
|
||||
char szWetter[15];
|
||||
display.fillRect(0, 34-10, 64, 8, myBLACK);
|
||||
Serial.println(Co2);
|
||||
//Serial.println(Co2);
|
||||
if (Co2 > 0)
|
||||
{
|
||||
sprintf(szWetter, "%5d", Co2);
|
||||
Serial.print("CO = "); Serial.println(Co2);
|
||||
//Serial.print("CO = "); Serial.println(Co2);
|
||||
display.setFont();
|
||||
display.setCursor(1, 35-10);
|
||||
switch (Co2){
|
||||
@@ -641,11 +644,11 @@ void ZeigeLuftdruck(float Pressure){
|
||||
}
|
||||
void BlinkSec(bool blink){
|
||||
if (blink) {
|
||||
display.fillRect(32, 4, 2, 2, myGREEN);
|
||||
display.fillRect(32, 10, 2, 2, myMAGENTA);
|
||||
display.fillRect(31, 5, 2, 2, myWHITE);
|
||||
display.fillRect(31, 9, 2, 2, myWHITE);
|
||||
|
||||
}else{
|
||||
display.fillRect(32, 0, 2, 12, myBLACK);
|
||||
display.fillRect(31, 5, 2, 6, myBLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,7 +657,7 @@ void readHtu(){
|
||||
FeuchteInnen = htu.readHumidity();
|
||||
TemparaturInnen = htu.readTemperature();
|
||||
TemparaturInnen = TemparaturInnen + HTU_Korrectur;
|
||||
Serial.printf("\n\nTemperarur Innen %f °C und\nLuftfeuchtigkeit %f %%\n\n", TemparaturInnen, FeuchteInnen );
|
||||
Serial.printf("Htu21D: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", TemparaturInnen, FeuchteInnen );
|
||||
}else{
|
||||
FeuchteInnen = 20.00;
|
||||
TemparaturInnen = 30.00;
|
||||
@@ -771,6 +774,7 @@ union single_double{
|
||||
} this_single_double;
|
||||
|
||||
unsigned long last_draw=0;
|
||||
|
||||
void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
{
|
||||
uint16_t text_length = text.length();
|
||||
@@ -782,7 +786,13 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
// Asuming 5 pixel average character width
|
||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
||||
{
|
||||
if (millis() - lastTime >= 200)
|
||||
// getNTPtime(10);
|
||||
// Serial.printf ("%D %D \n",SekOld,timeinfo.tm_sec);
|
||||
// if (SekOld != timeinfo.tm_sec){
|
||||
// SekOld = timeinfo.tm_sec;
|
||||
// blinkSek = !blinkSek;
|
||||
// }
|
||||
if (millis() - lastTime >= (1000 - scroll_delay))
|
||||
{
|
||||
lastTime = millis();
|
||||
blinkSek = !blinkSek;
|
||||
@@ -792,7 +802,6 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
}
|
||||
|
||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||
//display.clearDisplay();
|
||||
display.fillRect(xpos, ypos-2, 64-xpos, 10, (myBLACK));
|
||||
display.setCursor(xpos,ypos);
|
||||
display.println(text);
|
||||
@@ -811,7 +820,7 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
/* void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
{
|
||||
uint16_t text_length = text.length();
|
||||
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
|
||||
@@ -828,11 +837,11 @@ void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
blinkSek = !blinkSek;
|
||||
}
|
||||
if (blinkSek && blink) {
|
||||
display.fillRect(4 + 27, 20 - 3, 2, 2, myMAGENTA);
|
||||
display.fillRect(4 + 27, 20 + 1, 2, 2, myMAGENTA);
|
||||
display.fillRect(4 + 27, ypos - 3, 5, 5, myWHITE);
|
||||
display.fillRect(4 + 27, ypos + 1, 5, 5, myWHITE);
|
||||
}else{
|
||||
display.fillRect(4 + 27, 20 - 3, 2, 2, myBLACK);
|
||||
display.fillRect(4 + 27, 20 + 1, 2, 2, myBLACK);
|
||||
display.fillRect(4 + 27, ypos -8, 2, 2, myYELLOW);
|
||||
display.fillRect(4 + 27, ypos +1, 2, 2, myYELLOW);
|
||||
}
|
||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
||||
//display.clearDisplay();
|
||||
@@ -843,7 +852,7 @@ void scroll_text2(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
yield();
|
||||
}
|
||||
display.setTextSize(1);
|
||||
}
|
||||
} */
|
||||
|
||||
void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB, boolean blink)
|
||||
{
|
||||
@@ -856,9 +865,8 @@ void scroll_Grad(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
||||
// Asuming 5 pixel average character width
|
||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
||||
{
|
||||
if (millis() - lastTime >= 200)
|
||||
{
|
||||
lastTime = millis();
|
||||
if (SekOld != timeinfo.tm_sec){
|
||||
SekOld = timeinfo.tm_sec;
|
||||
blinkSek = !blinkSek;
|
||||
}
|
||||
if (blink){
|
||||
@@ -935,66 +943,46 @@ static void setup_wifi() {
|
||||
|
||||
|
||||
void loop() {
|
||||
Serial1.println("Hallo Co2");
|
||||
|
||||
|
||||
if (!client.connected()) {
|
||||
reconnect();
|
||||
}
|
||||
client.loop();
|
||||
|
||||
//client.loop();
|
||||
|
||||
getNTPtime(10);
|
||||
|
||||
|
||||
if (millis() - lastTime >= 1000)
|
||||
if (SekOld != timeinfo.tm_sec)
|
||||
{
|
||||
lastTime = millis();
|
||||
SekOld = timeinfo.tm_sec;
|
||||
blinkSek = !blinkSek;
|
||||
//ZeigeTestTime(timeinfo);
|
||||
ZeigeZeit(timeinfo,1,8);
|
||||
|
||||
if (akku < 2.85)
|
||||
if (akku < AKKU_GREZWERT)
|
||||
{
|
||||
AkkuAlarm();
|
||||
}
|
||||
|
||||
/* if ((timeinfo.tm_sec % 30) == 0)
|
||||
{
|
||||
if (readCo2Flag == true) //eadCo2Flag
|
||||
{
|
||||
CO2Wert = Co2;
|
||||
Serial.print("CO = \t"); Serial.println(CO2Wert);
|
||||
readCo2Flag = false;
|
||||
}
|
||||
}else{
|
||||
readCo2Flag = true;
|
||||
} */
|
||||
|
||||
if ((timeinfo.tm_min % 2) == 0)
|
||||
{
|
||||
if (readHtuFlag == true)
|
||||
{
|
||||
readHtu();
|
||||
Read_BME280();
|
||||
readHtuFlag = false;
|
||||
}
|
||||
}else{
|
||||
readHtuFlag = true;
|
||||
}
|
||||
Read_BME280();
|
||||
/* if ((timeinfo.tm_hour >= StartderAbdunklung) && timeinfo.tm_hour < EndederAbdunklung)
|
||||
{
|
||||
display.setBrightness(dunkel);
|
||||
#ifdef HELLIGKEIT
|
||||
Serial.printf("Die Helligkeit wird von %0d Uhr bis %0d Uhr auf %00d reduziert\n", StartderAbdunklung, EndederAbdunklung, dunkel);
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
display.setBrightness(hell);
|
||||
} */
|
||||
|
||||
switch (timeinfo.tm_sec)
|
||||
{
|
||||
case 0 ... 14:
|
||||
{
|
||||
//ZeigeInnenTemp(TemparaturInnen);
|
||||
ZeigeTemperatur(Temp, myGREEN);
|
||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
||||
ZeigeInnenCO(Co2);
|
||||
break;
|
||||
@@ -1009,7 +997,7 @@ void loop() {
|
||||
}
|
||||
case 30 ... 44:
|
||||
{
|
||||
ZeigeTemperatur(Temp, myGREEN);
|
||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
||||
ZeigeInnenCO(Co2);
|
||||
break;
|
||||
@@ -1023,54 +1011,7 @@ void loop() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ZeigeLuftdruck(Pressure);
|
||||
|
||||
/* if (Aussentemp > -99.9){
|
||||
scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 30,30,30, true);
|
||||
char szWetter[10];
|
||||
dtostrf(Aussentemp, 4, 1, szWetter);
|
||||
//Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter);
|
||||
scroll_Grad(matrix_height-8,30,"Aussentemperatur: " + String(szWetter), 64,64,64, true);
|
||||
dtostrf(Luftfeuchtigkeit, 4, 1, szWetter);
|
||||
scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 48,48,48, true);
|
||||
} */
|
||||
//ZeigeZeit(timeinfo, TimeX, TimeY);
|
||||
//ZeigeZeit(timeinfo, 1,40);
|
||||
/* ZeigeCO(1,CoY);
|
||||
if ((timeinfo.tm_min % 10) == 0){
|
||||
if (Covid19 != 0){
|
||||
scroll_text(matrix_height-8,20,"Landkreis Heilbronn", 30,30,30, true);
|
||||
if (Covid19 <= 500){
|
||||
// ------------------------------------ \204 für ä
|
||||
scroll_text(matrix_height-8,25,"Covid 19 F\204lle in den letzte 7 Tage pro 100000 EW: " + String(Covid19, 1), 40,40,40, true);
|
||||
} else if (Covid19 <= 1000){
|
||||
// ------------------------------------ \204 für ä
|
||||
scroll_text(matrix_height-8,25,"Covid 19 F\204lle in den letzte 7 Tage pro 100000 EW: " + String(Covid19, 1), 64,64,0, true);
|
||||
} else {
|
||||
// ------------------------------------ \204 für ä
|
||||
scroll_text(matrix_height-8,25,"Covid 19 F\204lle in den letzte 7 Tage pro 100000 EW: " + String(Covid19, 1), 64,0,0, true);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (Aussentemp > -99.9){
|
||||
scroll_text(matrix_height-8,30,"Luftdruck: " + String(Pressure) + " hPa", 30,30,30, true);
|
||||
char szWetter[10];
|
||||
dtostrf(Aussentemp, 4, 1, szWetter);
|
||||
//Serial.print(Aussentemp); Serial.print(" "); Serial.println(szWetter);
|
||||
scroll_Grad(matrix_height-8,30,"Aussentemperatur: " + String(szWetter), 64,64,64, true);
|
||||
dtostrf(Luftfeuchtigkeit, 4, 1, szWetter);
|
||||
scroll_text(matrix_height-8,30,"Luftfeuchtigkeit: " + String(szWetter) + " %", 48,48,48, true);
|
||||
}
|
||||
}
|
||||
//scroll_text(matrix_height-16,20,"Temperatur: " + String(Wetter,1) +" °C", 128,30,30, true);
|
||||
/* scroll_text2(matrix_height-24,20,"Liebe Frunde, liebe Nachbarn,", 128,128,0, true);
|
||||
scroll_text2(matrix_height-24,20,"ich w\201nsche Euch allen ein", 128,128,0, true);
|
||||
scroll_text2(matrix_height-24,20,"Frohes neues Jahr 2022.", 128,255,0, true); */
|
||||
|
||||
//ZeigeWetter(double(FlurTemp), WetterY,WetterX);
|
||||
|
||||
}
|
||||
client.loop();
|
||||
}
|
||||
@@ -1085,14 +1026,9 @@ bool getNTPtime(int sec) {
|
||||
//Serial.print(".");
|
||||
delay(10);
|
||||
} while (((millis() - start) <= (1000 * sec)) && (timeinfo.tm_year < (2016 - 1900)));
|
||||
if (timeinfo.tm_year <= (2016 - 1900)) return false; // the NTP call was not successful
|
||||
//Serial.print("now "); Serial.println(now);
|
||||
/* char time_output[30];
|
||||
strftime(time_output, 30, "%a %d-%m-%y %T", localtime(&now));
|
||||
Serial.println(time_output);
|
||||
Serial.println(); */
|
||||
}
|
||||
if (timeinfo.tm_year <= (2016 - 1900)) return false; // the NTP call was not successful }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void showTime(tm localTime) {
|
||||
@@ -1117,6 +1053,6 @@ void AkkuAlarm()
|
||||
char szAkku[10];
|
||||
dtostrf(akku, 5, 2, szAkku);
|
||||
String myAkku = "ACHTUNG!! Akku : " + String(szAkku) + " V. Bitte aufladen!";
|
||||
scroll_text(32-8,40, myAkku, 255,0,0, true);
|
||||
scroll_text(32-7,40, myAkku, 255,0,0, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user