Necessary tools and machines

Apps and online services

About this project

ESP8266 is a 3V WiFi module very popular for its Internet of Things applications. ESP 8266 maximum working Voltage is 3.6V and its very important to note. You must know how to power it, how to serial-connect it with Arduino safely, how to ping and many other things. You should use software like Circuito.io, Tinkercad, Fritzing to simulate and work with the board safely. You should also use Logic Level Controller to use with ESP8266 module.

Powering ESP 8266

There are many ways to power ESP8266 WiFi module: you can use 2 AA sized batteries for powering, PC port if you have a TTL-Serial-to-USB adapter (Don't try to connect the module to a PC serial port directly, you could cause damage to the module or to your computer!). You can use LIPO batteries to power the ESP Dev Thing board. You can use LM117 3.3V voltage regulator.

Logic Level Controller

The ESP8266’s maximum voltage is 3.6V, so the thing has an onboard 3.3V regulator to deliver a safe, consistent voltage to the IC. That means the ESP8266’s I/O pins also run at 3.3V, you’ll need to Logic Level Controller any 5V signals running into the IC.

Alternatively, if you have an external, regulated supply you’d like to deliver directly to the ESP8266, you can supply that voltage through the 3V3 pin (on the I2C header). While this voltage doesn’t have to be 3.3V, it must be within the range of 1.7-3.6V.

You can also power ESP using two AA batteries. Positive from batteries to VCC of ESP and GND to GND of ESP 8266.

I have used Tinkercad to show how the board can't handle even 0.1 extra. The maximum voltage you can give is 3.5V. You should use such simulation software to look that the power you are delivering to ESP is safe or not.

Using Logic Level Controller

The level converter is very easy to use. The board needs to be powered from the two voltages sources (high voltage and low voltage) that your system is using. High voltage (5V for example) to the ‘HV’ pin, low voltage (3.3V for example) to ‘LV’, and ground from the system to the ‘GND’ pin.

Communicating ESP 8266 Via Arduino UNO

To communicate with ESP8266 via Arduino UNO you will need a Logic Level Controller in between to safely work with ESP8266.

Communicating With ESP 8266 Module

Click on Start, Run, and type CMD and press enter. Type IPCONFIG and press enter. Type PING and the IP address of your module. A successful PING request will always return a set of numbers. If you get "Request Time Out" messages it means that something isn't communicating.

Then write your IP address to your web browser and now you can communicate with ESP8266 Module.

While In Circuito.io

I use this software to safely run my projects in reality. This software also guides you to wiring and also gives you a test code.

You can find this software in apps section on Hackster.io. Circuito.io gives you choices to build your project. Now you have to add connectivity as ESP8266 WiFi module. You can also add input and outputs.

Adding Connectivity

Click on Add Connectivity and then select ESP8266 WiFi module. Then click on Preview button. You should get Schematic as below.

You can also see its Project Guide. Isn't it useful?

Code

Test CodeC/C++

// Include Libraries#include"Arduino.h"#include"ESP8266.h"#include"dweet.h"// Pin Definitions#define ESP8266_PIN_RX 10#define ESP8266_PIN_TX 11// Global variables and defines// ====================================================================// vvvvvvvvvvvvvvvvvvvv ENTER YOUR WI-FI SETTINGS vvvvvvvvvvvvvvvvvvvv//constchar*SSID="WIFI-SSID";// Enter your Wi-Fi name constchar*PASSWORD="PASSWORD";// Enter your Wi-Fi password//// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^// ====================================================================// These Dweet tokens have been auto generated for you.char*constinputToken="59a7c547b7e19d001f7002d0_input";char*constoutputToken="59a7c547b7e19d001f7002d0_output";// object initializationESP8266wifi(ESP8266_PIN_RX,ESP8266_PIN_TX);Dweetdweet(&wifi,inputToken,outputToken);// define vars for testing menuconstinttimeout=10000;//define timeout of 10 seccharmenuOption=0;longtime0;// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.voidsetup(){// Setup Serial which is useful for debugging// Use the Serial Monitor to view printed messagesSerial.begin(9600);while(!Serial);// wait for serial port to connect. Needed for native USBSerial.println("start");wifi.init(SSID,PASSWORD);menuOption=menu();}// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.voidloop(){elseif(menuOption=='1'){//SET DWEETSdweet.setDweet("DemoKey","DemoValue");// replace with your own (key, value) pairs to dweet your datadweet.sendDweetKeys();//GET DWEETS dweet.receiveDweetEvents();if(!strcmp(dweet.getValue(),"DemoEventName")){Serial.println("DemoEventName received!");// Do something}}if(millis()-time0>timeout){menuOption=menu();}}// Menu function for selecting the components to be tested// Follow serial monitor for instrcutionscharmenu(){Serial.println(F("\nWhich component would you like to test?"));Serial.println(F("(1) IOT"));Serial.println(F("(menu) send anything else or press on board reset button\n"));while(!Serial.available());// Read data from serial monitor if receivedwhile(Serial.available()){charc=Serial.read();if(isAlphaNumeric(c)){elseif(c=='1')Serial.println(F("Now Testing IOT"));else{Serial.println(F("illegal input!"));return0;}time0=millis();returnc;}}}