the question is how can i connect to terminal i_1 or terminal N the 5v . what should i do in circuit so i can connect 5v but also if i connect ac it will work like it works now
Further to what @runaway_pancake said, even if there was enough current to light the LED, their is no ground. Connect 5VDC to L1 and there is no ground for the LED; or connect 5VDC to N and signal to L1 is blocked by D7.
let say i have one 5.08mm2P terminal . so i can choose to connect AC there or connect a wire from 5vdc there. and i will get HIGH signal on esp in booth cases
so 2 different scenarios and i can either connect AC or DC to get signal on esp
If I recall correctly it was not producable because HCPL-0300-500E was not in stock. I'll have to twist my brain hard to figure out how and why it might work. Intended to be used to check if all phases are present in 3-phase 400 VAC system (apx. 565V when rectified).
And, do not attempt this without understanding the risks and how to proper handle them!
For instance by air gapping at the correct places.
I was thinking of something along the lines of Olin Lathrop's suggestion and using an analog measurement. Perhaps use the exact circuit that @arpa123 has, but bias the output of the optocoupler and measure the voltage. Basically my idea is to turn the 220V to 5V span into a signal level that can be measured to determine whether or not an input is present.
I think it's feasible but would require some investigation.
Apparently you want the input to be '1' if AC voltage is present OR when 5V is present.
I suppose there's no input free, because that would be the simplest solution.
If you are not experienced with handling mains power, it’s best to avoid attempting this. Instead, simply use a wall wart that provides the voltage you need. Wall warts are readily available with both AC and DC output options, and they also provide galvanic isolation from the mains, making them much safer to use.
By taking this approach, you ensure safety and significantly reduce the risk of accidents—allowing you to enjoy many more sunrises. If you choose to work with a transformer-based solution, make sure to select the correct transformer for your specific voltage requirements, as this approach works with all AC voltages when matched properly.