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:
- Declare its own wifi access point;
- Instantiate an HTTP server;
- Wait for an HTTP request and perform an action based on that request.
The second ESP will serve as a client, meaning it will:
- Try to connect to the server's wifi access point (for 1 min, green LED blinking);
- Turn on the green LED to indicate that the connection to the server is established;
- Wait for a state change on GPIO_2 port (the IR cell);
- Send an HTTP request to the server with the GPIO_2 port state;
Diagrams


Code
Realization

