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 {http://arduino.esp8266.com/stable/package_esp8266com_index.json} without bracket into Additional Board Manager URLs field. Note you can add multiple url separating them with commas. >  http://arduino.esp8266.com/stable/package_esp8266com_index.json

Or you can follow this steps. http://www.14core.com/arduino-ide-with-esp8266-integration-for-ease-programming/

Source Code for Server

Source Code for Client

Downloads

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

 

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

JLCPCBPCBgogoPCBway4pcb

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

  • at
    Permalink

    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.

    Reply
  • at
    Permalink

    ‘digtalRead’ was not declared in this scope

    Reply
  • at
    Permalink

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

    Reply
  • at
    Permalink

    Soy Daniel de Valencia (España) . Me gustaría hablarte de un pequeño proyecto que tengo en mente. Como conectar entre si dos esp8266-01
    Uno como cliente con entrada gpio2 de un sensor de lluvia, que manda orden ( cuando llueve) durante 20 segundos al otro esp8266-01 como servidor,
    con salida por gpio2 a un relé, que hace que baje la persiana de una ventana.
    La idea es meter el esp8266-01 (servidor) dentro de la caja empotrada de los pulsadores de subir/bajar la persiana.
    La cuestión es que lo quiero hacer inalámbricamente.
    Es posible hacer el proyecto?
    He mirado mucho por internet y no he visto nada, podríais echarme una mano
    Mi problema es, que de programación, NO tengo nada de idea. ¿Tu podrías desarrollar el código (sketch)que hiciera funcionar mi proyecto?

    Muchas Gracias por la atención, espero tu ayuda. Un abrazo.

    [email protected]

    Reply
  • at
    Permalink

    i have the val not declared in scope problem please help

    Reply
    • at
      Permalink

      which value is not declared? most provably that issue is come from the declared variables, see true it that all variables are properly utilize/ :D

      Reply
  • Pingback:Point to Point / Server & Client Setup on ESP8266 & MCP9808 Temp Sensor | 14core.com

Leave a Reply to 14core Editor Cancel reply

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