Simple switch read using ESP8266

Dear Gaggymoon,

Thank you for the reply, i am currently working on a nearly similar setup, where i have a stand alone ESP which is connected to a relay to be controlled via web,
the relay will be connected to GPIO2

a push button will be connected to GPIO0 initially connected as high (since the GPIO boots as high and to floating) so this way we insure that the GPIO0 is High by default, when the push button is triggered it will be set as low and thus we can read the status

So in your code some changes will be made as the example below:

Initially we prepare the GPIO0 as input

pinMode(0, INPUT);

and then in loop function where we check the availability of a client we update

// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
// read the state of the pushbutton value:
buttonState = digitalRead(0); //GPIO 0
// check if the pushbutton is pressed.
// if it is, the buttonState is LOW:
if (buttonState == LOW) {
Serial.println("Button Pushed");
delay(100);
}

in the coming days, Once i finalize my development i will upload the full setup and code

NB: i am using ESP8266-01 in the setup, and Arduino IDE as programing interface.

Regards
Samir Tafesh
return;
}