Refer to this tutorial : https://blog.device-interactions.com/2018/05/wireless-messaging-with-two-nodemcus.html
The Communication setup is a Master-Slave configuration where one module is a Server and the other is a Client. The Server Module generates a WiFi hotspot and allows clients to connect to it. The Client Module connects to this hotspot and sends messages, based on the User's Serial commands
To get started, click the Clone/Download button in the top right corner and get a copy of this repository on your PC. Open the downloaded directory.
To set up the Server, follow these steps:
- Open the AP-Server.ino file with Arduino IDE
- Plug on your first ESP8266 Module
- Select the right port and board (ESP8266 Module)
- Open your Serial Monitor, and select 9600 baud rate
- Click on 'Upload Sketch' (Ctrl+U)
- Once the Sketch is uploaded, wait for the Serial message confirming that the Access Point and HTTP Server have started
- Now leave this powered up
To set up the Client Module, follow these steps:
- Open the Client.ino file with the Arduino IDE
- Plug in the second ESP8266 Module
- Select the right board and port (remember that the first ESP8266 module is connected too)
- Open the Serial Monitor and select 9600 baud rate
- Click on 'Upload Sketch' (Ctrl+U)
- Once the sketch is uploaded, wait for the Serial message to confirm that the Client has connected to the Server's Access Point.
- Once the connection takes place, it will prompt you for a Serial Command that can be provided from the top bar in the Serial Monitor
- Now you can type in any message that you like in the Serial monitor bar, and that message will be sent to the Server over the Hotspot
- You will also receive an acknowledgement message back from the Server regarding your message
The LED functionalities are implemented on the pins D4 and D5 of both NodeMCUs. LED at D4 is internally connected on the NodeMCU. LED at D5 needs to be connected via a 330 Ohm resistor. Refer to the connection diagram image in the Repo.