# what are the safety/protection I will have to take when converting 0 to 240V to 0 to 1V , feeding to adc pin of microcontroller

#### ashokraj

Joined Feb 1, 2018
117
Hi, I want to measure the voltage of the fan regulator and feed into ADC pin of ESP 8266, The range of ADC is 0 to 1V, theoretically I can use the below circuit. VG1 being the load voltage taken from the fan regulator, VF1 will be driven into my ADC pin , My doubt is, can i go with this circuit or is there a better way to convert 0 to 240V to 0 to 1V? please provide me insights.

Here I have considered peak voltage(340) not rms.

#### ericgibbs

Joined Jan 29, 2010
13,659
hi ash,
I would advise that you use a small mains step down transformer.
Say 240Vac down to 6Vac, remove some of the secondary windings in order to give 1Vac output.
Note: Your resistive divider or the transformer method will give a voltage which swings +/-1Vac about zero volts.
Don't apply a negative voltage to the ADC input.

I would suggest you use a a half or full wave rectifier, this means a higher than 1Vac will be be required to drive the rectifier in order to get +1Vdc at the ADC.

A simpler way would be to use the 6Vac , rectify and the use a resistive divider.
Using a transformer will give the safety isolation from the mains supply, which your original circuit does not cover.

E

#### andrewmm

Joined Feb 25, 2011
1,757
Like @ericgibbs solution
would suggest , don't remove windings,
but use the resistor divider idea on the 6v AC output

We are assuming input is AC though,

#### Ian0

Joined Aug 7, 2020
3,280
If your microcontroller is on the live side of the supply, then you can use the resistive divider, like you have drawn, but with another 1k resistor to the 3.3V supply. That biases the A/D's input in the middle, so that negative voltages will not damage it.

If the microcontroller is on the earth-side of the power supply (which it will be if there are any external connections to it), then isolation is mandatory, and a 6V transformer is perfect. Don't use EI transformers rated lower than 3VA as the really tiny ones have distorted output waveforms. I like to use this toroid.
https://uk.rs-online.com/web/p/toroidal-transformers/1730113/
A 6V transformer will probably be 8V off load. This attenuator circuit gets it to 1V rms, centred on half supply and only uses two values of resistor
R1=R2 and R3=R4

#### ashokraj

Joined Feb 1, 2018
117
hi ash,
I would advise that you use a small mains step down transformer.
Say 240Vac down to 6Vac, remove some of the secondary windings in order to give 1Vac output.
Note: Your resistive divider or the transformer method will give a voltage which swings +/-1Vac about zero volts.
Don't apply a negative voltage to the ADC input.

I would suggest you use a a half or full wave rectifier, this means a higher than 1Vac will be be required to drive the rectifier in order to get +1Vdc at the ADC.

A simpler way would be to use the 6Vac , rectify and the use a resistive divider.
Using a transformer will give the safety isolation from the mains supply, which your original circuit does not cover.

E
ok thank you, I would like to gain some knowledge excluding the 240V AC,

How can i convert a simple +/-1 v to 0 to 1V using opamps?please tell me

#### ericgibbs

Joined Jan 29, 2010
13,659
hi ash,
Do want 0V to 1V DC or AC,
I would suggest 1V DC, use a simple precision OPA rectifier circuit after the step down transformer.
E

#### Ian0

Joined Aug 7, 2020
3,280
If you're connecting to a microcontroller, then sampling and calculating RMS isn't difficult, and needs fewer external components.

#### Irving

Joined Jan 30, 2016
2,105