Photoelectric sensor E3JK-R4M1 with ESP 32 Wroom 32D

Maybe you will get lucky and someone here will volunteer to write all that code for you but I would not hold my breath.

If you want help from forum members you have to at least make a good effort at writing the code yourself and trying to make it work.

It's missing automatically generated weekly PDF report sent to your email.

Jim, I am not asking anyone to provide me whole code, I am just asking for basics, What will be the logic and how this transmission will be possible,
I haven't mentioned anywhere to provide me code. Read that again

The logic is what you described you wanted it to do.
You said you have an ESP32 so the transmission would be via WiFi.

Maybe a tutorial on using an ESP32 would help.

Plus there are several ESP examples in the Arduino IDE for whatever board you have selected.

@jim-p Hey jim, While implementing the control box, we need the distance between LCD (20x4) and esp 32 (within control box), you can say 4 meters, So the Voltage connection from LCD to esp 32 can surely decrease. Can I use a regulator here to maintain voltages? Or suggest me any other better alternate.
Thankyou.

The biggest problem will be with data integrity. You can't send I2C data over 4 meters of cable.
Put the ESP32 next to the LCD and make the relay wires longer.

Then Will there not be problem for sensor's grey wire that we gave to ESP 32 pin through voltage divider?

No
The resistors should also be located next to the ESP

@6v6gt Hi, which connection would be better, Pull up configuration or pull down configuration?

Do you know how to do either?

jim, you said, it will not work with internal pull up (INPUT_PULUP), now for connection of button, should I use resistor for external pull up or just do connection of pins with GND and other with digital pin? is 5V needed for one of pin of button?

How far away is the button from the ESP?

@jim-p it is almost 1 meter

Is this being in an industrial enviroment where there are motors , relays, other electrical machinery and wires carrying 120/220VAC close by?

yes

This circuit will provide some switch de-bouncing and also help reduce electrical noise pick up.

@jim-p 1 micro farad capacitor with 50V specification?

Any voltage rating over 6V would be OK

@jim-p The requirement has been achieved. Thank you so much for your help