***SOLVED*** UNO Lagged when hooked up to ESP via serial

SOLVED* Took out the serial crap output from ESP.

My UNO tends to operate REALLY slow, lag of 0-4 seconds (alteranating) when it’s hooked up thru serial to ESP12. I pull the rx and tx and things respond quick again. I’m stumped why the thing is slowing down so much, I only am transmitting 5 bytes / sec to the ESP and the ESP is sending about at same rate.

Here is code for ESP 1/1

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "JMR";
const char* password = "crystal2965";

WiFiUDP Udp;
unsigned int localUdpPort = 8888;  // local port to listen on
char receivedChars[255];  // buffer for incoming packets
char  replyPacket[] = "Hi there! Got the message :-)";  // a reply string to send back
boolean newData;
int numChars = 255;

void setup()
{
  Serial.begin(115200);
  Serial.println();

  Serial.printf("Connecting to %s ", ssid);

  IPAddress ip(192, 168, 1, 137);
  IPAddress gw(192, 168, 1, 254);
  IPAddress dns(192, 168, 1, 254);
  IPAddress sn(255, 255, 255, 0);
  WiFi.config(ip, gw, sn, dns);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");

  Udp.begin(localUdpPort);
  Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);
}
void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;
  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    sendUDP();
    Serial.print("This just in ... ");
    Serial.println(receivedChars);
    newData = false;
  }
}
void sendUDP() {
    Udp.beginPacket("192.168.1.139", 8888);
    Udp.write(receivedChars);
    Udp.endPacket();
}
void pingOut() {
  Udp.beginPacket("192.168.1.139", 8888);
  Udp.write("ping");
  Udp.endPacket();
}

void loop() {
  recvWithEndMarker();
  showNewData();
  sendUDP();
  pingOut();
  delay(500);
}

Here is code for UNO 1/4

//*****************************************************************************************************************************************************************
// -1: InputPullup, 0: Not installed, 1: Input Positive, 2: OUTPUT
const int installed[20] = {   0,   0,     1,    -1,     -1,    -1,    -1,    2,     2,     -1,     1,     2,     2,     2,     2,     2,     -1,     2,     0,     0 };
const char* pinNames[20] = { "0", "1",    "2",  "3",   "4",   "5",   "6",   "7",   "8",   "9",   "10",  "11",  "12",  "13",  "A0",  "A1",  "A2",  "A3",  "A4",  "A5"  };
const char* ssNames[20] = {  "Rx", "Tx", "pr7", "mc7", "bo7", "dr7", "pb7", "PX7", "HO8", "c8r", "gl7", "LG8", "LR8", "RS7", "AL7", "PW7", "rd8", "LB8", "SCL", "SDA" };
const int                            pr7 = 2,              bo7 = 4,      pb7 = 6,    c8r = 9,      LG8 = 11,     RS7 = 13,     PW7 = A1,    LB8 = A3 ;
const int                                  mc7 = 3,      dr7 = 5,      PX7 = 7, HO8 = 8,    gl7 = 10,     LR8 = 12,      AL7 = A0,     rd8 = A2;
// *****************************************************************************************************************************************************************

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);


// *******




// ******

float pirActivity;
int arrMax = 20, beeps, beepLen, beepRepeat, beepRepeatS, dirc, doorOpens, doorOpenTime, doorState, entering, iPing, i, iG, iBeep, hookedUp, loops, loops2, pr8Hits, parsed, pexUnlock, powerBoostInc, target;
int redState[3], redRun[3], redIntervalOn[3], redIntervalOff[3];
int beepInterval;

long unsigned doorMS, eventTime, hertz, pexPush, beepMS, redCycle[3], pirMS, c8rTimer, runOn, runTotal, lastMillis, ESPReset;
String eventName, beepEvent;
String eventSound;

int now[20] = { 0 } ; //Set prior to parse
int was[20] = { 0 } ; //Set after parse
int distanceA[8] = { 0 };

long unsigned last[20] = { 0 }; //Millis of last trigger (state change)
long flashStop[3];

const int beepArrSize = 40; // Carefully set this, can cause corruption!

const int deBounceMS = 30; // Debounce delay
const int delayMS = 10; //Loop Delay
const int loopsMax = 5; //Secondary Loop Divider
const long unsigned noKeysDelay1 = 10000; // Delay to unlock once
const long unsigned noKeysDelay = 300000; // Delay to unlock second time
const int delayDoorOpen = 20100; // Please Close Door Delay
const int c8rTimerMax = 180123; // Time to run powerBoost
// ***********************************************************

void setup() {
  // put your setup code here, to run once:
  digitalWrite(AL7, HIGH);
  digitalWrite(PW7, HIGH);
  digitalWrite(RS7, HIGH);
  pexPush = 99999999L;
  pexUnlock = 2;
  digitalWrite(PX7, LOW);
  //flash("blue", 500, 2000, -1);

  doorMS = 999100200L;
  loops = 0;

  for (i = 0; i < arrMax; i++) {
    // Array init loop

    // Set pin-modes based on installed flags
    if (installed[i] == -1) {
      pinMode(i, INPUT_PULLUP);
    }
    if (installed[i] == 0) {
      pinMode(i, INPUT_PULLUP);
    }
    if (installed[i] == 1) {
      pinMode(i, INPUT);
    }
    if (installed[i] == 2) {
      pinMode(i, OUTPUT);
    }
  }


  if ((digitalRead(pb7) == LOW) && (digitalRead(dr7) == LOW)) hookedUp = 1;
  if (hookedUp == 0) {
    Serial.begin(115200);  // Serial flag - serial doesn't run on Project.
  }
  hookedUp = 1;
  if (hookedUp == 0) {
    eventName = "Node 7 - PC Mode.";
  }
  if (hookedUp == 1) eventName = "Node 7 - Init.";
  lcd.init();
  lcd.print(eventName);
  lcd.backlight();

  beep(1); // Start Chime

}
// **************
void beepRepeatSet() {
  //BeepRepeatSet: Add 1x000 where x is 2^(x-1) times to repeat
  char hertzA[6];
  char hertzR;
  int hertzI, hertzLen;
  itoa(hertzA, hertz, 10);
  hertzLen = strlen(hertzA);
  hertzR = hertzA[2];
  hertzI = atoi(hertzR);
  beepRepeat = 2 ^ (hertzI - 1);
  if ((hertzI < 2) || (hertzLen < 6)) beepRepeat = 0;
  Serial.println(beepRepeat);
}
void loop0() {
  // Most rapid loop. Ran in place of delays.
  //Serial.print(millis());

  flash("0", 0, 0, 0); // Cycle flashing
}

Code for UNO 2/4

void loop() {
  sp(7102);
  loops = loops + 1;

  if (loops > loopsMax) {
    loops = 0;
    loop2();
  }
  beep(0); // Cycle beeps
  //distanceCheck();
  for (i = 0; i < 20; i++) {


    /*DEBUGGING SECTION START

      lcd.backlight();
      Serial.println(i);
      lcd.clear();
      lcd.print(ssNames[i]);
      lcd.print(": ");
      char* dRead = "lo";
      if (digitalRead(i) == HIGH) dRead = "HIGH";
      lcd.print(dRead);
      delay(1500);

    */
    //DEBUGGING SECTION END

    long unsigned endMS = millis() + delayMS;
    while (millis() < endMS); {
      loop0();
    }
    //delay(delayMS);
    if (i < 20) {
      now[i] = digitalRead(i);
    }

    if (abs(installed[i]) == 1) {
      if (now[i] != was[i]) {
        //state change!
        long unsigned endMS = millis() + delayMS;
        while (millis() < endMS); {
          loop0();
        }
        if (now[i] == was[i]) {
          goto next;  //If switch back, skip down.
        }
        // DeBounce
        if ((millis() - last[i]) < deBounceMS) {
          goto next;
        }
        last[i] = millis();
        inParse(ssNames[i], 0); // Incurs Delay #3
        Serial.println(i);
      }
    }
    was[i] = now[i];
next:
    int y = 1;
  }

  if (digitalRead(dr7) == HIGH) {
    flash("green", 400, 600, 60000);
  } // Flash green when door open

  //State Checks - Lowest Priority First
  //Magnet Non-Contact Warning

  //Timers

  if ((digitalRead(mc7) == HIGH) && (digitalRead(gl7) == HIGH) && (hookedUp == 1)) { // If door is open and magnet locks...
    if ((millis() - doorMS) > delayDoorOpen) {
      eventName = "Please Close Door!";
      sp(7006);
      eventTime = millis();
      flash("green", 100, 100, 1000);
      if (digitalRead(mc7) == LOW) {
        eventName = "Door Reed MalFx";  //Magnet in contact when door is open (high) / impossible
        sp(7094);
      }
    }
  }



  //Display seconds to unlock
  lcd.setCursor(13, 0);
  unsigned int secs = (pexPush + noKeysDelay - millis()) / 1000;
  if (pexUnlock == 0) lcd.print(secs);
  if ((secs > 1) && (pexUnlock != 2)) flash("green", 200, 1000, 1000);
  if (secs == 10) { //play no-keys tone ten secs prior to unlocking.
    eventName = "NoKeys Notice";
    sp(7097);
    eventTime = millis();
    beep(1);
  }
  lcd.setCursor(0, 0);
  if (((millis() - pexPush > noKeysDelay) || (millis() - pexPush > 20000)) && (pexUnlock < 2)) {//Unlcoks at 10secs as well
    if (millis() > 300123) { //Keep from unlock loop occuring on boot
      eventName = "NoKeys Unlock Now!";
      sp(7019);
      eventTime = millis();
      pexUnlock++;
      digitalWrite(PX7, HIGH);
      delay(100);
      digitalWrite(PX7, LOW);
    }
  }
}
//* * * * * * * * * *
void loop2() {
  beepRead();
  sp(7102); //Send out a ping!
  //beep(1);
  //RESET the ESP 12E
  if ((millis() - ESPReset) > 60123L) { //Reset ESP q60s
    ESPReset = millis();
    sp(7101);
    digitalWrite(RS7, LOW);
    delay(50);
    digitalWrite(RS7, HIGH);
  }
  if (millis() - c8rTimer > c8rTimerMax) {
    digitalWrite(PW7, HIGH); //Turn PW7 back off.
    sp(7015000);
  }
  
  //Magnet Cool down (only run 6 out of every ten minutes)
  if (digitalRead(PW7) == LOW) {
    runOn = runOn + (millis() - lastMillis);
    runTotal = runTotal + (millis() - lastMillis);
  }
  else {
    runTotal = runTotal + (millis() - lastMillis);
  }
  if (runTotal > 600123L) { //if ten minutes elapsed, reset timers
    runTotal = 0;
    runOn = 0;
  }
  if (runOn > 360123L) { //Six minutes running? Turn off.
    digitalWrite(PW7, HIGH);
    sp(7098);
  }
  
  lastMillis = millis();
  // Moved from Loop to Loop2
  if ((digitalRead(mc7) == HIGH) && (digitalRead(dr7) == LOW) && (digitalRead(gl7) == HIGH)) { //If no MC (hi), door closed (low), & mag on (gl7 hi [inverse]).
    eventName = "Door Ajar!";
    sp(7003);
    eventTime = millis();
    flash("red", 100, 100, 1000);
    if (digitalRead(bo7) == HIGH)  {
      eventName = "Re-Align Magnet.";  // Bolted (hi)
      sp(7016);
    }
    beep(1);
  }
  if (digitalRead(bo7) == LOW) { // Blink when maglocked only.
    if (digitalRead(gl7 == HIGH)) {
      flash("red", 50, 1000, 800);
    }
  }
  if (digitalRead(bo7) == HIGH) { //On / flicker when bolted and maglocked.
    if (digitalRead(gl7 == HIGH)) {
      flash("red", 1000, 50, 800);
    }
  }
  if (digitalRead(gl7) == LOW) flash("green", 1000, 1, 500); //Turn on green light when green light on!

  if (eventName == "Please Close Door!") {
    beep(1);
  }
  if (digitalRead(mc7) == LOW) { //If mc7 closed and maglocked, turn off green LED
    if (digitalRead(gl7) == HIGH) {
      digitalWrite(LG8, LOW);
    }
  }


  pirActivity = constrain(pirActivity - 0.0005, 0, 10); //Lose 5 points hourly (assuming this is ran once a second)
  int flashOn = pirActivity * 100; //Blue Flash indicates kitchen area activity
  int flashOff = ((millis() - pirMS) / 6000) + 100;
  flash("blue", flashOn, flashOff, 10000);
  lcd.setCursor(0, 1);
  lcd.print((millis() - eventTime) / 1000);

  lcd.backlight();
  if (eventName != "") {
    lcd.clear();
    lcd.print(eventName);



    //if (eventName != eventName2) lcd.print(eventName2);

    eventName = "";
    lcd.setCursor(0, 0);
  }
  long unsigned endMS = millis() + 25;
  while (millis() < endMS) {
    loop0();
  }
}
// ******
void flash(String color, int intervalOn, int intervalOff, int flashStopV) {
  int colorPin;
  int i;
  /*
     Usage
     (0, 0, 0) run to cycle flashing
     ("red", 50, 100) flash on for 50ms, off for 100.
     (0, -1, -1) turn off flashing
     ("green",100,0) turns on green solid
     ("red", -1, -1) turn off red flashing
  */
  if (color == "red") i = 0;
  if (color == "green") i = 1;
  if (color == "blue") i = 2;

  if ((color == "red") || (color == "green") || (color == "blue")) { // Starting
    if (intervalOn > -1) {
      redRun[i] = 1;
      redIntervalOn[i] = intervalOn;
      redIntervalOff[i] = intervalOff;
      flashStop[i] = flashStopV + millis(); // flashStop[i] is millis + arg. speficified delay
      if (flashStopV == -1) flashStop[i] = -1; //Set flashstop to ignore -1
    }
    if (intervalOn == -1) {
      redRun[i] = 0;
    }
  }

  i = int(random(0, 3)); // Choose ONE random color to update

  if (flashStop[i] > -1) { //-1 is ignore stop flag
    if (millis() > flashStop[i]) redRun[i] = 0;
  }
  if (redRun[i] == 1) {
    if (redState[i] == LOW) {
      if (millis() - redCycle[i] > redIntervalOff[i]) {
        redState[i] = HIGH;
        redCycle[i] = millis();
      }
    } else {
      if (millis() - redCycle[i] > redIntervalOn[i]) {
        redState[i] = LOW;
        redCycle[i] = millis();
      }
    }
    switch (i) { // Set correct pin for i
      case 0: colorPin = LR8; break;
      case 1: colorPin = LG8; break;
      case 2: colorPin = LB8; break;
    }
    digitalWrite(colorPin, redState[i]);
    if (hookedUp == 0)  {
      if (redState[0] == 1) {
        lcd.backlight();
      }
      else lcd.noBacklight(); //debugging
    }
  }
  if (redRun[i] == 0) digitalWrite(colorPin, LOW);
}

Code for UNO 3/4

beep(int flag) {
  // Moved Constants here to save global RAM
  const char* aEventName[38] = { "Bolting.", "Bolting.", "Bolting.",
                                 "Door Closed",
                                 "Door Open.", "Door Open.",
                                 "Key In", "Key In", "Key In",
                                 "Door Ajar!", "Door Ajar!",
                                 "Magnet Break!", "Magnet Break!", "Magnet Break!",
                                 "Node 7 - Init.", "Node 7 - Init.", "Node 7 - Init.",
                                 "NoKeys Unlock", "NoKeys Unlock", "NoKeys Unlock",
                                 "PIR Motion",
                                 "Please Close Door!", "Please Close Door!", "Please Close Door!",
                                 "Reed 8",
                                 "UnBolting.", "UnBolting.", "UnBolting",
                                 "Warning", "Warning",
                                 "Window Alarm!", "Window Alarm", "Window Alarm", "Window Alarm"
                               };

  const long aBeepHertz[38] = { 900, 750, 500, // Bolting
                                500, // Door Closed
                                700, 550, // Door Open
                                1400, 0, 1400, // Key In
                                1260, 800, // Mag No-Contact
                                131400, 132200, 131400, // Magnet Break!
                                900, 1100, 1200, // Init
                                1000, 1150, 1300, // NoKeys
                                900, // PIR Motion
                                800, 900, 1200, // Please Close Door
                                900,           //Reed 8
                                550, 800, 1000, // Un-bolting
                                500, 400, // Warning
                                900, 1600, 900, 16600 //Window Alarm
                              }; // Units are HERTZ or 1xyyyy where x is repeat #

  const int aBeepLen[38] = { 150, 150, 200, // Bolting
                             200, // Door Closed
                             300, 500, // Door Open
                             400, 400, 600, // KeyIn
                             300, 500, // Mag No-contact
                             1500, 1700, 1500, 1700, // Magnet Break
                             200, 100, 200, //Init
                             100, 100, 400, // No Keys
                             100,           // PIR Motion
                             400, 400, 700, // Please Close Door
                             450,           //Reed 8
                             150, 150, 200, // Unbolting
                             200, 200, // "warning"
                             1500, 1700, 1500, 1700 // Window Alarm!
                           }; // Units are MILISECONDs

  int i;
  int setBeepInitialI = 0;

  // Beep II Function
  if (flag == -1) {
    noTone(HO8);
    eventSound = "";
    //eventName = "";
    return;
  } //STOP
  if (flag == 0) {
    //Check if need to continue
    if (millis() - beepMS > beepLen) {
      noTone(HO8);
      i = iBeep;
      i = i + 1;
      flag = 2;
    }
    else return;
  }
  // Continue
  if (flag == 1) {
    beepRepeatS = 0;
    setBeepInitialI = 1;
    flag = 2;
    i = 0;
    // New beep
  }

  if (flag == 2) {
    if (eventName != "") {
      eventSound = eventName;
      // if (eventSound == "Door Shove!") eventSound = "Magnet Break!"; //Tone Alias
    }
    for (i; i < beepArrSize; i++) {
      if (i == beepArrSize - 1) { //At end of I loop?
        if (beepRepeat - beepRepeatS > 0) { //Repeats left?
          i = 0;
          beepRepeatS++;
        }
      }
      if (eventSound == aEventName[i]) {
        iBeep = i;
        beepLen = aBeepLen[i];
        hertz = aBeepHertz[i];

        //beepRepeatSet(); // Determine no. times to repeat
        //if (hertz == 0) hertz = 31000; //Make blanks supersonic
        beepMS = millis();
        noTone(HO8);
        tone(HO8, hertz, beepLen);
        i = 100; //Allow exit from for loop to allow sound to continue
      }

    }
  }
}

// ******
// ******

// * Taken out to fix noise problem.
void beepRead() {

  int serRead;
  String serReadS;
  char serReadA[10];
  serRead = 0;
  if (Serial.available() > 0) serReadS = Serial.readString();
  if (serReadS == "") return;
  String trigger = serReadS.substring(0, 3);
  String dircS = serReadS.substring(3, 5);
  char dircA[3];
  dircS.toCharArray(dircA, 3);
  int dircI = atoi(dircA);
  if (abs(dircI) > 0) {
    Serial.print("InParsing trigger id: ");
    Serial.print(trigger);
    Serial.print(" with direction of (integer): ");
    Serial.println(dircI);
    inParse(trigger, dircI);
    return;
  }
  serReadS.toCharArray(serReadA, 10);
  serRead = atoi(serReadA);
  switch (serRead) {
    case 1:
      eventName = "Bolting.";
      break;
    case 2:
      eventName = "Door Closed.";
      break;
    case 3:
      eventName = "Doorbell";
      break;
    case 4:
      eventName = "Key In";
      break;
    case 5:
      eventName = "Door Ajar!";
      break;
    case 6:
      eventName = "Magnet Break!";
      break;
    case 7:
      eventName = "Node 7 - Init.";
      break;
    case 8:
      eventName = "NoKeys Unlock";
      break;
    case 9:
      eventName = "Please Close Door!";
      break;
    case 10:
      eventName = "Reed 8";
      break;
    case 11:
      eventName = "UnBolting";
      break;
    case 12:
      eventName = "Warning";
      break;
    case 13:
      eventName = "Window Alarm!";
      break;
    case 14:
      break;
    case 15:
      break;
  }
  if (serRead > 0) {
    lcd.print(serRead);
    Serial.print("Now playing: "); Serial.println(eventName);
    eventTime = millis();
    beep(1);
  }
}

Code for UNO 4/4

void inParse(String trigger, int dirc) {
  if (millis() < 5000) return; //Start-up clearance period.
  // return; //Disable when connected to PC.

  if (dirc == 0) {
    if (was[i] == 0) dirc = 1;
    else dirc = -1;
  }
  parsed = 0;
  // This function will parse input to perform function
  if ((trigger == "c8r") && (dirc == -1)) { //May be 10s delay.
    if ((digitalRead(PW7) == HIGH) && (millis() - pexPush > 5000)) {
      digitalWrite(PW7, LOW); //Turn on PowerBoost!
      c8rTimer = millis();
      sp(7015001);
    }
    eventName = "C158 Motion";
    parsed = 1;
    sp(7095);
  }
  if ((trigger == "pr7") && (dirc == 1)) {
    pirMS = millis();
    pirActivity = constrain(pirActivity + 1, 0, 10);
    sp(7021);
  }
  if ((trigger == "rd8") && (dirc == 1)) {
    Serial.print("Reed 8");
    sp(7008);
  }
  if ((((trigger == "mc7") && (dirc == 1)) || (trigger == "dr7" && dirc == 1)) && ((digitalRead(mc7) == HIGH) && (digitalRead(gl7) == HIGH) && (digitalRead(dr7) == HIGH))) { //Magnet break alarm. Door must be open, then break.
    if ((millis() - pexPush) < 60000) return; // if less than 60 seconds since pexPush, ignore.
    eventName = "Magnet Break!"; //******************** MAGNET BREAK ALARM CODE HERE *****************************
    sp(7004);  // Do NOT adjust magnet while maglocked. Tends to false alarm this. Loose mc7 wire?
    beep(1);
    parsed = 1;

    digitalWrite(AL7, LOW); // Turn on alarm relay module.

  }
  if (trigger == "gl7" && dirc == -1) { // Green Light on!
    //See if PEX button was pressed recently
    entering = 0;
    digitalWrite(PW7, HIGH); //Turn off powerBoost so door can open!
    if ((millis() - pexPush) > 1000) {
      flash("green", 500, 100, 5000);
      if (hookedUp == 1) { //nuisances when bench-testing
        eventName = "Key In";
        entering = 1;
        sp(7018);
        beep(1);
      }
      pexUnlock = 2; // Will not unlock again if entering.
    }
    pexPush = millis(); //Magnet break wrok-around.
    if (digitalRead(bo7) == HIGH) { //If key/pex but bolted.
      if (hookedUp == 1) { //nuisances when bench-testing
        eventName = "Warning";
        beep(1);
      }
    }
    parsed = 1;
  }

  if (trigger == "pb7" && dirc == 1) {
    pexPush = millis();
    pexUnlock = 0;
    entering = 0;
    eventName = "PEX Pushed.";
    sp(7017);
    if (digitalRead(PW7) == LOW) {
      digitalWrite(PW7, HIGH);
      sp(7015000);
    } //Turn off powerBoost
    parsed = 1;
    flash("green", 1000, 100, 5000);
    flash("red", -1, -1, 0);
  }
  if (trigger == "gl7" && dirc == 1 && hookedUp == 1) { // Green Light off! Doesn't trigger on PC mode.
    digitalWrite(LG8, LOW);
    eventName = "Maglocked";
    sp(7007);
    parsed = 1;
  }
  if (trigger == "dr7" && dirc == -1) { // Door Close dr7 doesn't seem to get thru, try mc7
    eventName = "Door Closed";
    doorMS = 999100200L;
    doorState = 0;
    sp(7002);
    if (digitalRead(PW7) == HIGH) {
      digitalWrite(PW7, LOW); //Turn on powerBoost when door closing.
      c8rTimer = millis();
      sp(7015001);
    }
    flash("green", 200, 1000, 30000);
    flash("red", -1, -1, 0);
    parsed = 1;
    beep(-1); //STOP Beeping
  }
  if (trigger == "dr7" && dirc == 1) { // Door opens!
    if (doorState == 1) {
      eventName = "Door Re-Open Error";
      sp(7096);
    }
    else {
      doorState = 1;
      doorMS = millis(); //Set timer for door open alarm
      eventName = "Door Open.";
      sp(7001);
      parsed = 1;
      beep(1);
      doorOpens = millis();
    }
  }
  if (trigger == "bo7" && dirc == 1) {
    eventName = "Bolting.";
    parsed = 1;
    sp(7009);
    beep(1);
    pexUnlock = 2;
    digitalWrite(PW7, LOW); //Turn on powerBoost
  }
  if (trigger == "bo7" && dirc == -1) {
    eventName = "UnBolting.";
    sp(7010);
    beep(1);
    parsed = 1;
    digitalWrite(PW7, HIGH); //Turn off powerBoost
  }
  if (parsed == 1) {

    eventTime = millis();
    lcd.clear();
    lcd.print(eventName);
  }
  if (parsed == 0) {
  }
}

void sp(long number) { //Serial Print - for sending status information
  Serial.println("");
  Serial.println(number);
}