Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ESP8266 Robotics Projects

You're reading from   ESP8266 Robotics Projects DIY Wi-Fi controlled robots

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788474610
Length 210 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Pradeeka Seneviratne Pradeeka Seneviratne
Author Profile Icon Pradeeka Seneviratne
Pradeeka Seneviratne
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Ready FREE CHAPTER 2. Building a Mini Round Robot with Original ESP8266 3. Using Encoders 4. Building a Mini Round Robot with the Feather HUZZAH ESP8266 5. Line-Following Zumo Robot 6. Building an ESP8266 Robot Controller 7. Building a Gripper Robot 8. Photo Rover Robot

Connecting with a breadboard

Power supply

The ESP8266 works only with regulated 3.3V. You can build a simple regulated power supply with an LD1117-3.3 linear voltage regulator. It can provide 3.3V at 800 mA. You can purchase a TO-220 package of the LD1117-3.3 for use with a breadboard. Figure 1.5 shows the circuit diagram for 3.3V output. You can supply 4-15V DC to Vin using one of the following sources:

  • 7V LiPo battery
  • 5V power bank
  • 9V battery
  • 5V "wall wart" power supply
Figure 1.5: 3.3V regulated power supply circuit diagram

Now, you can connect the power supply to ESP-01:

  1. Connect Vout to the Vcc pin of ESP-01.
  2. Connect GND to the GND pin of ESP-01.

Connecting through USB for flashing

ESP8266 ESP-01 doesn't have a built-in USB to serial conversion chip to directly connect to your computer through a USB cable for flashing programs. As a solution, you can use a USB to TTL serial console cable to connect ESP8266 to a computer. Figure 1.6 shows a USB TTL serial console cable from Adafruit (https://www.adafruit.com/product/954):

Figure 1.6: A USB to TTL serial console cable. Image courtesy of Adafruit Industries (https://www.adafruit.com)

The type A USB plug includes a USB to serial conversion chip and provides four wires to connect to your ESP8266ESP-01 board. Table 1.1 shows the functions of the four wires:

Color

Function

Red

Power

Black

Ground

White

RX

Green

TX

Table 1.1: Color codes and functions of wires

You can use the following steps to connect the USB to TTL serial cable with your ESP8266:

  1. Connect the white RX wire of the cable to the TX pin of ESP8266
  2. Connect the green TX wire of the cable to the RX pin of ESP8266
  3. Connect the black ground wire of the cable to the GND pin of ESP8266
  4. Connect the CH_PD pin of ESP8266 to the Vcc wire of the power supply
Don't connect the red power wire because it is 5V.

Using a serial terminal program

The following steps will guide you how to use a serial terminal program to communicate and execute AT commands with ESP-01. In this example, you will use PuTTY, SSH, and a Telnet client for Windows to run AT commands through a serial port:

  1. First, download the latest PuTTY MSI installer or binary from the following sources:
  1. Open the PuTTY Configuration window by double clicking on putty.exe or the putty shortcut.
  2. In the Serial line text box, type the COM port that is assigned to your ESP8266 board (Figure 1.7).
  3. In the Speed text box, type 115200 as the baud rate.
  1. Click on the Open button to make a serial connection:
Figure 1.7: The PuTTY configuration window
  1. If you have provided the correct settings, the serial connection will establish between ESP8266 and your computer.
  2. You can use the serial terminal window to issue AT commands for ESP8266 from your computer.

AT commands

Table 1.2 shows the complete set of AT commands that you can use with ESP8266:

AT command

Manual

AT

Attention.

AT+RST

Resetting the unit.

AT+GMR

Retrieving the firmware version ID.

AT+CWMODE=?

AT+CWMODE?

AT+CWMODE=<mode>

Setting operation mode:

  • Client
  • Access point
  • Client and access point

The access point functionality does not have a DHCP function and has only minimum functionalities. However, it will assign an IP address to the client and there is no way to do a manual IP, manual DNS, and other advanced IP functionalities. This unit only provides minimal functionalities.

AT+CWJAP=<ssid>,<pwd>

AT+CWJAP?

Joining a network or just an access point.

AT+CWLAP

Retrieving the list of the visible network.

AT+CWQAP

Disconnecting from the current network connection.

AT+CWSAP=<ssid>,<pwd>,<chi>,<ecn>

AT+CWSAP?

Setting up access point SSID, password, RF channel, and security scheme.

The following is the security scheme:

  • 0: Open. No security.
  • 1WEP.
  • 2WPA_PSK.
  • 3WPA2_PSK.
  • 4WPA_WPA2_PSK.

AT+CWLF

Retrieving a list of assigned IP addresses.

AT+CIPSTATUS

Retrieving the current connection as socket client or socket server.

AT+CIPSTART=?

AT+CIPSTART=<type>,<addr>,<port> (AT+CIPMUX=0)

AT+CIPSTART=<id>,<type>,<port> (AT+CIPMUX=1)

Connecting to socket server (TCP or UDP).

AT+CIPSEND=<length> (AT+CIPMUX=0 & AT+CIPMODE=0)

AT+CIPSEND=<id>,<length> (AT+CIPMUX=1 & AT+CIPMODE=0)

AT+CIPSEND (AT+CIPMUX=0 & AT+CIPMODE=1)

Sending by connection channel and by specific length.

AT+CIPCLOSE

Closing the socket connection.

AT+CIFSR

Retrieving the assigned IP address when the unit is connecting to a network.

AT+ CIPMUX=AT+CIPMUX?

Setting a single connection (AT+CIPMUX=0) or multi-channel connection (AT+CIPMUX=1).

AT+CIPSERVER= [,] (AT+CIPMUX=1)

Starting at the specified port or stopping the server.

The default port is 333.

<mod> is as follows:

  • 0: Close the socket server
  • 1: Open the socket server

AT+CIPMODE=<mode>

AT+CIPMODE?

Setting transparent mode (data from the socket client will be sent to the serial port as is) or connection channel specific mode (+IPD,<connection channel>,<length>) segments.

Data sent from the socket client will be broken into multiple unsolicited (+IPD,<connection channel>,<length>) segments.

<mode>is as follows:

  • 0: Data received will be sent to the serial port with a +IPD,<connection channel>,<length> format. (AT+CIPMUX=[0,1])
  • 1: Data received will be sent to the serial port as a data stream. (AT+CIPMUX=0)

AT+CIPSTO=<time>

AT+CIPSTO?

Setting the automatic socket client disconnection timeout from 1 to 28800 seconds due to inactivities.

Packetized data from the unit

Unsolicited data packet (+IPD, <connection channel>,<length>).

Table 1.2: The ESP8266 AT command set (Source: SparkFun Electronics)

Using AT commands

Every AT command starts with the letters AT. Here's an example:

AT+GMR <CR> 

Type the AT command AT+GMR and press the Enter key. Don't type <CR>. The CR indicates carriage return.

This will return the firmware version ID of the ESP8266 module, as shown in Figure 1.8:

Figure 1.8: Terminal output for the AT+GMR command

Likewise, you can run any AT command with the PuTTY terminal to execute on ESP8266 through the serial connection.

You have been reading a chapter from
ESP8266 Robotics Projects
Published in: Nov 2017
Publisher: Packt
ISBN-13: 9781788474610
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image