 
 void setup() {
   // put your setup code here, to run once:
+  // Init Serial
+  Serial.begin(115200);
+  delay(100);
+  Serial.println("Serial init...");
   // Init Display
+  Serial.println("Display init...");
   display.init();
   display.flipScreenVertically();
   display.setFont(ArialMT_Plain_10);
+  display.clear();
   display.setTextAlignment(TEXT_ALIGN_LEFT);
+  display.setFont(ArialMT_Plain_16);
+  display.drawString(0, 0, "Hallo Jan");
+  display.setFont(ArialMT_Plain_16);
+  display.drawString(0, 16, "es klappt");
+  display.setFont(ArialMT_Plain_16);
+  display.drawString(0, 32, "Juhuuuu");
+  display.setFont(ArialMT_Plain_16);
+  display.drawString(0, 48, "Zeile 4");
+
+  display.display();
   // Init WIFI
+  Serial.println("Wifi init...");
   initWiFi();
   // Init MQTT
+  Serial.println("MQTT init...");
   client.setServer(mqttServer, mqttPort);
   client.setCallback(callback);
+  Serial.print("Connecting...");
+  char data[13];
+  sprintf(data, "Panel-%.2x%.2x%.2x", mac[3], mac[4], mac[5]);
   while (!client.connected()) {
-     if (client.connect(mqttDeviceName + mac[3] + mac[4] + mac[5], mqttUser, mqttPassword )) {
-     } else {
-       delay(1000);
-     }
+    if (client.connect(data, mqttUser, mqttPassword )) {
+    } else {
+      Serial.print(".");
+      delay(500);
+    }
   }
+  Serial.println("");
+  Serial.println("Subscribing...");
   client.subscribe("test");
+  client.publish("esp32", data);
   // Init Rotary
-  encoder1.AddRotaryCounter(ROTARY_ID1, 10, -100, 100, 1, true );
-  encoder1.SetRotary(ROTARY_ID1);
-  encoder1.SetChanged(ROTARY_ID1); // This way we can force an update the first time through
+  Serial.println("Encoder init...");
+  pinMode(interruptPin1, INPUT_PULLUP);
+  attachInterrupt(digitalPinToInterrupt(interruptPin1), int_25, CHANGE);
+  pinMode(interruptPin2, INPUT_PULLUP);
+  attachInterrupt(digitalPinToInterrupt(interruptPin2), int_26, CHANGE);
+  pinMode(interruptPin3, INPUT_PULLUP);
+  attachInterrupt(digitalPinToInterrupt(interruptPin3), int_2, CHANGE);
   // Init IR
-  rem1.begin(17,1);
-  rem2.begin(16,1);
+  Serial.println("IR init...");
+  rem1.begin(17, 1);
+  rem2.begin(16, 1);
+  Serial.println("Loop init...");
 }
 
 void loop() {

// WIFI Client Lib
#include <ssl_client.h>
#include <WiFiClientSecure.h>
// MQTT Lib
#include <PubSubClient.h>
// OLED Display
#include <OLEDDisplay.h>
#include <OLEDDisplayFonts.h>
#include <OLEDDisplayUi.h>
#include <SSD1306.h>
#include <SSD1306Wire.h>
// include IR Lib
#include <esp32_rmt.h>
// Rotary Encoder Lib
#include <ky-040.h>

//-------- Customise these values -----------
const char* ssid = "uberssid";
const char* password = "securewlanpass";
const char* mqttServer = "mqtt.server.local";
const int   mqttPort = 8883;
const char* mqttUser = "mqttuserName";
const char* mqttPassword = "mqttpassw0rd";
const char* mqttDeviceName = "Panel-";
byte mac[6];

// Initialize the OLED display using Wire library
SSD1306  display(0x3c, 5, 4);

// Init MQTT
PubSubClient client(mqttServer, mqttPort, wifiClientSecure);
// Init Encoder
byte interruptPin1 = 25;
byte interruptPin2 = 26;
byte interruptPin3 = 36;
volatile byte state = LOW;

// Init IR
ESP32_RMT rem1, rem2;
