establish-serial-connection.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Establish Serial Connection with ESP32
  2. ======================================
  3. This section provides guidance how to establish serial connection between ESP32 and PC.
  4. Connect ESP32 to PC
  5. --------------------
  6. Connect the ESP32 board to the PC using the USB cable. If device driver does not install automatically, identify USB to serial converter chip on your ESP32 board (or external converter dongle), search for drivers in internet and install them.
  7. Below are the links to drivers for ESP32 boards produced by Espressif:
  8. * ESP32-PICO-KIT and ESP32-DevKitC - `CP210x USB to UART Bridge VCP Drivers <https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers>`_
  9. * ESP32-WROVER-KIT and ESP32 Demo Board - `FTDI Virtual COM Port Drivers <http://www.ftdichip.com/Drivers/D2XX.htm>`_
  10. Above drivers are primarily for reference. They should already be bundled with the operating system and installed automatically once one of listed boards is connected to the PC.
  11. Check port on Windows
  12. ---------------------
  13. Check the list of identified COM ports in the Windows Device Manager. Disconnect ESP32 and connect it back, to verify which port disappears from the list and then shows back again.
  14. Figures below show serial port for ESP32 DevKitC and ESP32 WROVER KIT
  15. .. figure:: ../_static/esp32-devkitc-in-device-manager.png
  16. :align: center
  17. :alt: USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  18. :figclass: align-center
  19. USB to UART bridge of ESP32-DevKitC in Windows Device Manager
  20. .. figure:: ../_static/esp32-wrover-kit-in-device-manager.png
  21. :align: center
  22. :alt: Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  23. :figclass: align-center
  24. Two USB Serial Ports of ESP-WROVER-KIT in Windows Device Manager
  25. Check port on Linux and MacOS
  26. -----------------------------
  27. To check the device name for the serial port of your ESP32 board (or external converter dongle), run this command two times, first with the board / dongle unplugged, then with plugged in. The port which appears the second time is the one you need:
  28. Linux ::
  29. ls /dev/tty*
  30. MacOS ::
  31. ls /dev/cu.*
  32. .. _linux-dialout-group:
  33. Adding user to ``dialout`` on Linux
  34. -----------------------------------
  35. The currently logged user should have read and write access the serial port over USB. On most Linux distributions, this is done by adding the user to ``dialout`` group with the following command::
  36. sudo usermod -a -G dialout $USER
  37. Make sure you re-login to enable read and write permissions for the serial port.
  38. Verify serial connection
  39. ------------------------
  40. Now verify that the serial connection is operational. You can do this using a serial terminal program. In this example we will use `PuTTY SSH Client <http://www.putty.org/>`_ that is avilable for both Windows and Linux. You can use other serial program and set communication parameters like below.
  41. Run terminal, set identified serial port, baud rate = 115200, data bits = 8, stop bits = 1, and parity = N. Below are example screen shots of setting the port and such transmission parameters (in short described as 115200-8-1-N) on Windows and Linux. Remember to select exactly the same serial port you have identified in steps above.
  42. .. figure:: ../_static/putty-settings-windows.png
  43. :align: center
  44. :alt: Setting Serial Communication in PuTTY on Windows
  45. :figclass: align-center
  46. Setting Serial Communication in PuTTY on Windows
  47. .. figure:: ../_static/putty-settings-linux.png
  48. :align: center
  49. :alt: Setting Serial Communication in PuTTY on Linux
  50. :figclass: align-center
  51. Setting Serial Communication in PuTTY on Linux
  52. Then open serial port in terminal and check, if you see any log printed out by ESP32. The log contents will depend on application loaded to ESP32. An example log by ESP32 is shown below.
  53. .. highlight:: none
  54. ::
  55. ets Jun 8 2016 00:22:57
  56. rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  57. ets Jun 8 2016 00:22:57
  58. rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  59. configsip: 0, SPIWP:0x00
  60. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  61. mode:DIO, clock div:2
  62. load:0x3fff0008,len:8
  63. load:0x3fff0010,len:3464
  64. load:0x40078000,len:7828
  65. load:0x40080000,len:252
  66. entry 0x40080034
  67. I (44) boot: ESP-IDF v2.0-rc1-401-gf9fba35 2nd stage bootloader
  68. I (45) boot: compile time 18:48:10
  69. ...
  70. If you see some legible log, it means serial connection is working and you are ready to proceed with installation and finally upload of application to ESP32.
  71. .. note::
  72. For some serial port wiring configurations, the serial RTS & DTR pins need to be disabled in the terminal program before the ESP32 will boot and produce serial output. This depends on the hardware itself, most development boards (including all Espressif boards) *do not* have this issue. The issue is present if RTS & DTR are wired directly to the EN & GPIO0 pins. See the `esptool documentation`_ for more details.
  73. .. note::
  74. Close serial terminal after verification that communication is working. In next step we are going to use another application to upload ESP32. This application will not be able to access serial port while it is open in terminal.
  75. If you got here from section :ref:`get-started-connect` when installing s/w for ESP32 development, then go back to section :ref:`get-started-configure`.
  76. .. _esptool documentation: https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection#automatic-bootloader