Trying to figure out this one, i would like to install ESP8266 with a relay and wall light switch, which is quite simple BUT, i also want my ESP8266 to know if the light is ON if i use the switch.
Basic diagram like on the image bellow works, i can turn ON and OFF the light with either wall switch remotely through the relay. The problem is when i use phone app to control the light, i do not know if the light has been turned ON with the switch.
i have seen somewhere that someone used 1N4007 and 1/2W 47kohm in line to go from mains HOT to A0 port (analog in) to detect current and thus know if the light is on... not sure is this safe solution in a long run...
Also, if i am to install my wifi device into the wall, where the light switch is, whats the best way to power the device from available 220V to 5V.
Many thanks for any suggestions.