Esp8266 Wifi Module
Contents
Introduction
ESP8266 is an UART-WiFi transparent transmission module with ultralow power consumption, specially designed for the needs of a new connected world. It offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the application or to offload all Wi-Fi networking functions from another application processor.
ESP8266 has powerful on-board processing and storage capabilities that allow it to be integrated with the sensors and other application specific devices through its GPIOs with minimal development up-front and minimal loading during runtime. Its high degree of on-chip integration allows for minimal external circuitry, and the entire solution, including front-end module, is designed to occupy minimal PCB area. ESP8266 Serial Wifi Wireless Transceiver Module is suitable for Uno, Mega 2560 and Nano.
Pin Functions
Pin | Name | Description |
---|---|---|
1 | TXD | 1) UART_TXD, sending; 2) General Purpose Input/Output:GPIO1; |
2 | GND | GND |
3 | CU_PD | 1) Working at high level; 2) Power off when low level is supplied |
4 | GPIO2 | 1) It should be high level when power on, hardware pull-down is not allowed; 2) Pull-up by default; |
5 | GPIO16 | External Reset signal, reset when low level is supplied; work when high level is supplied (high level by default); |
6 | GPIO0 | 1) WiFi Status indicator; 2) Operation mode selection: |
7 | VCC | Power Supply(3.3V) |
8 | RXD | 1) UART_RXD,Receiving 2) General Purpose Input/Output: GPIO3; |
Schematic
Features
• 802.11 b/g/n
• Integrated low power 32-bit MCU
• Integrated 10-bit ADC
• Integrated TCP/IP protocol stack
• Integrated TR switch, balun, LNA, power amplifier and matching network
• Integrated PLL, regulators, and power management units
• Supports antenna diversity
• Wi-Fi 2.4 GHz, support WPA/WPA2
• Support STA/AP/STA+AP operation modes
• Support Smart Link Function for both Android and iOS devices
• SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control, PWM, GPIO
• A-MPDU & A-MSDU aggregation & 0.4s guard interval
• Deep sleep power <10uA, Power down leakage current < 5uA
• Wake up and transmit packets in < 2ms
• Standby power consumption of < 1.0mW (DTIM3)
• +20 dBm output power in 802.11b mode
• Operating temperature range -40C ~ 125C
• FCC, CE, TELEC, Wi-Fi Alliance, and SRRC certified
How to Test and Debug Esp8266
Use Arduino Board
In this experiment, you will learn same simple operations about ESP8266 – transfer the data collected from sensors to devicebit.com.
Introduction to DeviceBit Platform
DeviceBit platform is a sensor data storage, visualization and devices remote control and management platform, provides most of its functionality via its Application Programming Interface (API). You can create your devices and applications here and share them with your friends by pushing the customized information to social network.
1. Register an Account on DeviceBit Platform
Login the website (http://www.devicebit.com/). Click Sign Up on the top right corner of the page.
The following page will appear, type your username, password, and Email. Then log on to your mailbox to activate your account.
2. Add a New Device
Click to enter User Center, go to My Devices -> Devices -> Add A device, fill in corresponding information and then save.
ID: The ID of the device, allocated by system automatically. It is unique for each device.
Type: The type of the device.
Arduino: Arduino Board.
Lw-board: The board developed by DeviceBit.
Other: Other board.
Name: The name of the device. For example, IOT
Description: Description of the device.
Public: If your devices are public, other users can also view them and their measurement.
Location: The location of your device. Click the location point on the Map.
3. Add a New Sensor or Controller
The next step is to add a new sensor or controller connected to your device.
Add a new sensor
go to My Devices -> Sensors&Controllers -> Sensors, and then click Add button to create a new sensor.
Now, the following page will appear
ID: The ID of the new sensor. It is unique for each sensor.
Type: The type of the new sensor.
Unit: The unit of the measurement.
Device: Select the device which the sensor is to be connected to.
Name: The name of the new sensor.
Data Conversion: To calibrate your sensor’s measurement. You can fill in the Coefficient and offset if applicable.
Picture: Upload the picture of your sensor.
Public: If your sensors are public, other users can also view them and their measurement.
Normal Value Range: The normal range of the sensor’s measurement. You can set it according to your actual need.
Overrange alarm: Turn it on and you will receive the alert by SMS or email when the sensor’s measurement is out of the range.
Sending Interval: It is only used as the standard for judging whether the sensor is online.
Description: information about the sensor
Twitter Auto-sending: to send data to Twitter automatically
Sort No.: For the same device, the list is sorted by digital size; for different devices, it is sorted by number priority.
4. Add a new controller
Go to My Devices -> Sensors&Controllers -> Controllers, and then click Add to add a new controller.
Now, the following page will appear:
Fill in the related information and then click Save.
The related parameters are explained as follows:
1) ID: The ID of the new controller. It is unique for each controller.
2) Name: The name of the new controller.
3) Device: To select the device which the controller is connected to.
4) Type: The type of the new controller, which can be Switch Control or Numerical Control. For switch type, 0 or 1 is used to control the switch, while for numerical type, the controller status is adjusted by different numerical values.
5) Max-value: The max-value for numerical type.
6) Min-value: The min-value for numerical type.
Here we use a photoresistor to collect data and then transfer them to the platform. Add a sensor now. Remember to save every time after you finish filling in the information.
Components
-1 * ESP8266 Module
-1 * Arduino Board
-1 * Several jump wires
-1 * Breadboard
-1 * USB Cable
- 1* sensor Module
Experimental principle
SunFounder Uno collects light data by photoresistor, and then uploads the data to network server. Here we use the third party server www.devicebit.com.
Some functions in the code:
ESP_Begin(unsigned long baudRate): Set the communication baud rate between the ESP8266 module and SunFounder Mega2560 as 115200 (In esptodevicebit library provided, the communication baud rate between the ESP8266 module and SunFounder Mega 2560 currently only support 115200.).
ESP_Init(): ESP8266 module initilization configuration.
ESP_Send(String server, String gateWay, String userKey, String name, String value): The sending function of the ESP8266 module. Its parameters are decided by the DeviceBit platform. Server is the IP address of sending website (For example, www.devicebit.com we used); gateWay is a gateway number for a user, and you can get it from User Center of the DeviceBit platform; UserKey is obtained from User Center of the DeviceBit platform; Name is the name of the sensor you upload, which is named by you on the DeviceBit platform; Value is the data from the sensor you upload, and it should be of string type.
Experimental Procedures
Step1: Connect the circuit
ESP8266 Mega2560
TXD Pin 19(RX1)
RXD Pin 18(TX1)
CH_PD 3.3V
GND GND
VCC 3.3V
SIG of sensor Module connect to A5, VCC to 5V, GND to GND.
Step2: Open esp_ devicebit.ino under.Before upload, you need to change some parameters.
1) Change the SSID and password into your own ones (see Line 8 and 9).
2) You need to know your password on Devicebit. Go to User Center, click My Account ->Account Settings, and then you can see your Userkey.
Copy and paste the value of Userkey in the following code. The gateway number is your device ID on the Devicebit platform. You can click MyDevices ->Devices in User Center. Select your device ID (here the device is Smart Home, and ID: 01)
and then download it to the SunFounder Mega 2560 board.
Experimental phenomenon: Open the serial monitor, it will display configuration information about ESP8266.
Login to www.devicebit.com, enter into your homepage, check sensor data, and you will see light data uploaded from the Gateway shield
Note: if you use a uno board, before you upload the code, you need to modify the line 6 #define MEGA2560 to #define UNO in the esp8266.h
And connect RXD to Pin 3 , TXD to pin 2
Use AT Command
Preparation
-1 * PL2303HXD
-1 * SunFounder Uno Board
-1 * ESP8266
Procedures
Step 1: wire
Connect UTXD of ESP8266 to RXD of PL2303, URXD to TXD, CH_PD to 5v(recommend 3.3v), GND to GND, and VCC to 3.3v. The Uno board here is used to supply 3.3v power. PL2303 is a USB to Serial Bridge Controller. You can also use other components, such as FTDI.
Step 2:set parameters
After wiring, open the serial port debug tool sscom32. Set parameters at first.
1) Open the serial port, click Open Com. Select the correct port, as shown below.
2) Select the correct baud rate. Here select 115200 bps. Click SendNew, as shown below.
Step3:AT instructions Now, you can start to send instructions. Enter "AT+RST" in the text box. It’s used to restart the module. If ESP8266 goes well, OK will be sent, as shown below:
You can also send other instructions, such as "AT+GMR". It is used to check the version of AT commands and SDK that you are using, the type of which is "executed".
For more information about ESP8266 AT Instructions. please refer to ESP8266EX_AT_Instruction_Set.
Resource
ESP8266EX_AT_Instruction_Set
ESP8266_Module_User_Guide
Sscom32E