Things You Should Know Before Using ESP8266 WiFi Module © GPL3+

Things you should know using ESP8266 WiFi module for its safety and easiness as it's very delicate module to use.

  • 6,788 views
  • 1 comment
  • 23 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

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.

ESP 8266 Pinout

ESP8266 has 8 pins, namely:

  • RX
  • VCC
  • GPIO 0
  • RESET
  • CH_PD
  • GPIO 2
  • TX
  • and GND

VCC and GND are powering pins. RX and TX are used to communicate. You should also look at ESP8266 datasheet at https://cdn.sparkfun.com/datasheets/Wireless/WiFi/ESP8266ModuleV1.pdf

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.

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.

Connections:

For Connecting ESP TO Arduino, Connect ESP8266 RX to Logic Level Controller Level 1.

  • Connect ESP TX to Logic Level Controller Level 2.
  • ESP VCC to Arduino UNO 3.3V
  • Logic Level Controller Level to Arduino 3.3V.
  • Logic Level Controller GND To Arduino GND.
  • ESP GND to Arduino GND.
  • ESP CH_PD To Arduino 5V.
  • Logic level Controller HV to Arduino 5V.
  • Logic Level Controller HV1 to Arduino 11th pin.
  • Logic Level Controller HV2 to Arduino 10th pin.

Test code is given in code section below.

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.

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
//
const char *SSID     = "WIFI-SSID"; // Enter your Wi-Fi name 
const char *PASSWORD = "PASSWORD" ; // Enter your Wi-Fi password
//
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ====================================================================


// These Dweet tokens have been auto generated for you.
char* const inputToken  = "59a7c547b7e19d001f7002d0_input";
char* const outputToken = "59a7c547b7e19d001f7002d0_output";

// object initialization
ESP8266 wifi(ESP8266_PIN_RX,ESP8266_PIN_TX);
Dweet dweet( &wifi, inputToken, outputToken);



// define vars for testing menu
const int timeout = 10000;       //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup() 
{
    // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    while (!Serial) ; // wait for serial port to connect. Needed for native USB
    Serial.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.
void loop() 
{
    
    
    
    else if (menuOption == '1') {
    
    //SET DWEETS
    
    dweet.setDweet("DemoKey", "DemoValue"); // replace with your own (key, value) pairs to dweet your data
    dweet.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 instrcutions
char menu()
{

    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 received
    while (Serial.available()) 
    {
        char c = Serial.read();
        if (isAlphaNumeric(c)) 
        {
            
    		else if(c == '1') 
    			Serial.println(F("Now Testing IOT"));
            else
            {
                Serial.println(F("illegal input!"));
                return 0;
            }
            time0 = millis();
            return c;
            }
        }
    }

Comments

Similar projects you might like

Infrared Replicator

Project tutorial by Gustavo Gonnet

  • 402 views
  • 2 comments
  • 12 respects

Development Board for AtTiny MCU

by Vincenzo G.

  • 271 views
  • 0 comments
  • 10 respects

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by GadgetProgrammers

  • 3,576 views
  • 7 comments
  • 48 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 1,330 views
  • 0 comments
  • 6 respects

Control LED Using Your Voice Command

by IoTBoys

  • 1,494 views
  • 1 comment
  • 13 respects

Ultrasonic Security System

Project tutorial by Krepak

  • 1,088 views
  • 1 comment
  • 9 respects
Add projectSign up / Login