This topic has been already discussed, but without a real solution.
I'm using two NodeMCU, one with a receiver and one with an emitter.
The receiver works as expected. It receives signals from remote controls and even from the emitter. The emitter works. Since it's supposed to be a break beam, my expectations were that, putting my hand in between, or a book, the receiver would stop to .... ehm, receive 
In the previous topic, it was pointed out that the receiver continues to get data because the emitter continues to send. But this is exactly the goal. If data are received then nobody passed in front of the emitter, otherwise the beam is broken and something will happen.
Here's what I already tried based on the research I made so far:
- remove power from the emitter: the receiver clearly does not receive
- break the beam with hand, book, plastic, the receiver reads data
- If I point the TV remote towards the receiver and keep a button pressed, the receiver continues to read data, but if I put a hand in between, the reading stops.
- randomly fill the rawData array to generate different values at every loop - this told me that the receiver actually reads from the emitter, and continues even with the Divine Comedy (all the 3 volumes) in between and no matter the distance
The emitter has only the IR led attached to pin D8.
The receiver has only the IR receiver attached to pin D6
Both are the most basic stuff, just the leds, not mounted on some fancy component.
Code is the most basic you can imagine... anyway here it is
//// the receiver
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
const int RECV_PIN = D6;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
}
int k = 0;
void loop() { // this is the receiver loop
if (irrecv.decode(&results)) {
Serial.println(results.value);
irrecv.resume();
k++;
Serial.println(k);
// yes it's ugly but I want something to be printed in between the lines which are all the same
}
delay(100);
}
////// the emitter
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRutils.h>
const int SEND_PIN = D8;
IRsend irsend(SEND_PIN);
decode_results results;
uint16_t rawData[67] = {1000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550,
600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650,
600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650,
650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550,
650, 550, 650, 550, 600, 550, 650, 550, 650, 550,
650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650,
650, 1650, 650, 1650, 650, 1650, 600};
void setup() {
//Serial.begin(9600);
irsend.begin();
}
int k = 0;
void loop() { // this is the sender loop
irsend.sendRaw(rawData, 67, 38); // Send a raw data at 38kHz.
delay(2000);
}