ESP-01 Module |
Pin
|
Name
|
Description
|
---|---|---|
1 | GND | Ground |
2 | U0TXD | UART0 Transmit, GPIO1, (blue LED) |
3 | GPIO2 | U1TXD, I2C_SDA, has internal pull-up |
4 | CHIP_EN | Chip Enable, active high |
5 | GPIO0 | Has internal pull-up, (for Flash programming mode) |
6 | EXT_RSTB | External reset signal, active low, pull-up resistor |
7 | U0RXD | UART0 Receive, GPIO3, has internal pull-up |
8 | VDD | +3.3V power input |
Pull GPIO0 low at power up to enter the Flash programming mode.
The ESP-03 has more I/O pins. The board is 17.4mm x 12.2mm with 2mm pin spacing.
ESP-03 Module |
GPIO12 | MTDI, HSPI_MISO, PWM0 | |
GPIO13 | MTCK, HSPI_MOSI, UART0_CTS | |
GPIO14 | MTMS, HSPI_CLK, I2C_SCL, PWM2 | |
GPIO15 | MTDO, HSPI_CS, UART0_RTS, PWM1 | |
GPIO16 | Deep-Sleep Wakeup | |
Module Schematic |
For this version of the firmware, the baudrate is 9600. It had to be determined by looking at the scope of the TX signal. (Note that some documentation says 115200, but that may be for an earlier version.)
The ESP module starts as an access point, which can be connected from a PC WiFi adapter. Open a server TCP port on the PC, using nc. We can start the communication,
AT+CWMODE=2 # set mode AP
AT+CWSAP? # returns AP: ssid, password, channel, encryption
AT+CIFSR # returns the IP address
AT+CIPSTART="TCP","192.168.4.100",6789 # open a TCP connection
AT+CIPSEND=4 # send 4 bytes, type in the
The message shows at the PC terminal running nc, and anything you type in nc is displayed at the serial terminal.
To create a TCP server
AT+CIPMUX=1 # must be 1 for server
AT+CIPSERVER=1,6789 # create server port 6789
At this point, we can connect to the server from the PC and whatever we send is displayed.
To send data back,
AT+CIPSEND=0,5 # send 5 bytes, must specify id
Another way to try is to set up an access point (AP) on a PC and have the module connect to it. The command sequence is as follows,
AT+CWMODE=3 # set mode to station and AP
AT+CWLAP # list the available APs
AT+CWJAP="AP","Password" # to join an AP
AT+CIPSTART="TCP","192.168.12.1",1234 # open a TCP connection
AT+CIPSEND=4 # send 4 bytes, type in the
Next we check the compiler toolchain and the SDK.
The toolchain is xtensa-lx106-elf. The latest SDK is esp_iot_sdk_v0.9.4. The default app IoT_Demo is built by running make and gen_misc.sh in the app directory. To upload through serial port, set GPIO0 low and GPIO2 high and run in the bin directory,
esptool.py is a python program to communicate with the ROM bootloader. The baud rate is non-standard 74880.~/esptool-py/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 eagle.app.v6.flash.bin 0x40000 eagle.app.v6.irom0text.binConnecting...Erasing flash...Writing at 0x00008c00... (100 %)Erasing flash...Writing at 0x00067000... (100 %)Leaving...
The at_v0.20 only works with esp_iot_sdk_v0.9.3 . It can be built and uploaded to the module like above. The default baud rate is 115,200. After spewing some garbage, it is ready to accept AT commands.
Great article. Now I can make my own wireless networkable module without any formal IOT training . But I would suggest that colleges should offer IOT projects for engineering students in their final year, which can help bring in more innovative IOT products in the future.
ReplyDelete