   Serial.println(" mV");
   Serial.print("switch status: ");
   Serial.println(digitalRead(MAGNETIC_SWITCH_PIN) == HIGH);
-  Serial.println(" *******************");
+  Serial.println("*******************");
   Serial.println("");
   Serial.println(" Enter a new devide id (press enter for no change):");
+  delay(500);
   while (Serial.available() == 0)
     /* just wait */ ;
-  int new_device_number = Serial.read();
-  if (new_device_number != -1) {
-    g_device_number = new_device_number;
-    EEPROM.write(EE_DEVICE_NUMBER, g_device_number);
-    Serial.println("New sensor id: ");
-    Serial.println(g_device_number);
+  String new_device_number = Serial.readStringUntil(13);
+  if (new_device_number) {
+    new_device_number.trim();
+    if (new_device_number.length() != 0) {
+      g_device_number = new_device_number.toInt();
+      EEPROM.write(EE_DEVICE_NUMBER, g_device_number);
+      Serial.println("New sensor id: ");
+      Serial.println(g_device_number);
+    }
   }
+  // Reset the interrupt switch
+  g_interrupt_id = NO_INTERRUPT;
+
   // Exiting DIAG mode
   digitalWrite(LED_PIN, LOW);
 }

    }
    packet >>= 1;
  }
  Serial.print(g_device_number);
  // Send packet
  rfDevice.send(codeWord1);
  rfDevice.send(codeWord2);

}

// Print a diagnostic report on the serial line and ask for a new device number
void diagnostic() {
  // Entering DIAG mode
  digitalWrite(LED_PIN, HIGH);

  Serial.println("");
  Serial.println("*** DIAG report ***");
  Serial.print("type of device: ");
  Serial.println(DOOR_SENSOR);
  Serial.print("device id: ");
