title: How to change arduino esp8266-01 it's wifi SSID and password through firebase and php?
body: <p><strong><em>I'm setting up The wifi SSID and Password of arduino specifically the esp-01 to be change by sending data (SSID &amp; Password) to firebase then to PHP and to arduino</em></strong> </p>
  
  <p>I tried many possible solutions and read articles that are related to what I wanted to be the result but none of it works</p>
  
  <p>I am using an app to send data to firebase</p>
  
  <p>Given the code for both Arduino and PHP (firebase)</p>
  
  <blockquote>
    <p><strong>Arduino code</strong></p>
  </blockquote>
  
  <pre><code>    #include &lt;SoftwareSerial.h&gt;
     #include &lt;DHT.h&gt;;
      SoftwareSerial Serial1(10, 11);
     #define Trash "Trash3"
     #define DHTTYPE DHT11
     #define DHTPIN 2
     #define TRIGGER_PIN 4
     #define ECHO_PIN 3
  
      DHT dht(DHTPIN, DHTTYPE, 11);
  
      float humidity, temp_f;
      int distance;
      long duration;
  
       String buff(64);
       String getStr(128);
  
      void setup() {
  
       Serial.begin(9600);
       Serial1.begin(9600);
      delay(2000);
       Serial1.setTimeout(5000);
      dht.begin();
       pinMode(TRIGGER_PIN, OUTPUT);
      pinMode(ECHO_PIN, INPUT);
  
       if (!connectWiFi()) {
      Serial.println("Can not connect to the WiFi.");
       while (true);
      }
      Serial.println("OK, Connected to WiFi.");
  
       sendCommand("AT+CIPSTA?");
      sendCommand("AT+CIPSTAMAC?");}
  
       void loop() {
  
      temp_f = dht.readTemperature();
       humidity = dht.readHumidity();
      digitalWrite(TRIGGER_PIN, LOW);
       delayMicroseconds(2);
      digitalWrite(TRIGGER_PIN, HIGH);
       delayMicroseconds(10);
      digitalWrite(TRIGGER_PIN, LOW);
  
       duration = pulseIn(ECHO_PIN, HIGH);
      distance = duration * 0.034 / 2;
  
       if (sendCommand("AT+CIPSTART=\"TCP\",\"gg.com\",80")) {
      Serial.println("connected to Cloud");
  
       getStr = "GET /upload.php?trash=";
      getStr += Trash;
       getStr += "&amp;distance=";
      getStr += distance;
       getStr += "&amp;temp_f=";
      getStr += temp_f;
       getStr += "&amp;humidity=";
      getStr += humidity;
       getStr += " HTTP/1.1\r\n";
      getStr += "Host: gg.com\r\n\r\n";
  
      buff = "AT+CIPSEND=";
       buff += getStr.length();
      if (sendCommand(buff.c_str()) &amp;&amp; Serial1.find("&gt;")) { 
  
        Serial.println(getStr);
        Serial1.print(getStr);
        if (Serial1.find("+IPD,")) { 
          int l = Serial1.parseInt();
          while (l &gt; 0) {
            if (Serial1.available()) {
              Serial.write(Serial1.read());
              l--;
            }
          }
          Serial.println("--------------");
        } else {
          Serial.println("no response");
        }
       } else {
        Serial.println("send error");
       }
        sendCommand("AT+CIPCLOSE");
       } else {
        Serial.println("Error connecting");
       }
        }
  
       bool connectWiFi() {
  
         if (!sendCommand("ATE0")) // echo off
       return false;
         if (!sendCommand("AT+CIPMUX=0")) // set single connection mode
       return false;
         if (!sendCommand("AT+CWMODE=1")) // set STA mode
       return false;
         return sendCommand("AT+CWJAP=\"CAPSTONE\",\"capstonemis\"");
       }
  
       bool sendCommand(const char* cmd) {
         Serial.println(cmd);
       Serial1.println(cmd);
         while (true) {
       buff = Serial1.readStringUntil('\n');
         buff.trim();
       if (buff.length() &gt; 0) {
        Serial.println(buff);
       if (buff == "OK" || buff == "SEND OK" || buff == "ALREADY CONNECTED")
         return true;
       if (buff == "ERROR" || buff == "FAIL" || buff == "SEND FAIL")
         return false;
       }
        }
  }
  </code></pre>
  
  <blockquote>
    <p><strong>PHP code</strong></p>
  </blockquote>
  
  <pre><code>&lt;?php
        require 'firebaseLib.php';
        $Trash = $_GET["trash"];
        $Distance = $_GET["distance"];
        $Temperature = $_GET["temp_f"];
        $Humidity= $_GET["humidity"];
  
          $baseURI = 'https://thesis1-69.firebaseio.com';
          $token = 'gg';
      $devicestatus= array('Distance' =&gt; $Distance,'Temperature' =&gt; 
        $Temperature,'Humidity' =&gt; $Humidity);
      $firebasePath = '/thesis1-69/';
        $full= array($Trash =&gt; $devicestatus);
      $fb = new Firebase($baseURI, $token);
        $fb -&gt; update($firebasePath, $full);
       ?&gt;
  </code></pre>
  
  <p>I hope you can help me with the objective I wanted to finish
  Thank you so much
  more power!</p>