user46195: I'm trying to program an ESP8266 ESP-01 module to let it connect to my personal wifi network and activate a wireless relay that I've bought.
No problems with Wifi connection so I've omitted the code about it, my problem is to find what is the right PIN to set to LOW/HIGH to control my relay.
Setting relayPin to 1 as shown in this code works and with it I can see the embedded LED turning on and off.
const int relayPin = 1;

void setup() {
    pinMode(relayPin, OUTPUT);
}

void loop() {
    Serial.println("Close Relay for 100 ms and then Open");
    digitalWrite(relayPin, LOW);
    delay(100);
    digitalWrite(relayPin, HIGH);
    delay(200);
}

Surfing the web I've found the following diagram about the ESP8266 ESP-01 module:

I've tried to set relayPin to 0 or to 2 but the relay doesn't activate/deactivate.
So, what is the right PIN number to set in my relayPin constant to control the GPIO0 port?
The relay works succesfully if I give him +3.3V on GPIO0 with an external power.
Thanks in advance

user4143: Looking at better pictures of the PCB on ALIExpress it looks like GPIO0 is used to switch the relay.
What that pin maps to, though, depends on what board you have selected in the IDE.

user21371: most GPIO pins on the ESP8266 "boot" up in INPUT mode
You'll need to
const int relayPin = 0; // or 2

void setup() 
{
    pinMode(relayPin, OUTPUT);
}

The reason GPIO1 works is because GPIO1 is serial TxD - so, it's set to output

46195: <p>I'm trying to program an ESP8266 ESP-01 module to let it connect to my personal wifi network and activate a <a href="https://aliexpress.com/item/ESP8266-5V-WiFi-relay-module-Things-smart-home-remote-control-switch-phone-APP-ESP-01/32821697306.html" rel="nofollow noreferrer">wireless relay</a> that I've bought.</p>

<p>No problems with Wifi connection so I've omitted the code about it, my problem is to find what is the right PIN to set to LOW/HIGH to control my relay.
Setting relayPin to 1 as shown in this code works and with it I can see the embedded LED turning on and off.</p>

<pre><code>const int relayPin = 1;

void setup() {
    pinMode(relayPin, OUTPUT);
}

void loop() {
    Serial.println("Close Relay for 100 ms and then Open");
    digitalWrite(relayPin, LOW);
    delay(100);
    digitalWrite(relayPin, HIGH);
    delay(200);
}
</code></pre>

<p>Surfing the web I've found the following diagram about the ESP8266 ESP-01 module:</p>

<p><a href="https://i.stack.imgur.com/KVtEM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KVtEM.jpg" alt="ESP8266 ESP-01 module"></a></p>

<p>I've tried to set relayPin to 0 or to 2 but the relay doesn't activate/deactivate.</p>

<p>So, what is the right PIN number to set in my relayPin constant to control the GPIO0 port?</p>

<p>The relay works succesfully if I give him +3.3V on GPIO0 with an external power.</p>

<p>Thanks in advance</p>
 4143: <p>Looking at <a href="https://m.es.aliexpress.com/item/32842108327.html" rel="nofollow noreferrer">better pictures of the PCB on ALIExpress</a> it looks like GPIO0 is used to switch the relay.</p>

<p>What that pin maps to, though, depends on what board you have selected in the IDE.</p>
 21371: <p><em>most</em> GPIO pins on the ESP8266 "boot" up in <strong>INPUT</strong> mode</p>

<p>You'll need to</p>

<pre><code>const int relayPin = 0; // or 2

void setup() 
{
    pinMode(relayPin, OUTPUT);
}
</code></pre>

<p>The reason GPIO1 works is because GPIO1 is serial TxD - so, it's set to output</p>
