   Serial.print("PASS: ");
   Serial.println(epass);  
   
-   if (wifiConnected())
-   {
-    Serial.println("");
-    Serial.println("Connected to wifi network :/ ");
-    return;
-    } 
-
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-bool wifiConnected(void) {
+  Serial.print("DHCP Enabled: ");
+  Serial.println(char(EEPROM.read(128)));
+
+  String DHCP_Enabled;
+  DHCP_Enabled = char(EEPROM.read(128));
+  if (DHCP_Enabled == "T")
+  {
+     if (wifiConnect())
+     {
+      Serial.println("");
+      Serial.println("Connected to wifi network :/ ");
+      Serial.print("IP address: ");
+      Serial.println(WiFi.localIP());
+      return;
+      } 
+  }
+  else {
+     if (wifiConnectDHCP())
+     {
+      Serial.println("");
+      Serial.println("Connected to wifi network :/ ");
+      Serial.print("IP address: ");
+      Serial.println(WiFi.localIP());
+      return;
+      } 
+  }
+  
+
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////
+bool wifiConnect(void) {
   WiFi.mode(WIFI_STA);
   int c = 0;
   if ( esid.length() > 1 ) {

  Serial.begin(115200);
  EEPROM.begin(512);
  //pinMode(0, INPUT);
  pinMode(4, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH); //Turn off
  WiFi.begin();
  delay(1000);
  Serial.println("");
  Serial.println("delay done");
  Serial.println(digitalRead(4));

  //If button is pressed on power up then start access point for config
  if (digitalRead(4)==false)
  { 
    Serial.println("button pressed at beginning");
    delay(250);
    if (digitalRead(4)==false)
      {
        setupAP();
      }

  connect2Wifi();

  //If wifi is not connected start access point for config
  if(!wifiConnect())
  {
    digitalWrite(LED_BUILTIN, LOW); //Turn on
    setupAP();
