Blog > Projects > How to use Adeept ESP8266 WiFi Module
How to use Adeept ESP8266 WiFi Module

admin

2016-03-19 21:52:31

Projects

1896 Views

0 Comments

ESP8266 is a low-power UART-WiFi module. It can be widely used in smart power system, smart transportation, smart home, handheld devices, industrial control and other fields. This module uses 3.3V power supply and supports the wireless 802.11 b/g/n standard. In addition, the WiFi module has three operating modes, namely STA, AP and STA + AP.


The following is a using routine about this ESP8266 WiFi module on the Arduino platform .


Overview

The PC software "USR-TCP232-Test.exe" send control commands via the WiFi wireless network to change the color of RGB LED. Then the status of the RGB LED will be returned to the computer through ESP8266.



Requirement

- 1* Arduino UNO

- 1* USB Cable

- 3* 220Ω Resistor

- 1* RGB LED

- 1* Breadboard

- 1* WiFi Router

- Several Jumper Wires

Procedures

1. Build the circuit



2. Network Configuration

Run the software USR-TCP232-Test.exe on your computer, then enter configuration information is as follows:



3. Program

Arduino code:

/***********************************************************
File name:   wifiRGB.ino
Description: Arduino receive wifi data and then control RGB LED‘s color
Website:     www.adeept.com
E-mail:      support@adeept.com
Author:      Tom
Date:        2015/05/02 
***********************************************************/
 
int redPin   = 11;    // R petal on RGB LED module connected to digital pin 11 
int greenPin = 10;    // G petal on RGB LED module connected to digital pin 10 
int bluePin  = 9;     // B petal on RGB LED module connected to digital pin 9 
 
void setup()    
{   
   Serial.begin(115200);       // set up a wifi serial communication baud rate 115200
   pinMode(redPin, OUTPUT);    // sets the redPin to be an output 
   pinMode(greenPin, OUTPUT);  // sets the greenPin to be an output 
   pinMode(bluePin, OUTPUT);   // sets the bluePin to be an output 
   color(255,255,255);         // turn the RGB LED white
    
   delay(4000);
   Serial.println("AT+CWMODE=3");//set to softAP+station mode
   delay(4000);     //delay 4s
   Serial.println("AT+RST");     //reset wifi
   delay(4000);     //delay 4s
   Serial.println("AT+CWJAP=\"djx\",\"root007005\"");   //replace "djx" to your WiFi AP name(SSID), replace "root007005" to your WiFi password
   delay(4000);     //delay 4s
   delay(4000);     //delay 4s
   Serial.println("AT+CIPSTART=\"TCP\",\"192.168.1.102\",8080");   //TCP Protocol, server IP addr, port
   delay(4000);     //delay 4s
   delay(4000);     //delay 4s
   Serial.println("AT+CIPMODE=1");//Open transparent mode
   delay(4000);     //delay 4s
   Serial.println("AT+CIPSEND");  //Starting transparent mode
   delay(4000);     //delay 4s
   Serial.println(" Adeept_wifi connection is successful! ");//wifi send 'Adeept_wifi connection is successful!'
   color(0,255, 0); // turn the RGB LED green
} 
 
void loop()   
{      
  while(Serial.available())
   {      
     switch(Serial.read())
     {
         case '1': color(255, 0, 0);   // turn the RGB LED red 
                   Serial.println("RGB LED is red ");//wifi send RGB LED status 'red'
                   break;
         case '2': color(0,255, 0);    // turn the RGB LED green 
                   Serial.println("RGB LED is green ");//wifi send RGB LED status 'green'
                   break;
         case '3': color(0, 0, 255);   // turn the RGB LED blue
                   Serial.println("RGB LED is blue ");//wifi send RGB LED status 'blue'
                   break;
         case '4': color(255,255,0);   // turn the RGB LED yellow
                   Serial.println("RGB LED is yellow "); //wifi send RGB LED status 'yellow' 
                   break;
         case '5': color(255,255,255); // turn the RGB LED white
                   Serial.println("RGB LED is white ");//wifi send RGB LED status 'white'
                   break;
         case '6': color(128,0,255);   // turn the RGB LED purple
                   Serial.println("RGB LED is purple ");//wifi send RGB LED status 'purple'
                   break;
         case '7': color(0,0,0);       // turn the RGB LED off 
                   Serial.println("RGB LED is off ");//wifi send RGB LED status 'OFF'
                   break;
         default:  break;
       }
    }
} 
 
// the color generating function      
void color (unsigned char red, unsigned char green, unsigned char blue)      
{    
     analogWrite(redPin, 255-red);       
     analogWrite(greenPin, 255-green); 
     analogWrite(bluePin, 255-blue);
}

4. Compile the program and upload to the Arduino UNO board

5. Observe the experimental phenomena


Send different character to the Arduino UNO via WiFi. Such as and “7”.



If you send different data to the Arduino, the color of RGB LED will be changed.

Last article : How to install and use Geany IDE in the Raspberry Pi or Ubuntu?
Next article : How to Use RC522 RFID Reader Module on The Raspberry Pi Plateform

COMMENTS

Identifying:

  Related Products
  Related Blogs
  • CONNECT WITH US 
Copyright © 2016 Adeept.com All Rights Reserved.