How can I read AC 0-220Volts in ESP8266

Hello Everyone,

I am new to arduino So I am sorry if I can not explain properly, I am working on a project "Dimmable Lights", my question is, How can we monitor 0-220Volt OR how can we read 0-220Volt on ESP8266 or Arduino UNO.

Thanks in advance for the Help :)

Why do you want to monitor mains voltage? It makes little sense in the context of your project. Do you want to measure the voltage or just detect it's presence?

But just on the off chance that the OP does consider it relevant to his project, he will not be the first. link

Thanks Mike for the response, Actually My goal is to Control Lights intensity through App i-e Dimmable Lights, and additionally my requirement is "If anyone wants to control lights through manual dimmer", so, I have to check the status of the MANUAL Dimmer constantly.

Thanks.

Grumpy_Mike: Why do you want to monitor mains voltage? It makes little sense in the context of your project. Do you want to measure the voltage or just detect it's presence?

Thanks Mike for the response, Actually My goal is to Control Lights intensity through App i-e Dimmable Lights, and additionally my requirement is "If anyone wants to control lights through manual dimmer", so, I have to check the status of the MANUAL Dimmer constantly.

Thanks

jlsilicon:
Only suggesting this if you have Electronics experience.

You could start with a High-Voltage Rectifier-Bridge then a High-Impedence Resistor-Ladder.

   O----*-->|----*

|       |
220       V        –
VAC      –        ^
          |       |
          ----   |   -------    
          |       |            < R1M
          |       —+      >
          |       |     |      |
         –       V     |       --------—> Adc0 : Arduino
         ^        –     |      |          |
          |       |     |       < R10K   – C10nF
  O----
--------*     |       >          –
                           |      |          |
                        ±—--------—>  Gnd : Arduino
                               |
                              —
                               -  gnd








You could then Monitor the Voltage on the Arduino Adc0/A0 pin.
C10nF would need to be assigned dependent upon the Timeframe of monitoring 1x/sec or 1x/msec or 1x/10sec, etc.

If you put all that between code tags, there is a chance that it will be readable.

Or draw it as a picture, would be even better.

jlsilicon:
Only suggesting this if you have Electronics experience.

Odd that because anyone with any Electronics experience would know not to do that.

You could then Monitor the Voltage on the Arduino Adc0/A0 pin.

And produce a small explosion if you ever plugged a PC into it while it was connected to the mains. That circuit is dangerous and in most countries illegal. It is VITAL that any connection to the mains be isolated from an Arduino circuit.

True - here in the US, we use 110 where one side is 110 and the other side is neutral - with our 220, it is actually 110 either side of neutral (two phase if you will). If there is 50-50 chance of connecting so the ground of your project would be hot, Murphy says you will always do it when it can fry the most things (you included). Letting the “magic smoke” out of things (especially you) is generally a very bad thing. Not sure with the euro 220 if one side of that is ground or if it is like the US 220, but either way, I would isolate from the mains with a small step down transformer - recognize that a transformer can also affect how the dimmer works (some are more sensitive than others to inductive loads).

Not sure with the euro 220 if one side of that is ground or if it is like the US 220,

In Europe we have a live and neutral, ground is only used for safety and if you connect neutral to ground the electricity companies track you down and you can go to prison, although it is likely it will be a fine. Neutral sits about 6 to 12V above ground, but from a safety legislation point of view you must not rely on a specific connection being live or neutral. That is the live and neutral must be capable of being swapped without affecting the safety of the device.

The 220V is just one phase of a three phase signal and domestically adjacent proprieties may be on different phases. I once had a situation where there was a wiring fault at the end of the road and the neutral got disconnected. Therefore my house was connected across two phases through the neutral next door. The result was I got ( about ) double the mains voltage and this caused light bulbs to blow, my Hi-fi amplifier's left channel went ( thus protecting the right channel ) and the cooker made quite a loud hum and would have got hot if it would have left it on. Luckily I spotted the problem, made a voltage measurement, reported the problems and warned the neighbors.

Back to the question: What kind of dimmer are you using? In any case: You do know that you will not have 0-220V through a dimmer but most certainly the sine waves will be cut off after or before a zero crossing?

The easiest and by far safest way would be to replace the manual control. Put a poti into the dimmer, or replace them with a momentary switch. In my last lighting project, I used a momentary double switch. Left click switches on/off, left hold increases brightness, right hold decreases brightness, right click toggles through the controllable lights.

With a phase control dimmer, you could use a bridge rectifier and an opto-coupler. Since it will be of for at least some time around the zero cross, you will not get the very high region of the manual dimmer correctly, though.
You get a BR and an OC as a single component intended for exactly that purpose in form of the H11AA1. You will also need some kind of current limiting. Since you want to keep the off-time for the full sine wave as short as possible, you want relatively high currents, so you cannot practically use pure resistive limiting with 220V. It will dissipate too much heat to be practical. So you want capacitive limiting. Limit to <80mA resistive and then add capacitive limiting (MKP, X2 rated) to 20mA.

How are you planning to dim what?

Grumpy_Mike:
And produce a small explosion if you ever plugged a PC into it while it was connected to the mains. That circuit is dangerous and in most countries illegal. It is VITAL that any connection to the mains be isolated from an Arduino circuit.

I think that D2 and D4 will explode even before you plug a pc since they are connected straight to ground!

Ciao, Ale.

ilguargua: I think that D2 and D4 will explode even before you plug a pc since they are connected straight to ground!

No it is AC, and ground is not the same as mains neutral. It just acts as a voltage reference.

A phase control dimmer will not work with an AC voltage lower than 18V or so, and the original spec was for it to work down to 0V.

GND is for Arduino only.
No connection to the Wall Gnd.
And, it was not stated here to do any such thing.

If you can not read a schematic - then do not post crittique here in the forums.

Actually, I have job experience (in a Nyc company) expanding (new) X10 Devices for Household control on the home pc, and also providing a Home Web Server to allow Users to Monitor their Household alarms from the internet (say at work or on vacation). The product was marketed.

I designed / built the circuitry to connect a Micro on 60hz Household power - using a 120KHz carrier.
And, wrote the code to extend Data onto the X10 codes.

As I remember, the interface circuitry was close to my suggestion here:

  • basically just a RC for Ac of 1Mohm and 1uF connecting the Micro to the 110Vac power.
    I also used a Triac to control 110vac bulbs from the micro. The 1M was safe.

Didn’t have any problems. Had fun blinking lights across the office.
My circuits don’t ‘blow up’ or smoke. - Maybe yours do.
:slight_smile:

But, I think this is beyond the capability of the audience here.
And, will not post the full circuits here.
I clearly Advise NOT to do this - considering that you obviously express that you lack the EE knowledge.

So stated,
You could start with a High-Voltage Rectifier-Bridge then a High-Impedence Resistor-Ladder.

   O------*-->|----*
          |       |
220       V       --
VAC      --       ^
          |       |
          *----   |   ---------*     
          |       |            < R1M
          |       *-----+      >
          |       |     |      |
         --       V     |      *----------*---> Adc0 : Arduino
          ^      --     |      |          |
          |       |     |      < R10K    -- C10nF
   O------*-------*     |      >         --
                        |      |          |
                        +------*----------*--->  Gnd : Arduino

You could then Monitor the Voltage on the Arduino Adc0/A0 pin.
C10nF would need to be assigned dependent upon the Timeframe of monitoring 1x/sec or 1x/msec or 1x/10sec, etc.
This is under the assumption that the Arduino is running off of a Battery, and Not connected to any pc.

Please ignore any Kiddie / Trolls advice above here - who also state above that they lack actual EE knowledge or experience.
They seem to sugest depending upon if the circuit ‘Smokes’ or not to verify high voltage circuits.
Something I Deffinately would not do - And Deffinately Advise Avoiding.