Prerequisites

I assume that:

  • presence detection on the IR cell triggers a high state on a GPIO input;
  • the alarm will be activated via a high state on a GPIO output.

You will need:

Warning!
The code is in LUA and therefore requires the ESP8266 to have the nodemcu firmware.

Principle

One ESP will serve as a server, meaning it will:

  1. Declare its own wifi access point;
  2. Instantiate an HTTP server;
  3. Wait for an HTTP request and perform an action based on that request.

The second ESP will serve as a client, meaning it will:

  1. Try to connect to the server's wifi access point (for 1 min, green LED blinking);
  2. Turn on the green LED to indicate that the connection to the server is established;
  3. Wait for a state change on GPIO_2 port (the IR cell);
  4. Send an HTTP request to the server with the GPIO_2 port state;

Diagrams

Client diagram
Server diagram

Code

Client | Server

Realization

Client image
Server image