 int average = 0;
 
 WiFiClient wifiClient;
-PubSubClient client(server, 1883, callback, wifiClient);
+PubSubClient client(mqtt_server, 1883, callback, wifiClient);
 
 long lastReconnectAttempt = 0;
+long calcIrmsmillis = 0;
 
 void wifi_connect() {
   // WIFI
-  if (EVENT_PRINT) {
+  if (DEBUG_PRINT) {
     Serial.println();
     Serial.println();
     Serial.print("Connecting to ");

        Serial.print(client.state());
      }
      unsigned long now = millis();
      //      if (now - lastReconnectAttempt > 5000) {
      if (now - lastReconnectAttempt > 1000) {
        lastReconnectAttempt = now;
        if (reconnect()) {

    oldrevMills = revMills ;
  }

  //ArduinoOTA.handle();
  client.loop();
  //delay(500);
}

void sendmqttMsg(char* topictosend, String payloadtosend)
{

  if (client.connected()) {
    if (DEBUG_PRINT) {
      Serial.print("Sending payload: ");
      Serial.print(payloadtosend);
    }
    unsigned int msg_length = payloadtosend.length();
    if (DEBUG_PRINT) {
      Serial.print(" length: ");
      Serial.println(msg_length);
    }
