The device I am using is an esp8266 which uses an xtensa microcontroller if that is relevant. There is only one Analog to Digital converter pin on the microcontroller.
I connect a small resistor in series to a load. At one side of resistor is the neutral wire and the other side goes to the load. I want to measure the voltage across the resistor since by measuring the voltage I can find out the current in the wire ( I = V(mains) / R(resistor) ) which is an easy way to measure AC current.
The problem is I am stumped about how to go about isolating my microcontroller from the mains. The ground reference for the microcontroller and ADC is the same, so that implies I have to ground my microcontroller to the mains (instead of keeping it floating relative to mains like power converters do).
How do I go about doing this?
I connect a small resistor in series to a load. At one side of resistor is the neutral wire and the other side goes to the load. I want to measure the voltage across the resistor since by measuring the voltage I can find out the current in the wire ( I = V(mains) / R(resistor) ) which is an easy way to measure AC current.
The problem is I am stumped about how to go about isolating my microcontroller from the mains. The ground reference for the microcontroller and ADC is the same, so that implies I have to ground my microcontroller to the mains (instead of keeping it floating relative to mains like power converters do).
How do I go about doing this?