Another illustration how to wire the ESP8266 as server and client mode, therefore there is no need to use a router or smart phones to interact/communicate to the ESP8266, this is direct communication between 2 ESP module as server and client mode, ones the code is loaded the ESP8266 coded as server the client ESP8266 will automatically connect to the ESP8266 Server Access Point. As you can see the diagram on the ESP8266 client the push button is attach to pin D2 map on Arduino as GPIO pin 4 when button is pressed it will send a command to the server as value of 1 then the server will turn the D2/GPIO 4 to HIGH then LED light will turn on.

Required Components

  • ESP8266 12/12E, ESP8266 7, ESP8266 NodeMCU, ESPDuino, WeMos.
  • USB TTL UART / (Flashing/Programming the ESP8266 Module)
  • Push Button
  • Resistors
  • LED
  • Jumper Wire / DuPont Wire
  • Solder Less Bread Board
  • AA Battery

Wiring Guide

Programming / Flashing the ESP8266 12/12E
You need to install Arduino 1.6.8 from the Arduino website. available for Windows, Mac OS, and Linux (32 and 64 bit).
Open Arduino IDE and open the Preferences window then add {} without bracket into Additional Board Manager URLs field. Note you can add multiple url separating them with commas. >

Or you can follow this steps.

Source Code for Server

Source Code for Client


  • Download ESP8266 HTTP Client Library | Zip
  • Download ESP8266 WiFi Code Library | Zip


Wiring & Programming ESP8266 12/12E / NodeMCU as WiFi Remote Client/Server Mode

6 thoughts on “Wiring & Programming ESP8266 12/12E / NodeMCU as WiFi Remote Client/Server Mode

  • at

    Hi sir,

    I am tring to use your code but its seems at the server side it say’s

    ‘val’ was not decleared in this scope.

    How to fix this. Thank you.

  • at

    ‘digtalRead’ was not declared in this scope

  • at

    need to be:
    if (req.indexOf(“/led/0”) != -1) val=0;
    if (req.indexOf(“/led/1”) != -1) val=1;


Leave a Reply

Your email address will not be published. Required fields are marked *