This instructable will cover the basic steps that you need to follow to get started with the ESP8266 ESP-12.
A lot of this content is already out there, but I had a hard time getting everything in place, and the different tutorials can cause a great deal of confusion, which is why I have tried to make the simplest setup possible.
Specifically, this instructable will cover how to make the ESP-12 behave as a WiFi client by connecting to your home wireless network and how to send sensor data (we will send random numbers to test, and will not really be covering sensors in this instructable ) to a Thingspeak channel.
The ESP-12 has a 2mm pitch, which means you cannot access all the pins on a breadboard or a perforated / dot matrix directly, which have a 2.54mm pitch (distance between adjacent pins).
You could use a Xbee adapter board, but there's an easier way out. Take a small length of single strand cable or multi strand cable, and get a spider web breakout like this. I added two rows of pinouts, to make sure the pins were handy. Here's what it looks like.
Add a power barrel so that you can easily plug in a 5V adapter into your board to power it. This is an optional step, but one that saves you a lot of trouble later.
Connect the terminals of the power connector to the LM1117 (SMD), so that you have 3.3V output to supply to the ESP8266 ESP-12. It is good practice to add capacitors across the input and output lines, but I am just going to skip that, since this application is very basic and is non-essential.
Here is what the board looks like after adding the power connector and the LM1117.
The additional jumper wires are so that I can either channel the power from the connector to the LM1117 (if I am using a power source > 3.3V), or directly to the ESP-12 (if I am using a 3V power source). This is optional, and you do not need to add this.
Note: Do NOT connect the 3V3 line from the CP2102 to the ESP-12. The ESP-12 consumes a lot of current, and the USB port is NOT capable of providing that, you are at risk of blowing the USB port if you connect the two.
Alternatively, you can also connect an Arduino Uno's Rx and Tx lines with the CP2102, but you will need to have a voltage divider resistor arrangement to step down the 5V UART lines from the Uno to the 3.3V needed by the ESP-12 , otherwise you risk damaging the ESP-12.
If you have Arduino IDE installed, you can just use the Serial Monitor present inside. For that, you have to navigate to Tools > Ports, select the Port that the CP2102 was detected on, and then open the Serial Monitor.
For the next few steps, we will be using the Arduino Serial Monitor for demonstrating.
In the Arduino Serial Monitor, at the bottom right, in the line endings tab, select “Both NL and CR”. This inserts a NewLine and CarriageReturn at the end of each command you send, and is necessary for the ESP-12 module to receive and understand your commands.
The other terminals should have a similar option in their respective configuration pages.
First, to check if the module has been recognized and is accepting commands, just briefly connect the “REST” pin of the ESP-12 to ground, using a jumper. This resets the ESP-12 and you should see something like the screenshot if this works well.
Next, we run the following set of commands in the Serial Terminal:
1. AT
This is just a hello message, and if the ESP-12 is in the correct mode, it will return an “OK” message.
2.AT+GMR
This command returns the firmware version currently on the chip.
3.AT+CWMODE?
This command returns the mode of operation. If the mode is not 3, we will change it to 3 using the following command:
AT+CWMODE=3
This mode makes the ESP8266 behave both as a WiFi client as well as a WiFi Access point.
4.AT+CWLAP
The LAP (List Access Points) lists the WiFi networks around. Next, we choose our WiFi network
5. AT+CWJAP="your_network_name","your_wifi_network_password"
This command JAP (Join Access Point) makes the ESP-12 join your WiFi Network.
6.AT+CIFSR
This command returns the IP address of the ESP-12 as the second line and the gateway IP address as the first line if it managed to connect successfully.
Next, we just post our data to Thingspeak. For now, we will be posting made up numbers, which you can replace with sensor data if you are using an Arduino Uno or some other micro-controller with the ESP-12, or once you progress to using the ESP-12 with your own custom firmware.
You need to sign up for an account at Thingspeak, set up a channel, but to make the process simpler, I am just going to include my access key for Thingspeak, so you can send data right away to test your modules and view it too .
This instructable will cover the basic steps that you need to follow to get started with the ESP8266 ESP-12.
A lot of this content is already out there, but I had a hard time getting everything in place, and the different tutorials can cause a great deal of confusion, which is why I have tried to make the simplest setup possible.
Specifically, this instructable will cover how to make the ESP-12 behave as a WiFi client by connecting to your home wireless network and how to send sensor data (we will send random numbers to test, and will not really be covering sensors in this instructable ) to a Thingspeak channel.
The ESP-12 has a 2mm pitch, which means you cannot access all the pins on a breadboard or a perforated / dot matrix directly, which have a 2.54mm pitch (distance between adjacent pins).
You could use a Xbee adapter board, but there's an easier way out. Take a small length of single strand cable or multi strand cable, and get a spider web breakout like this. I added two rows of pinouts, to make sure the pins were handy. Here's what it looks like.
Add a power barrel so that you can easily plug in a 5V adapter into your board to power it. This is an optional step, but one that saves you a lot of trouble later.
Connect the terminals of the power connector to the LM1117 (SMD), so that you have 3.3V output to supply to the ESP8266 ESP-12. It is good practice to add capacitors across the input and output lines, but I am just going to skip that, since this application is very basic and is non-essential.
Here is what the board looks like after adding the power connector and the LM1117.
The additional jumper wires are so that I can either channel the power from the connector to the LM1117 (if I am using a power source > 3.3V), or directly to the ESP-12 (if I am using a 3V power source). This is optional, and you do not need to add this.
Note: Do NOT connect the 3V3 line from the CP2102 to the ESP-12. The ESP-12 consumes a lot of current, and the USB port is NOT capable of providing that, you are at risk of blowing the USB port if you connect the two.
Alternatively, you can also connect an Arduino Uno's Rx and Tx lines with the CP2102, but you will need to have a voltage divider resistor arrangement to step down the 5V UART lines from the Uno to the 3.3V needed by the ESP-12 , otherwise you risk damaging the ESP-12.
If you have Arduino IDE installed, you can just use the Serial Monitor present inside. For that, you have to navigate to Tools > Ports, select the Port that the CP2102 was detected on, and then open the Serial Monitor.
For the next few steps, we will be using the Arduino Serial Monitor for demonstrating.
In the Arduino Serial Monitor, at the bottom right, in the line endings tab, select “Both NL and CR”. This inserts a NewLine and CarriageReturn at the end of each command you send, and is necessary for the ESP-12 module to receive and understand your commands.
The other terminals should have a similar option in their respective configuration pages.
First, to check if the module has been recognized and is accepting commands, just briefly connect the “REST” pin of the ESP-12 to ground, using a jumper. This resets the ESP-12 and you should see something like the screenshot if this works well.
Next, we run the following set of commands in the Serial Terminal:
1. AT
This is just a hello message, and if the ESP-12 is in the correct mode, it will return an “OK” message.
2.AT+GMR
This command returns the firmware version currently on the chip.
3.AT+CWMODE?
This command returns the mode of operation. If the mode is not 3, we will change it to 3 using the following command:
AT+CWMODE=3
This mode makes the ESP8266 behave both as a WiFi client as well as a WiFi Access point.
4.AT+CWLAP
The LAP (List Access Points) lists the WiFi networks around. Next, we choose our WiFi network
5. AT+CWJAP="your_network_name","your_wifi_network_password"
This command JAP (Join Access Point) makes the ESP-12 join your WiFi Network.
6.AT+CIFSR
This command returns the IP address of the ESP-12 as the second line and the gateway IP address as the first line if it managed to connect successfully.
Next, we just post our data to Thingspeak. For now, we will be posting made up numbers, which you can replace with sensor data if you are using an Arduino Uno or some other micro-controller with the ESP-12, or once you progress to using the ESP-12 with your own custom firmware.
You need to sign up for an account at Thingspeak, set up a channel, but to make the process simpler, I am just going to include my access key for Thingspeak, so you can send data right away to test your modules and view it too .
No comments:
Post a Comment