Sunday, 1 March 2015

Arduino dirt cheap wifi solution -- ESP8266 (introducing and command explaination)

This post will just list the key information for Arduino developers:

1,  Why and what is ESP8266. Today is IoT age. However, Arduino does not have network connecting ability. if you need it. You can implement it mainly by 2 ways:  (of cause there are many different solutions)

a) Wired network: An Arduino ethernet extension board. You also need a internet cable.

b) Wireless network: mainly three options for this: Arduino Yun, or a wifi module or GSM module.

 Arduino yun is about 50 great Britain pound each.
 ESP8266 is a cheap wifi module, it is about 2 pound each.
 GSM module is about 40 pound each.

Obviously, ESP8266 is the best solution. Arduino yun is only good for a prototype. GSM could be a solution but it is to complex for application with simple http requirement. And also it is not a 3G network. And it could be replaced by wifi module and a 3G wifi router.

2, ESP8266 needs 3.3V . 5V could destroy it. Fortunately, Arduino has 3.3v

3, Which version of Arduino hardware should I use?  All my ESP8266 examples run with Arduino Uno. This is the most common and most cheap one now.

4, ESP8266 has 3 versions, Which version should I use? 01,02 and 03.  All my examples run with 01. 02 and 03 are higher versions, so all versions can run my examples.

5, How to connect the wire with Arduino and ESP8266?

-----For the ping (my test example) project, you should connect RX of ESP8266 to Arduino's RX and TX to TX  (you can check this). When you run this test example, you can install any arduino program into your arduino board. However this program should not use serial. Otherwise you cannot send commands to ESP8266 via serial monitor. To understand this I shall explain serial ports to you:

RX and TX are serial ports. Arduino has only two hardware serial ports. One is digital 0-digital 1 another is the USB port. but only one can work at the same time. USB port is used to link to your computer for installing program into your Arduino board.  So if you link your ESP8266 with your Arduino in RX and TX ports (digital 0 and digital ), you cannot install any code to your Arduino board. A work around for this is you can disconnect RX and TX then install program then connect RX TX.

However, if RX and TX are used, you still can use serial monitor to show data of this serial port. And what you entered in test example, it will be directly sent to ESP8266 directly.

------For the arduino restful program example. I want use program to send commands instead of manually inputing on serial monitor. However,  using serial to send command and print out response is the same API, which means if you print out response from ESP it will be recognised as a input again. Because Arduino only has one physical RX TX.  To avoid conflict we can use softSerial to connect to ESP8266 and empty RX and TX for doing log. However the softSerial should connect RX to TX and TX to RX. because the output of arduino should link to ESP8266's input and input to output.

If you don't need see the log, you can use Arduino hardware serial ports directly, but you should connect RX to TX and TX to RX. And of cause, this is inconvenient. But you can do that if you want.

If ESP8266 get connected correctly and get command correctly, it will flash the blue light.

6, which baud should I use? I use 9600 baud for connecting with ESP8266 for all my examples.

7, do I need a SDK or library for ESP8266? No. After you can understand my example and code you can checkout this:

No comments:

Post a comment