Arduino UNO + ESP8266 Module + Relay

Hi All,

This is my first time posting so please be gentle with me :

I am trying to connect my Arduino UNO using the ESP8266 Wifi module to the internet (IOT) to control a relay.

I have writen code to my Arduino unit which allows me to use the serial monitor to toggle my Relay switch ( Light ) on and off. Works very well. I have since purchased the ESP8266 WIFI module to connect my Arduino unit to the internet, however i cannot find a simple nor reliable/easy tutorial to explain how to connect my Arduino Unit using the ESP8266 to WWW. I have tried Cayenne tutorials however i cannot see code for the ESP8266 module through the Arduino Uno, I have searched endless amounts of time on the internet and struggling.

Can someone please kindly help?

My Goals

  1. Using my smart phone to toggle the Arduino relay on and off.

This Relay will be connected to my front room light and will also need to read a push button input for local use, however this is not important just yet. Want to get the unit working first.

Hope this helps, please help?

Thanks Daz

So you will have one output (to the relay) and one input (from local switch)? I don't see why you need the Uno. The ESP module is way more than just a wifi module. It is, by itself a powerful processor. It does have limited IO pins but that can be fixed. Programming the ESP with the Arduino IDE is possible using the Arduino core.. You need code on the ESP, anyway, unless you want to us the AT commands (which are clumsy and limited in my opinion). Which ESP module do you have? I suggest the -7 or -12 variants as they have more pins broken out.

Ahhh really? So i could simply remove the Arduino Uno unit completely and just write to the ESP8266 wifi module?

This is how the unit is going to be wired and used. - ** Home automation**

Locally - Digital read button state, if button pressed (Normal wall mounted 1 gang switched on) power relay on so light switches on.

IOT - I can use my Samsung Smart phone to connect to the Wifi module and also power the relay on or off.

This way, the normal home switch can be operated normally, however its also a smart switch.

Does this helps, so you understand my initial goal?

I am currently writing the code so i can do the above all locally. Just need to know how you use/add the ESP8266 wifi module to do this all remotely as well.

Hope i explained this properly.

Thanks

Ahhh really? So i could simply remove the Arduino Uno unit completely and just write to the ESP8266 wifi module?

Yes, that is what I am saying. For instance, I have a weather station using only an ESP8266-12 that is connected to a wind gauge (speed and direction), a barometer, a rain gauge and a temperature and humidity sensor. The ESP acts as a server and to view the weather information I connect to it with a browser.
So to do what you want is certainly possible.

To program the ESP you will need a USB to TTL converter to connect the ESP to a PC running the Arduino IDE. This page describes the core installation and setting up to program the ESP.

Much more information is available on the web. Just search for "program ESP8266 with Arduino IDE".

There is also a lot of info on setting the ESP up as a server or client and a wifi access point or station. Included with the core are many examples to get you started with the programming. On the forum there are members with way more expertise than I that can hep you, too.

One thing that needs mentioning is the power requirements of the ESP. It must have a 3.3V supply capable of providing at least 800mA for reliable operation. Note,too, that the outputs are only good for about 10mA, unlike an Uno that can do 20mA safely.

You might want to check out the Wemos D1 Mini and Blynk. Makes wifi home automation projects so much easier.

  • Scotty