I’m looking to detect a 230VAC signal, which is set to live when a Plumbing Valve is open. The signal line has no voltage, when the Valve is not fully open.
I am thinking of using an opto-isolated detector. I want to use an 3.3v Arduino ESP32 to detect the output of the opto isolator.
I am not sure if I need a resistor on the mains input to the opto isolator.
And I am not sure if I need a pullup or pull down resistor (and what size) on the 3.3v that goes to the ESP32 input line.
Be careful here: anything connected to 230VAC must be treated as mains equipment.
About the resistors:
Many of those “AC mains detector / opto-isolator” boards already include a series resistor/capacitor network on the input (often ~100k or a capacitive dropper). If your board has that, you do NOT add another input resistor.
The important check is the PCB creepage/clearance and proper enclosure. Some cheap boards are not safe for permanent installation.
About the ESP32 side:
If the output stage is an opto-transistor/open-collector, you need a pull-up to 3.3V (often 4.7k–10k). Many boards already have a pull-up fitted (sometimes to 5V), which would be a problem for ESP32.
Verify with a meter or schematic whether the output is pulled up to 5V or 3.3V. If it’s pulled up to 5V, remove/replace the pull-up resistor or use a level shifter / divider.
Also add a fuse (or other current protection) on the mains input and make sure the whole thing is enclosed. Don’t leave a bare PCB with mains on it.