How do I make two (or more) pins available on my server url? I have a webserver configured on my esp8266 with is set to fire off electrical relay0 on my 8 port relay board.
The device initializes relay0 perfectly and without errors.
But when I configure the second relay1, i get no response from my second url.
//note, when you write to low, you turn the switchport on. It's backwards for some reason
#include &lt;ESP8266WiFi.h&gt;
#define statusLed 2   // built-in led for the ESP8266-12

const char* ssid = &quot;myssid&quot;;
const char* password = &quot;mypass&quot;;
 
int switchPin0 = 16;
int switchPin1 = 5;
int switch0;
int switch1;

WiFiServer server(80);
 
void setup() {
  Serial.begin(115200);
  delay(10);
 
  pinMode(statusLed, OUTPUT);
  pinMode(switchPin0, OUTPUT);
  digitalWrite(switchPin0, HIGH);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print(&quot;Connecting to &quot;);
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(&quot;.&quot;);
  }
  digitalWrite(statusLed, HIGH);
  Serial.println(&quot;&quot;);
  Serial.println(&quot;WiFi connected&quot;);
 
  // Start the server
  server.begin();
  Serial.println(&quot;Server started&quot;);
 
  // Print the IP address
  Serial.print(&quot;Use this URL : &quot;);
  Serial.print(&quot;http://&quot;);
  Serial.print(WiFi.localIP());
  Serial.println(&quot;/&quot;);
 
}
 
void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println(&quot;new client&quot;);
  while(!client.available()){
    delay(1);
  }
 
  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);

  client.flush();

  // Match the request
 
  int value = HIGH;
  if (request.indexOf(&quot;/SWITCH=0&quot;) != -1){
    digitalWrite(switchPin0, LOW);
    digitalWrite(statusLed, LOW);   // blink led
    delay(1);
    digitalWrite(statusLed, HIGH);
    //set water pump time here
    delay(8000);
    digitalWrite(switchPin0, HIGH);
    value = HIGH;
    ++switch0;
  } else if (request.indexOf(&quot;/SWITCH=1&quot;) != -1){
    digitalWrite(switchPin1, LOW);
    digitalWrite(statusLed, LOW);   // blink led
    delay(1);
    digitalWrite(statusLed, HIGH);
    //set water pump time here
    delay(8000);
    digitalWrite(switchPin1, HIGH);
    value = HIGH;
    ++switch1;
  } else {

    }
 
  // Return the response
  client.println(&quot;HTTP/1.1 200 OK&quot;);
  client.println(&quot;Content-Type: text/html&quot;);
  client.println(&quot;&quot;); //  do not forget this one
  client.println(&quot;&lt;!DOCTYPE HTML&gt;&quot;);
  client.println(&quot;&lt;html&gt;&quot;);
 
  client.print(&quot;Switch pin is now: &quot;);
 
  if(value == HIGH) {
    client.print(&quot;Off&quot;);  
  } else {
    client.print(&quot;On&quot;);
  }
  client.println(&quot;&lt;br&gt;&lt;br&gt;&quot;);
  client.println(&quot;Switch 0&quot;);
  client.println(&quot;Click &lt;a href=\&quot;/SWITCH=0\&quot;&gt;here&lt;/a&gt;  to send a measured amount&lt;br&gt;&quot;);
  client.println(&quot;Number of times plant 0 has been fed is &quot;);
  client.println(switch0);
  client.println(&quot;&lt;br&gt;&lt;br&gt;&quot;);
  client.println(&quot;Switch 1&quot;);
  client.println(&quot;Click &lt;a href=\&quot;/SWITCH=1\&quot;&gt;here&lt;/a&gt;  to send a measured amount&lt;br&gt;&quot;);
  client.println(&quot;Number of times plant 1 has been fed is &quot;);
  client.println(switch1);
  client.println(&quot;&lt;/html&gt;&quot;);
 
  delay(1);
  Serial.println(&quot;Client disconnected&quot;);
  Serial.println(&quot;&quot;);
  digitalWrite(statusLed, LOW);   // blink led
  delay(1);
  digitalWrite(statusLed, HIGH);
 
}

my counter will update, but the relay pin never fires for relay1. relay0 works fine. I can swap the ports and then the second relay will work and not the first. I just can't manage both.
How do I get a second (or more) relay ports to initialize via webpage?
It looks like you forgot to initialize switchPin1 to be an output.
Add the following to your setup() (for example, right after the corresponding initialization commands for switchPin0):
void setup() {
    ....
    pinMode(switchPin1, OUTPUT);
    digitalWrite(switchPin1, HIGH);
    ....
}