ESP8266 Wi-Fi Module for IoT Communication

ESP8266 Wi-Fi Module for IoT Communication

https://www.youtube.com/embed/TbrZaOjmhFo?feature=oembed&rel=0

The ESP8266 is an ultra-low-power, UART-WiFi module of transparent transmission. With industry-leading package size and ultra-low power technology designed for mobile devices and IoT applications, it can connect users’ physical devices to Wi-Fi wireless network for Internet or LAN communication.

ESP8266 is widely used in smart grid, intelligent transportation, smart furniture, handheld devices, industrial control and other fields.

Main functions

The main functions that ESP8266 can achieve include serial port transparent transmission, PWM regulation, and GPIO control.

  • Serial port transparent transmission: data transmission with great reliability, the maximum transmission rate is 460800bps.
  • PWM regulation: light adjustment, three-color LED adjustment, motor speed regulation, etc.
  • GPIO control: control switches, relays, etc.

 

Working modes

The ESP8266 module supports three working modes: STA, AP and STA+AP.

  • STA mode: The ESP8266 module connects to the Internet through a router, and the mobile phone or computer can remotely control the device through the Internet.
  • AP mode: The ESP8266 module acts as a hotspot, enabling the mobile phone or computer to communicate directly with the module to achieve wireless control of the local area network.
  • STA+AP mode: Two modes coexist, the seamless handover can be realized through the Internet control, which is convenient for operation.

 

Applications

  • Serial port CH340 to Wi-Fi;
  • Industrial transparent transmission DTU;
  • Wi-Fi remote monitor/control;
  • Toy;
  • Colorful LED control;
  • Integrated management of fire and security intelligence;
  • Smart card terminals, wireless POS machines, Wi-Fi cameras, handheld devices, etc.

 

Components

– 1 * Adeept UNO board

– 1 * USB cable

– 1 * ESP8266-01 Wi-Fi module

– 1 *Jumper wire

– 1 *LED

– 1 *220Ω resistor

 

Program

Step 1 connect the circuit as shown below.

Step 2 upload the program.

/*************************************
File name:Adeept_wifi_control_led
Description:
Website:www.addept.com
E-mail:support@addept.com
Author:felix
Date:2019/6/10
*************************************/
#include<SoftwareSerial.h>    //use the library to commmunicate with esp8266 wifi module
#define rxPin 2               //define rx and tx pin
#define txPin 3

SoftwareSerial mySerial = SoftwareSerial(rxPin,txPin); //creat an object mySerial

//define esp8266 wifi module variate
char judge = 0;
String comdata = "";
//define receive data
String text1 = "\r\n+IPD,0,1:1";
String text2 = "\r\n+IPD,0,1:2";

// put your setup code here, to run once:
void setup() {
  pinMode(13,OUTPUT);
  mySerial.begin(115200);                  // set up a wifi serial communication baud rate 115200
   delay(4000);
   mySerial.println("AT+RST\r\n");         //reset wifi
   delay(5000);     
   delay(5000);     
   mySerial.println("AT+CWMODE=3\r\n");    //set to softAP+station mode
   delay(4000);     
   mySerial.println("AT+CIPMUX=1\r\n");    //set to multi-connection mode
   delay(4000);
   mySerial.println("AT+CIPSERVER=1\r\n"); //set as server
   delay(4000);
   mySerial.println("AT+CIPSTO=7000\r\n"); //keep the wifi connecting 7000 seconds
   delay(4000);
   digitalWrite(13,HIGH);                  //configuration is complete
   delay(1000);
   digitalWrite(13,LOW);
}

// put your main code here, to run repeatedly:
void loop() {
  //receive the data
  while(mySerial.available()>0)
   {  
    comdata += char(mySerial.read());
    delay(1);
   }

   
  //set the judge
  judgement();
  
  //judge the variate "judge"
           switch(judge)
     {
         case 1: while(!mySerial.available()){digitalWrite(13,HIGH); }
                   break;
         case 2: while(!mySerial.available()) {digitalWrite(13,LOW);} 
                   break;     
         default:  break;
     }
}


  //set the judge
void judgement(){
    if (comdata.length() > 0)
    {
        if(comdata==text1){
          judge=1;
        }
        if(comdata==text2){
          judge=2;
        }
        comdata = "";
    }
}

NetAssist

Step 3 configure Net Assistant (server IP and port number are factory default).

Step 4 connect the computer and ESP8266-01 module.

Step 5 start wireless control of LED through the Net Assistant.

 

Leave a Reply