Power up Arduino and a Relay with 220v

Hi, I have an Arduino Nano working with esp8266 and a relay to turn on/off a lamp, everything works fine but I am using two wall plugs just for one lamp... (one for Arduino, one for the lamp)

So I want to shrink the project and make it work with just one plug for both, Arduino and the lamp, but I am a bit scared working with 220v with my limited knowledge of electronics.

Could I split the 220v signal in two, and then one to the relay and the other to a 220v to 5v transformer for the Arduino?

I have found this 220v to 5v switcher: http://www.aliexpress.com/item/AC85-265V-to-DC5V-1-5A-7-5W-Switching-Power-Supply-Module-LED-Power-Board-220V/1501238567.html

And this is what I want to do:

|444x500

Should I? do you think its safe? Thanks

Honestly, if you do not have an electrical engineering degree or massive amounts of experience with mains voltage, don't try this. Something is likely to catch fire (a un-extinguishable fire) from the smallest mistake.

Now if you become comfortable and knowledgeable about mains voltage I would recommend a AC-DC from a name brand rather than a generic supply from China. I would also recommend an enclosed supply with terminal connections like this one.

Also, if you actually plan on running 220VAC through a breadboard, then you certainly are [u]not[/u] qualified to handle mains voltage.

:astonished: [shiver!] :astonished:

I agree with the others, if you don't know what you are doing DON'T do it!

If you do go ahead, all mains connections must be via approved mains connectors. Remember that the connectors on the relay board have tracks on the bottom that have mains on them. The board must be mounted so that these cannot be contacted. All of the projects needs to be treated as live.

I assume you have used the breadboard in the diagram to illustrate the circuit. No one would be so stupid as to actually connect mains to a breadboard (I hope!).

Also, the solid state relay can be driven directly from the Arduino.

Weedpharma

Thanks robotix3 and Weedpharma

Yes I know I am not qualified and maybe I am stupid enough, but not too stupid to do it in "real life", I have been researching how to do this in a safe way and here I have "version 2":

|444x500

I am planning to use a wall transformer that I have been using with an Arduino Leonardo for months, it works well, I think I could cut the cables and use it as a transformer.

If you see any other stupid thing in this picture please let me know, I am not going to do anything before I am totally sure.

Appreciate your help, thanks.

Please post a real schematic if you want effective feedback.

Using insulation tape to make a joint on a mains wiring system breaks just about any countries wiring regulations.

You could get rid of the arduino and control the relay from the esp8266. This would shrinkify the project even more.

Hi again, just wanted to share my finished project, and thanks mart256 for your tip on using only the esp8266 to control everything.

I have finally used an original Samsung phone charger, the total cost is about 12$ or less, and it's fully controllable via an android app, just plug something and turn it on and off via smartphone.

If anyone want help to make something like this I would be glad to help.

|444x500

:astonished: [shiver!] :astonished:

I wonder if there are any IEE mains wiring regulations that are still not violated by this.

Dude, thats cool. Could you explain a bit more how is being powered the esp8266 and how did you convert 220vac to 3v3 dc?

Watcher: I wonder if there are any IEE mains wiring regulations that are still not violated by this.

could you, please, tell me what's the problem with this?

mart256: Dude, thats cool. Could you explain a bit more how is being powered the esp8266 and how did you convert 220vac to 3v3 dc?

of course, I am using the phone charger to transform 220v ac to 5v dc, then I am using that 5vdc to power the relay, and then an AMS1117 to transform that 5v to 3.3v to power the esp8266 on pins VCC and CH_PD, the relay its connected to GPIO0, you can see it better in this image:

|500x281

of course it is closed when plugged in so you can never touch a 220v area when it is closed

could you, please, tell me what's the problem with this?

Fire safety.

could you, please, tell me what's the problem with this?

Creapage and clearance for a start.

thanks aarg and Grumpy_Mike

any tip on how to make this safe?

You don't want to know!

Well, short of a custom plastics fabrication workshop, we would have to say to get a utility box (such as used for house or business wiring), fit a proper mains outlet, fit an IEC input connector to use with a standard IEC cable and mount the modules firmly inside so that they have adequate clearance.

When you need to re-program the ESP8266, disconnect it from the mains, open it up and connect it only to your programming interface.

Paul__B: You don't want to know!

Well, short of a custom plastics fabrication workshop, we would have to say to get a utility box (such as used for house or business wiring), fit a proper mains outlet, fit an IEC input connector to use with a standard IEC cable and mount the modules firmly inside so that they have adequate clearance.

When you need to re-program the ESP8266, disconnect it from the mains, open it up and connect it only to your programming interface.

I want to know! I just ignore a lot of things of electronics, thats why I am looking for some help here, trying to learn. I am software developer and hardware its like a new world to me.

If I gave the impression that I do not want to know, sorry, English is not my native language and I am trying to write it the best I can.

I just bought a multiple socket connector and thought that if I can plug in a mobile charger to it, why not directly solder the charger so it is smaller and permanent? Under my ignorance that made sense.

This is what I bought, on a local store in Europe, not on internet:

|500x281

I just cut one side to solder the phone charger and removed the other side completely to leave space for the relay and esp.

Anyway thanks all for your help, by now I'm going to let the project "paused", until I find a way to do it better.

I would begin with a bigger box. Also find a way to mount everything inside the box securely, and include some insulating partitions or other methods to prevent things from contacting each other (in the event of things moving around due to external shock or vibration). Ensure that nothing can get too hot.

Edit - also the load side should meet local requirements for an electrical supply, including live/neutral polarity and grounding. If there are restrictions on the load, it should be clearly labelled on the outside of the box.

If I gave the impression that I do not want to know, sorry, English is not my native language and I am trying to write it the best I can.

OK - The phrase "You don't want to know" is a rather subtle English usage meaning - "There are so many things that you need to know that you will be better off in a state of ignorance is bliss" it does not mean that you do not desire to know.

This is what I bought, on a local store in Europe

The big difference between that and what you are doing is that the picture you posted is used only at mains voltages and it is totally enclosed. There are a lot fewer restrictions on that because it is all mechanical and there is no low voltage side the user can come into contact with.

What you have is a system where there is contact with an external system and that system is capable of being connected to something else. Here there are restrictions as to how close wiring of the live side can be to the user side as well as requirements on the insulation of the free wiring. There needs to be double insulation on any wires carrying mains and distance requirements on mains to user side connections. These spacing requirements can be quite complex depending on how the equipment is categorised.