How to send HTTP request from one ESP8266 (master) to another (slave)

Hi all,

I have a working Wemos/Lolin D1 Mini running WiFiTerm (discussed here Remote terminal/monitor for ESP8266 & ESP32 - Libraries - Arduino Forum ).
I can send commands to it from any browser and control different local actions via a command line interface :

#include <ESP8266WiFi.h>
const char* ssid = "";
const char* password = "";

#include "WiFiTerm.h"

ESP8266WebServer server(80);

void setup()
{
  pinMode(D1, OUTPUT);
  Serial.begin(115200);
  Serial.print("\nConnecting to WIFI");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print('.');
  }
  Serial.println("connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.begin();
  Serial.println("webServer started");

  term.begin(server);
  Serial.println("term started");
}

void loop()
{
  server.handleClient();
  term.handleClient();

  if (term.available()) {
    incoming = term.readString();
    incoming.toUpperCase();
    term.println(incoming);
    uint8_t i = incoming.indexOf(' ');
    uint8_t j = incoming.indexOf(' ', i + 1);

    cmd = incoming.substring(0, i);
    p1 = incoming.substring(i + 1, j).toInt();
    p2 = incoming.substring(j + 1).toInt();
    //term.println(cmd);
    //term.println(p1);
    //term.println(p2);


    if (cmd == "TEST") 
    {
      digitalWrite(D1, 1);
    }

    if (cmd == "ON")   // Turn on lamp
    {
      // send HTML request to Sonoff S20 slave esp8266
    }
  }
}

What I could need som help with is how to execute a HTML request from this sketch to another ESP (which has a static IP address on my LAN). That would be a wifi controlled power outlet like this Reprogram Sonoff Smart Switch Web Server | Random Nerd Tutorials.

I can see in the sonoff sketch that a web page like this will be provided :
"

SONOFF Web Server

<a href="on">ON <a href="off">OFF

";

How can I send a HTTP "on" (or "off") command from the master to the slave ? I only need one way communication, the master can just throw away any web page element reply updates from the slave.

Thanks.

check out the BasicHttpClient example from ESP8266HttpClient

@Deva_Rishi
I will do that, thanks for your help !

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.