2025-11-1301
This commit is contained in:
@@ -8,15 +8,16 @@
|
|||||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||||
|
|
||||||
const float No_Val = 999.99;
|
const float No_Val = 999.99;
|
||||||
float Temp = No_Val;
|
|
||||||
float Feuchte = No_Val;
|
|
||||||
float L_Druck = No_Val;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char temperature[15] = {0};
|
char temperature[15] = {0};
|
||||||
char pressure[15] = {0};
|
char pressure[15] = {0};
|
||||||
char approx_altitud[15] = {0};
|
char approx_altitud[15] = {0};
|
||||||
char humity[15] = {0};
|
char humity[15] = {0};
|
||||||
|
float Temp = No_Val;
|
||||||
|
float Feuchte = No_Val;
|
||||||
|
float L_Druck = No_Val;
|
||||||
} BME280Data;
|
} BME280Data;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,13 +42,13 @@ void Init_BME280() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Read_BME280(){
|
void Read_BME280(){
|
||||||
Temp = bme.readTemperature();
|
BME280Data.Temp = bme.readTemperature();
|
||||||
Temp = Temp + BME_Korrectur;
|
BME280Data.Temp = BME280Data.Temp + BME_Korrectur;
|
||||||
L_Druck = bme.readPressure();
|
BME280Data.L_Druck = bme.readPressure();
|
||||||
L_Druck = L_Druck + KorrekturLuftdruck;
|
BME280Data.L_Druck = BME280Data.L_Druck + KorrekturLuftdruck;
|
||||||
Feuchte = bme.readHumidity();
|
BME280Data.Feuchte = bme.readHumidity();
|
||||||
Feuchte = Feuchte + KorrekturFeuchte;
|
BME280Data.Feuchte = BME280Data.Feuchte + BME_KorrekturFeuchte;
|
||||||
Serial.printf("BME 280: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", Temp, Feuchte );
|
Serial.printf("BME 280: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", BME280Data.Temp, BME280Data.Feuchte );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
#include "Adafruit_HTU21DF.h"
|
#include "Adafruit_HTU21DF.h"
|
||||||
|
|
||||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
const float No_Valhtu = 999.99;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char temperature[15] = {0};
|
char temperature[15] = {0};
|
||||||
char humity[15] = {0};
|
char humity[15] = {0};
|
||||||
} htuData;
|
float Temp = No_Valhtu;
|
||||||
|
float Feuchte = No_Valhtu;
|
||||||
|
} htu21Data;
|
||||||
|
|
||||||
|
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
||||||
|
|
||||||
|
|
||||||
void init_HTU21(){
|
void init_HTU21(){
|
||||||
if (!htu.begin()) {
|
if (!htu.begin()) {
|
||||||
@@ -16,17 +21,8 @@ void init_HTU21(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void read_HTU21D() {
|
void read_HTU21D() {
|
||||||
float t = htu.readTemperature();
|
htu21Data.Temp = htu.readTemperature();
|
||||||
dtostrf(t,10,4,htuData.temperature);
|
htu21Data.Feuchte = htu.readHumidity();
|
||||||
float h = htu.readHumidity();
|
htu21Data.Temp = htu21Data.Temp + HTU_Korrectur;
|
||||||
dtostrf(h,8,2,htuData.humity);
|
htu21Data.Feuchte = htu21Data.Feuchte + HTUKorrekturFeuchte;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void M2M_HTU21D(long deviceId = 4711) {
|
|
||||||
char topic[100];
|
|
||||||
sprintf(topic, "%s%ld%s", "hjk/devices/", deviceId, "/telemetry/temperature_Htu_21" );
|
|
||||||
client.publish(topic, htuData.temperature, true);
|
|
||||||
sprintf(topic, "%s%ld%s", "hjk/devices/", deviceId, "/telemetry/humity" );
|
|
||||||
client.publish(topic, htuData.humity, true);
|
|
||||||
Serial.printf("HTU21:\t\t %s °C\n", htuData.temperature);
|
|
||||||
Serial.printf("HTU21:\t\t %s %% \n", htuData.humity); */
|
|
||||||
@@ -48,7 +48,8 @@ build_flags = ${env.build_flags}
|
|||||||
-DHTU_Korrectur=0.00
|
-DHTU_Korrectur=0.00
|
||||||
-DBME_Korrectur=-2.30
|
-DBME_Korrectur=-2.30
|
||||||
-DKorrekturLuftdruck=0.00
|
-DKorrekturLuftdruck=0.00
|
||||||
-DKorrekturFeuchte=0.00
|
-DHTUKorrekturFeuchte=0.00
|
||||||
|
-DBME_KorrekturFeuchte=0.00
|
||||||
-DAKKU_GREZWERT=2.90
|
-DAKKU_GREZWERT=2.90
|
||||||
|
|
||||||
|
|
||||||
@@ -60,11 +61,12 @@ build_flags = ${env.build_flags}
|
|||||||
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION2/telemetry/pressure\"
|
-DLUFTDRUCK=\"hjk/devices/WETTERSTATION2/telemetry/pressure\"
|
||||||
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION2/telemetry/humity\"
|
-DFEUCHTIGKEIT=\"hjk/devices/WETTERSTATION2/telemetry/humity\"
|
||||||
-DHELL=\"hjk/devices/WETTERSTATION/telemetry/Lux\"
|
-DHELL=\"hjk/devices/WETTERSTATION/telemetry/Lux\"
|
||||||
-DHTU_Korrectur=-0.75
|
-DHTU_Korrectur=-0.55
|
||||||
-DBME_Korrectur=-0.00
|
-DBME_Korrectur=-0.00
|
||||||
-DKorrekturLuftdruck=0.00
|
-DKorrekturLuftdruck=0.00
|
||||||
-DKorrekturFeuchte=0.00
|
-DHTUKorrekturFeuchte=0.00
|
||||||
-DAKKU_GREZWERT=3.00
|
-DBME_KorrekturFeuchte=0.00
|
||||||
|
-DAKKU_GREZWERT=3.60
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
140
src/main.cpp
140
src/main.cpp
@@ -20,7 +20,7 @@
|
|||||||
#include <Adafruit_HTU21DF.h>
|
#include <Adafruit_HTU21DF.h>
|
||||||
|
|
||||||
#include <mess_BME280.h>
|
#include <mess_BME280.h>
|
||||||
|
#include <mess_HTU21D.h>
|
||||||
|
|
||||||
// Pins for LED MATRIX
|
// Pins for LED MATRIX
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -75,8 +75,6 @@ unsigned long endTime;
|
|||||||
#define mqtt_port 61883
|
#define mqtt_port 61883
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
PubSubClient client(espClient);
|
PubSubClient client(espClient);
|
||||||
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define matrix_width 64
|
#define matrix_width 64
|
||||||
@@ -163,7 +161,7 @@ float FeuchteInnen = 0.00;
|
|||||||
float TemparaturInnen = 0.00;
|
float TemparaturInnen = 0.00;
|
||||||
bool NOHTU = false;
|
bool NOHTU = false;
|
||||||
bool readHtuFlag = true;
|
bool readHtuFlag = true;
|
||||||
float akku = 2.87;
|
float akku = 5.00;
|
||||||
int Helligkeit = 255;
|
int Helligkeit = 255;
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +201,6 @@ void ZeigeTemperatur(float Temperatur, uint16_t Color);
|
|||||||
|
|
||||||
void ZeigeInnenFeuchtigkeit(float Luftfeuchtigkeit);
|
void ZeigeInnenFeuchtigkeit(float Luftfeuchtigkeit);
|
||||||
void ZeigeLuftdruck(float Pressure);
|
void ZeigeLuftdruck(float Pressure);
|
||||||
void readHtu();
|
|
||||||
void AkkuAlarm();
|
void AkkuAlarm();
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@@ -652,18 +649,6 @@ void BlinkSec(bool blink){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void readHtu(){
|
|
||||||
if (!NOHTU){
|
|
||||||
FeuchteInnen = htu.readHumidity();
|
|
||||||
TemparaturInnen = htu.readTemperature();
|
|
||||||
TemparaturInnen = TemparaturInnen + HTU_Korrectur;
|
|
||||||
Serial.printf("Htu21D: Temperarur Innen %3.2f °C und\n Luftfeuchtigkeit %3.2f %%\n\n", TemparaturInnen, FeuchteInnen );
|
|
||||||
}else{
|
|
||||||
FeuchteInnen = 20.00;
|
|
||||||
TemparaturInnen = 30.00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
{
|
{
|
||||||
display.setCursor(1, 40);
|
display.setCursor(1, 40);
|
||||||
@@ -682,7 +667,7 @@ void setup() {
|
|||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
}
|
}
|
||||||
readHtu();
|
read_HTU21D();
|
||||||
Init_BME280();
|
Init_BME280();
|
||||||
delay(5000);
|
delay(5000);
|
||||||
WiFi.mode( WIFI_OFF );
|
WiFi.mode( WIFI_OFF );
|
||||||
@@ -694,62 +679,16 @@ void setup() {
|
|||||||
|
|
||||||
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
|
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
|
||||||
display.begin(16); // Rows-scan pattern 1/32
|
display.begin(16); // Rows-scan pattern 1/32
|
||||||
//display.begin(8, 14, 13, 12, 4);
|
|
||||||
|
|
||||||
// Define multiplex implemention here {BINARY, STRAIGHT} (default is BINARY)
|
|
||||||
//display.setMuxPattern(BINARY);
|
|
||||||
|
|
||||||
// Set the multiplex pattern {LINE, ZIGZAG,ZZAGG, ZAGGIZ, WZAGZIG, VZAG, ZAGZIG} (default is LINE)
|
|
||||||
// display.setScanPattern(LINE);
|
|
||||||
|
|
||||||
|
|
||||||
// Rotate display
|
|
||||||
//display.setRotate(true);
|
|
||||||
|
|
||||||
// Flip display
|
|
||||||
//display.setFlip(true);
|
|
||||||
|
|
||||||
// Control the minimum color values that result in an active pixel
|
|
||||||
//display.setColorOffset(5, 5,5);
|
|
||||||
|
|
||||||
// Set the multiplex implemention {BINARY, STRAIGHT} (default is BINARY)
|
|
||||||
//display.setMuxPattern(BINARY);
|
|
||||||
|
|
||||||
// Set the color order {RRGGBB, RRBBGG, GGRRBB, GGBBRR, BBRRGG, BBGGRR} (default is RRGGBB)
|
// Set the color order {RRGGBB, RRBBGG, GGRRBB, GGBBRR, BBRRGG, BBGGRR} (default is RRGGBB)
|
||||||
display.setColorOrder(RRBBGG);
|
display.setColorOrder(RRBBGG);
|
||||||
|
|
||||||
// Set the time in microseconds that we pause after selecting each mux channel
|
|
||||||
// (May help if some rows are missing / the mux chip is too slow)
|
|
||||||
//display.setMuxDelay(0,1,0,0,0);
|
|
||||||
|
|
||||||
// Set the number of panels that make up the display area width (default is 1)
|
|
||||||
//display.setPanelsWidth(2);
|
|
||||||
|
|
||||||
// Set the brightness of the panels (default is 255)
|
// Set the brightness of the panels (default is 255)
|
||||||
//display.setBrightness(50);
|
//display.setBrightness(50);
|
||||||
display.setBrightness(255);
|
display.setBrightness(255);
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
// Set driver chip type
|
|
||||||
//display.setDriverChip(FM6124);
|
|
||||||
|
|
||||||
display.setTextColor(myRED);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.print("Pixel");
|
|
||||||
display.setTextColor(myGREEN);
|
|
||||||
display.setCursor(30,0);
|
|
||||||
display.print("Time");
|
|
||||||
//----------------------
|
|
||||||
/* display.setTextColor(myBLUE);
|
|
||||||
display.setCursor(2,50);
|
|
||||||
display.print("Pixel");
|
|
||||||
display.setTextColor(myYELLOW);
|
|
||||||
display.setCursor(30,50);
|
|
||||||
display.print("Time"); */
|
|
||||||
display_update_enable(true);
|
display_update_enable(true);
|
||||||
//delay(5000);
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//--------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
print_wifi_status();
|
print_wifi_status();
|
||||||
configTime(0, 0, NTP_SERVER);
|
configTime(0, 0, NTP_SERVER);
|
||||||
@@ -786,12 +725,6 @@ void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t
|
|||||||
// Asuming 5 pixel average character width
|
// Asuming 5 pixel average character width
|
||||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
|
||||||
{
|
{
|
||||||
// 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))
|
if (millis() - lastTime >= (1000 - scroll_delay))
|
||||||
{
|
{
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
@@ -820,40 +753,6 @@ 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)
|
|
||||||
{
|
|
||||||
uint16_t text_length = text.length();
|
|
||||||
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setRotation(0);
|
|
||||||
display.setTextColor(display.color565(colorR,colorG,colorB));
|
|
||||||
|
|
||||||
// Asuming 5 pixel average character width
|
|
||||||
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*10); xpos--)
|
|
||||||
{
|
|
||||||
if (millis() - lastTime >= 1000)
|
|
||||||
{
|
|
||||||
lastTime = millis();
|
|
||||||
blinkSek = !blinkSek;
|
|
||||||
}
|
|
||||||
if (blinkSek && blink) {
|
|
||||||
display.fillRect(4 + 27, ypos - 3, 5, 5, myWHITE);
|
|
||||||
display.fillRect(4 + 27, ypos + 1, 5, 5, myWHITE);
|
|
||||||
}else{
|
|
||||||
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();
|
|
||||||
display.fillRect(xpos, ypos, 64-xpos, 16, (myBLACK));
|
|
||||||
display.setCursor(xpos,ypos);
|
|
||||||
display.println(text);
|
|
||||||
delay(scroll_delay);
|
|
||||||
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)
|
void scroll_Grad(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() +2;
|
uint16_t text_length = text.length() +2;
|
||||||
@@ -904,9 +803,6 @@ static void setup_wifi() {
|
|||||||
|
|
||||||
//WiFi.forceSleepWake();
|
//WiFi.forceSleepWake();
|
||||||
delay( 1 );
|
delay( 1 );
|
||||||
/* WiFi.persistent( false );
|
|
||||||
WiFi.setHostname(hostname.c_str()); //define hostname
|
|
||||||
WiFi.mode( WIFI_STA ); */
|
|
||||||
WiFi.config( ip, gateway, subnet, dns1, dns2);
|
WiFi.config( ip, gateway, subnet, dns1, dns2);
|
||||||
|
|
||||||
WiFi.begin(ssid, pass);
|
WiFi.begin(ssid, pass);
|
||||||
@@ -926,19 +822,6 @@ static void setup_wifi() {
|
|||||||
Serial.print("IP address: \t");
|
Serial.print("IP address: \t");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
/* Serial.begin(115200);
|
|
||||||
Serial.print("Connecting to: ");
|
|
||||||
Serial.println(ssid);
|
|
||||||
WiFi.begin(ssid, pass);
|
|
||||||
|
|
||||||
while(WiFi.status() != WL_CONNECTED){
|
|
||||||
delay(500);
|
|
||||||
Serial.print(".");
|
|
||||||
}
|
|
||||||
Serial.println("");
|
|
||||||
Serial.println("WiFi connected");
|
|
||||||
Serial.print("IP-Address of ESP8266 module: ");
|
|
||||||
Serial.println(WiFi.localIP()); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -949,8 +832,6 @@ void loop() {
|
|||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
//client.loop();
|
|
||||||
|
|
||||||
getNTPtime(10);
|
getNTPtime(10);
|
||||||
|
|
||||||
|
|
||||||
@@ -969,9 +850,10 @@ void loop() {
|
|||||||
{
|
{
|
||||||
if (readHtuFlag == true)
|
if (readHtuFlag == true)
|
||||||
{
|
{
|
||||||
readHtu();
|
read_HTU21D();
|
||||||
Read_BME280();
|
Read_BME280();
|
||||||
readHtuFlag = false;
|
readHtuFlag = false;
|
||||||
|
Serial.printf(" HTU: %3.2f\t\t %3.2f\n\n", htu21Data.Temp, BME280Data.Temp);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
readHtuFlag = true;
|
readHtuFlag = true;
|
||||||
@@ -981,15 +863,13 @@ void loop() {
|
|||||||
{
|
{
|
||||||
case 0 ... 14:
|
case 0 ... 14:
|
||||||
{
|
{
|
||||||
//ZeigeInnenTemp(TemparaturInnen);
|
ZeigeTemperatur(htu21Data.Temp, myGREEN);
|
||||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
ZeigeInnenFeuchtigkeit(htu21Data.Feuchte);
|
||||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
|
||||||
ZeigeInnenCO(Co2);
|
ZeigeInnenCO(Co2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 15 ... 29:
|
case 15 ... 29:
|
||||||
{
|
{
|
||||||
//ZeigeAussenTemp(Aussentemp);
|
|
||||||
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
||||||
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
||||||
ZeigeLuftdruck(Pressure);
|
ZeigeLuftdruck(Pressure);
|
||||||
@@ -997,14 +877,13 @@ void loop() {
|
|||||||
}
|
}
|
||||||
case 30 ... 44:
|
case 30 ... 44:
|
||||||
{
|
{
|
||||||
ZeigeTemperatur(TemparaturInnen, myGREEN);
|
ZeigeTemperatur(htu21Data.Temp, myGREEN);
|
||||||
ZeigeInnenFeuchtigkeit(Feuchte);
|
ZeigeInnenFeuchtigkeit(htu21Data.Feuchte);
|
||||||
ZeigeInnenCO(Co2);
|
ZeigeInnenCO(Co2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 45 ... 59:
|
case 45 ... 59:
|
||||||
{
|
{
|
||||||
//ZeigeAussenTemp(Aussentemp);
|
|
||||||
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
ZeigeTemperatur(Aussentemp, myHimmelblau);
|
||||||
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
ZeigeAussenFeuchtigkeit(Luftfeuchtigkeit);
|
||||||
ZeigeLuftdruck(Pressure);
|
ZeigeLuftdruck(Pressure);
|
||||||
@@ -1023,7 +902,6 @@ bool getNTPtime(int sec) {
|
|||||||
do {
|
do {
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
//Serial.print(".");
|
|
||||||
delay(10);
|
delay(10);
|
||||||
} while (((millis() - start) <= (1000 * sec)) && (timeinfo.tm_year < (2016 - 1900)));
|
} while (((millis() - start) <= (1000 * sec)) && (timeinfo.tm_year < (2016 - 1900)));
|
||||||
if (timeinfo.tm_year <= (2016 - 1900)) return false; // the NTP call was not successful }
|
if (timeinfo.tm_year <= (2016 - 1900)) return false; // the NTP call was not successful }
|
||||||
|
|||||||
Reference in New Issue
Block a user