WiFi on Arduino: Setting up the ESP8266
The ESP8266 is a system-on-a-chip which can be programmed independently using the Arduino IDE. It can also be used as a WiFi shield for an Arduino Uno by setting upa simple serial connection. Once connected, the ESP8266 can be controlled by issuing the appropriate AT commands. The instructions below explain how to do this.
The Autodesk graphics library includes an ESP8266 module, but it does not behave perfectly. In particular, the body of the component appears on top of the wires which makes it difficult to see the actual connections. The graphical component is also a different model from the one you are using, and has no breakout board. You will therefore need to interpret the diagram.
Notice that the power to the ESP8266 is 3.3V, and that the signal wire from the Arduino passes through a voltage divider.
Create the required circuit, and then upload the code shown below. Notice that the set_esp8266_baud_rate() method contains some AT commands which set the baud rate to 9600. This is called in setup().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|24||This is an array containing all of the common baud rates|
|29||Outer loop: tries to set the baud rate up to a maximum of five times|
|30||Inner loop: goes through each baud rate in turn trying to get an OK response from the ESP|
|37-41||If we get an OK response, the current baud rate matches the ESP's current setting. We then issues the AT command to set the speed.|
|144-146||Set the configuration of the serial channel|
|45-53||These lines test that the configuration has been successful|
|54-59||If any of the tests fail, we try again|
|67-81||A final test after all attempts have been completed. A status message is written to the serial port so that the user knows the end result.|
With this code running, you should be able to enter the following commands into the Arduino serial monitor and get the response from the module:
|AT+CWLAP||List of available WiFi access points|
Please be careful when you are sending AT commands to the ESP8266. You may
accidentally place the unit into an indefinite deep sleep...