user72632: I'm working on a Home Automation Project.
I can turn on-off ESP32 pin from Alexa and Google Assistant Successfully now.
What I need help is with a way to read if the AC supply is ON/OFF on the Arduino pin.
Or if possible to save pins I would want to read it on the same pin which id defined as Digital output to control the relay.
Below attached image of what I have in mind.

Normal switch turns On/off supply to load without any requirement of WiFi.
Load is also connected to Relay NO, which is controlled by Arduino Pin D13.

What I want is instead of just reading the status of the D13 pin, I want to read the status of the Mechanical Switch which directly provide to Load.
So I'll actual status of the Load whether it's turned on by Switch or Relay with interrupting directly connected switch from load to supply.

Edited: As others suggested it is not possible to use the Same Pin to control the relay and read AC load status. So is there a way to read the AC supply through the GPIO pin of ESP32 maintaining galvanic isolation, (opposite working of Relay)?

user7508: If you want to know the state of the load, I suggest to put the
mechanical switch on the low-voltage side of the relay:

simulate this circuit – Schematic created using CircuitLab
The voltage divider R1/R2 is meant to lower the
voltage at the transistor's collector (up to one diode threshold above
Vcc) to a value suitable for the Arduino digital input.
Note that you still need two separate inputs for controlling and for
sensing the state.

72632: <p>I'm working on a Home Automation Project.
I can turn on-off ESP32 pin from Alexa and Google Assistant Successfully now.</p>
<p>What I need help is with a way to read if the AC supply is ON/OFF on the Arduino pin.
Or if possible to save pins I would want to read it on the same pin which id defined as Digital output to control the relay.</p>
<p>Below attached image of what I have in mind.</p>
<ol>
<li>Normal switch turns On/off supply to load without any requirement of WiFi.</li>
<li>Load is also connected to Relay NO, which is controlled by Arduino Pin D13.</li>
</ol>
<p>What I want is instead of just reading the status of the D13 pin, I want to read the status of the Mechanical Switch which directly provide to Load.</p>
<p>So I'll actual status of the Load whether it's turned on by Switch or Relay with interrupting directly connected switch from load to supply.</p>
<p><a href="https://i.stack.imgur.com/6jM9P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6jM9P.png" alt="enter image description here" /></a></p>
<p>Edited: As others suggested it is not possible to use the Same Pin to control the relay and read AC load status. So is there a way to read the AC supply through the GPIO pin of ESP32 maintaining galvanic isolation, (opposite working of Relay)?</p>
 7508: <p>If you want to know the state of the load, I suggest to put the
mechanical switch on the low-voltage side of the relay:</p>

<p><img src="https://i.stack.imgur.com/4YR1F.png" alt="schematic" /></p>

<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f4YR1F.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
<p>The voltage divider R<sub>1</sub>/R<sub>2</sub> is meant to lower the
voltage at the transistor's collector (up to one diode threshold above
Vcc) to a value suitable for the Arduino digital input.</p>
<p>Note that you still need two separate inputs for controlling and for
sensing the state.</p>
