okay das ist dann mal was wenn ich zu viel zeit hab.
Werd dann mal ein Foto machen wenns fertig verbaut ist
das ist ja alles schön und gut aber tut’s nicht einfach ein ausgedientes Tablet mit 'ner eigenem Webfront. Da kann man doch alles problemlos sichtbar machen.
Es sei denn der Basteltrieb muss befriedigt werden
Ich finde einfach solche Displays viel schöner.
Kann man in etwa vergleichen mit einem alten Flipper. Man kann natürlich auch auf dem PC Flippern, aber das ist einfach nicht das gleiche
sehr schön, bis auf die Kabel. Die musst du noch besser verlegen: das Auge isst mit
oder eine Blende davor
Ne ne soll ja Transparent sein Also nix mit Blende
Kabel schau ich mir am Wochenende nochmal an
Hat was von einer Skulptur.
Wenn man sowas mag, nicht schlecht.
schöne grüße
bb
Ich habe jetzt noch das Problem das sich scheinbar das wlan nicht wieder verbindet.
Wenn die Wifi Verbindung kurz unterbrochen ist hängt alles und nur ein Neustart schafft Abhilfe.
Kannst du mir sagen wie ich das fixe?
Kann der esp32 eigentlich auch wpa3?
#include <WiFi.h>
#include <PubSubClient.h>
#include <Wire.h> // This library is already built in to the Arduino IDE
#include <LiquidCrystal_I2C.h> //This library you can add via Include Library > Manage Library >
LiquidCrystal_I2C oled_pverzeugung(0x20, 16, 2);
LiquidCrystal_I2C oled_verbrauch(0x21, 20, 4);
LiquidCrystal_I2C oled_einspeisung(0x22, 16, 2);
LiquidCrystal_I2C oled_bezug(0x23, 16, 2);
LiquidCrystal_I2C oled_akkuzustand(0x24, 16, 2);
LiquidCrystal_I2C oled_akkuladung(0x25, 16, 2);
LiquidCrystal_I2C oled_akkuentladung(0x26, 16, 2);
// Update these with values suitable for your network.
const char* ssid = "....";//put your own wifi ssid here
const char* password = "......";// put your wifi password here
const char* mqtt_server = "192.168.115.7";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
void setup_wifi() {
delay(100);
// We start by connecting to a WiFi network
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
//#################################################################################
void callback(char* topic, byte* payload, unsigned int length)
{
Serial.print("Command from MQTT broker is : ");
Serial.print(topic);
Serial.println();
Serial.print(" publish data is:");
//##########################
if ( !strncmp (topic, "pverzeugung", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_pverzeugung.clear();
oled_pverzeugung.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_pverzeugung.print((char)payload[i]);
}
if (isChar)
{
oled_pverzeugung.setCursor(0, 0);
oled_pverzeugung.print("PV Erzeugung");
}
}
//######################
if ( !strncmp (topic, "verbrauch", sizeof(topic)) )
{
oled_verbrauch.setCursor(0, 0);
oled_verbrauch.print(" ");
oled_verbrauch.setCursor(0, 0);
for (byte i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
oled_verbrauch.print((char)payload[i]);
}
}
if ( !strncmp (topic, "ogverbrauch", sizeof(topic)) )
{
oled_verbrauch.setCursor(0, 1);
oled_verbrauch.print(" ");
oled_verbrauch.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
oled_verbrauch.print((char)payload[i]);
}
}
if ( !strncmp (topic, "egverbrauch", sizeof(topic)) )
{
;
oled_verbrauch.setCursor(0, 2);
oled_verbrauch.print(" ");
oled_verbrauch.setCursor(0, 2);
for (byte i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
oled_verbrauch.print((char)payload[i]);
}
}
if ( !strncmp (topic, "ugverbrauch", sizeof(topic)) )
{
oled_verbrauch.setCursor(0, 3);
oled_verbrauch.print(" ");
oled_verbrauch.setCursor(0, 3);
for (byte i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
oled_verbrauch.print((char)payload[i]);
}
}
//##########################
if ( !strncmp (topic, "einspeisung", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_einspeisung.clear();
//oled_einspeisung.noBacklight(); // Turn off the LCD backlight
oled_einspeisung.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_einspeisung.print((char)payload[i]);
}
if (isChar)
{
oled_einspeisung.setCursor(0, 0);
oled_einspeisung.print("Einspeisung");
// oled_einspeisung.backlight(); // Enable or Turn On LCD the backlight
}
}
//##########################
if ( !strncmp (topic, "bezug", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_bezug.clear();
oled_bezug.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_bezug.print((char)payload[i]);
}
if (isChar)
{
oled_bezug.setCursor(0, 0);
oled_bezug.print("Bezug");
}
}
//#########################
if ( !strncmp (topic, "akkuzustand", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_akkuzustand.clear();
oled_akkuzustand.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_akkuzustand.print((char)payload[i]);
}
if (isChar)
{
oled_akkuzustand.setCursor(0, 0);
oled_akkuzustand.print("Akkuzustand");
}
}
//#########################
if ( !strncmp (topic, "ladungakku", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_akkuladung.clear();
oled_akkuladung.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_akkuladung.print((char)payload[i]);
}
if (isChar)
{
oled_akkuladung.setCursor(0, 0);
oled_akkuladung.print("Akkuladung");
}
}
//##############
if ( !strncmp (topic, "entladungakku", sizeof(topic)) ) // http://www.cplusplus.com/reference/cstring/strncmp/
{
bool isChar = false;
oled_akkuentladung.clear();
oled_akkuentladung.setCursor(0, 1);
for (byte i = 0; i < length; i++)
{
if (isPrintable((char)payload[i]))
isChar = true;
Serial.print((char)payload[i]);
oled_akkuentladung.print((char)payload[i]);
}
if (isChar)
{
oled_akkuentladung.setCursor(0, 0);
oled_akkuentladung.print("Akkuentladung");
}
}
//#####################
// Serial.println();
}
//#########################
//end callback
void reconnect() {
// Loop until we're reconnected
while (!client.connected())
{
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
//if you MQTT broker has clientID,username and password
//please change following line to if (client.connect(clientId,userName,passWord))
if (client.connect(clientId.c_str()))
{
Serial.println("connected");
//once connected to MQTT broker, subscribe command if any
client.subscribe("pverzeugung");
client.subscribe("verbrauch");
client.subscribe("ogverbrauch");
client.subscribe("egverbrauch");
client.subscribe("ugverbrauch");
client.subscribe("einspeisung");
client.subscribe("bezug");
client.subscribe("akkuzustand");
client.subscribe("ladungakku");
client.subscribe("entladungakku");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 6 seconds before retrying
delay(6000);
}
}
} //end reconnect()
//###################################################
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
oled_pverzeugung.init(); // initializing the LCD
//oled_pverzeugung.backlight(); // Enable or Turn On the backlight
oled_verbrauch.init(); // initializing the LCD
oled_einspeisung.init(); // initializing the LCD
oled_bezug.init(); // initializing the LCD
oled_akkuzustand.init(); // initializing the LCD
oled_akkuladung.init(); // initializing the LCD
oled_akkuentladung.init(); // initializing the LCD
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.setCallback(callback);
client.loop();
}
kann keiner helfen?
Hab was zu reconnect gefunden aber keine Ahnung wo ich das einbauen muss