Monday, November 14, 2016

ESP8266-ESP201 Step-by-step Guide




This is a step-by-step guide to ESP8266-ESP201.

1.       Buy ESP8266-ESP201 with its hardware development kit from eBay, click here:



The development board is shown in photo below as well. You have a relay, buzzer, switches, LEDs, etc. to play with and test your code and to learn input/output functions of ESP8266:



2.       Connect the USB cable between your computer and the development board.
3.       Push the power button to check if power led is working and the board shows sign of life.
4.       Complete schematic of the development board is as follows:



5.       On the PCB near the DIP switch these are the values:
·         R - should be the RED led from the RGB connected to the IO15 pin. Putting the R DIP to ON will light RED if the GPIO15 is HIGH.
·         G - GREEN led from RGB led is connected to IO13. Putting the G DIP to ON will light GREEN if the GPIO13 is HIGH.
·         B - BLUE led from RGB led is connected to IO12. Putting the B DIP to ON will light BLUE if the GPIO12 is HIGH.
·         W - WHITE led located almost under RGB led is connected to the IO14 pin. Putting HIGH on GPIO14 and DIP switch ON will light the WHITE led.
·         J - relay pin connected to IO16 (which is always HIGH - I have no idea why. This behavior and the RED led that is not working can be because I have a bad board or the design for all the boards is wrong. Connecting the IO16 to GND (not recommended) will stop the relay, otherwise it will be ON all the time the J DIP pin is ON.
·         B - BUZZER connected to IO5 pin through B DIP switch. Having GPIO5 HIGH and B on DIP switch ON will prove that the buzzer is working.
·         K1 - I assume is connected to S2.
·         K2 - I assume is connected to S3.



6.       A schematic on a napkin will look like this one:



7.       ESP8266 comes with pre-installed AT commands, so you can check these to see if you get any response. The list of AT commands can be found here:



To test the AT commands, you need to have a program like “Hyper Terminal”. The easiest and recommended way is to install Arduino from here which has a built-in serial monitor through which you can send and receive data.



Once you have downloaded and installed Arduino, you can now run it and it will look like this:



Now click File menu and then select Preferences. It will look like this:



Now add the link below in the “Additional Boards Manager URLs” because ESP8266 board is not included in Arduino by default.


Click OK button.

Now click Tools menu and select Board. Our board in this case will Generic ESP8266 Module. Your screen should look like this:



Now click Tools menu again and select Port from the list of available ports. Your screen should look like this:



Now if you have set everything corrected (i.e. (a) USB connection between ESP8266 development board and computer, (b) Settings in Arduino software) then you are ready to type AT and send AT commands to your ESP8266 and be excited to see “OK” response from your chip. When you send AT to your ESP8266, it will respond you with OK.

Click Tools menu and select Serial Monitor or press on your keyboard Ctrl+Shift+M to open serial monitor where you can send and receive AT commands from serial interface. Make sure you select (a) “both NL and CR” for both new line and carriage return, (b) correct baud rate (e.g. 115200 baud). Your screen should look like this when you ready to send AT commands:




8.       If you have been successful so far, you can be sure that your ESP8266 and its development board and communication between your computer and development board – all is working fine!
9.       Now you want to know how to control GPIO pins by yourself. For that, click File menu, select Examples, select ESP8266WiFi, and then select WiFi WebServer. Your screen should look like this:

                


A new window with WiFi webserver example will open (as shown above in left screenshot). Now edit this file by typing in your WiFi SSID and password. Save the example with another filename and then press upload button to start code compilation and upload to the ESP8266. This will fail. To be successful you need to perform a few more steps.

10.   Turn the board off; Ground the IO0 pin; Set K2 to Ground (ON); Power on the board; and Set K2 to OFF.
11.   Now press Ctrl+Shift+M to open Serial Monitor and then click upload button again, if it fails or shows error close Arduino and open Arduino again and press upload button. It will upload successfully – at least it did it for me! J
12.   Now you will see in Serial Monitor window that your ESP8266 is now connected to your WiFi network and shows an IP address from where you can control IO2 to be 1 or 0.
13.   Connect LED to IO2 and Ground. Go to the given IP address in Serial Monitor (say, 192.168.0.140) and turn on/off LED like this:

14.    The pinouts of ESP8266-ESP201 look like this:


Helpful resources:

·         http://www.esp8266.com/


s

Guest post by: Ahmed Hussain

No comments:

Post a Comment