Skip to main content

Get Started

ESP32 Open IoT and IIoT Gateways (P01 & P02)

At the beginning it is necessary to set up a development environment. Programming gateways are supported on every popular operating systems like Windows, Linux or MAC OS. This document was prepared in reference to Windows.

ESP-IDF framework

The main tool is ESP-IDF framework provided by Espressif. To get more information about installation, visit manufacturer’s 
website: Get Started - ESP32 -  — ESP-IDF Programming Guide latest documentation.

Manual Installation of ESP-IDF: Standard Setup of Toolchain for Windows - ESP32 -  — ESP-IDF Programming Guide latest documentation.

During the ESP-IDF installation you might be asked for install Eclipse additionally.

After successful process it is necessary to add new enviroment variables.

Variables names:

  • IDF_PATH - paste the path of the directory with ESP-IDF framework
  • IDF_TOOLS_PATH - paste the path of the directory with ESP-IDF tools

f8899686-b97f-47ad-9a49-32b7a88b725c.png

11e4e082-6da0-4bff-9e2b-33098e5062b4.png

Finally you can run ESP-IDF CMD and start to manage your project. There should be an icon on the desktop or easy access to ESP-IDF.

e4d424cb-4a06-45e7-9c6b-3160777c93fe.png

Create new project

idf.py create-project -p <name>

Build project

idf.py -p <port> build

Flash project

idf.py -p <port> flash

idf.py -p <port> flash monitor

Erase flash

esptool.py --port <port> erase_flash

MinGW

Download MinGW with GUI from MinGW - Minimalist GNU for Windows and install on your PC. After a successful installation run MinGW Installation Manager (GUI).

04cab29c-1dae-42b6-a0c6-d013d37ffadd.png

Now we need to install Basic Setup. Right click on every square fields in “Package” tab, then “Mark for Installation”. Next, in “Installation” tab click on “Apply Changes” and then “Apply”.

67a06d6c-6dc6-4b4d-a4c4-25afbe706867.png 5e24edfe-6c42-48ba-bfb8-7701b7b71c77.png

To check if the installation is successfull, open Command line and type:

gcc --version

d9abc443-bde5-4a2d-b6c4-55c0820cbe99.png

IDE

You can edit code in your preferred IDE as ESP-IDF is handling the final build and flash.

Recommanded IDEs:

Visual Studio Code

  • Download the package with example projects for IoT Gateway.
  • Select one of the demos and copy it to a new directory.
  • Open Visual Studio Code and click on the extension tab.
  • Install and configure C/C++ extensions.

1dbaaf87-a363-40c9-a7e7-0ac416be86bd.png

  • Open directory in VS Code.

7bfa65be-c841-4617-a3e5-b5c0a473d15d.png

  • If errors occur, edit “includePath” settings.

5aa5ab7d-6595-47e4-bdd4-f9b552cbee39.png

  • Add the line "${env:IDF_PATH}/**".

c3529dd3-920f-44dd-beb6-9629385e9aaf.png

  • Now code is ready to be modified.

  • To build or flash project, use ESP-IDF CMD.

Visual Studio Code provides an extension “Espressif IDF” which has some issues at this moment. However it is not essential for editing code.

CodeBlocks

  • Download the package with example projects for IoT Gateway.
  • Select one of the demos and copy it to a new directory.
  • Run ESP-IDF CMD, set the path to your project and then generate project for CodeBlocks:
cmake -G "CodeBlocks - MinGW Makefiles"

1ccc0952-02b0-414f-93ee-aae2e4ce9fd7.png

0b03cd5a-5116-422e-a5de-c47d6e7a569b.png

  • Run CodeBlocks. Click on "File → Open…", find .cbp type file and click on “Open”.

7d20079f-f797-4a2d-9d74-4eb40a308cb3.png

  • After this, there should be a project tree available and code is ready to be modified.

06b76408-0f58-47f0-8894-a3e115cf8562.png

  • To build or flash project, use ESP-IDF CMD.

Thonny IDE

  • Download and install Python interpreter.
  • Download the package with example projects for IoT Gateway.
  • Select one of the demos and copy it to a new directory.
  • Run ESP-IDF CMD, erase flash using:
esptool.py --port <COMX> erase_flash

5af1e224-2094-49a3-96c6-80545ce5d8f5.png

  • Download firmware which allows to run microPython.

  • Flash .bin file using:

 esptool.py --port <COMX> write_flash -z 0x1000 <name_of_the_bin_file>

2aae30b3-126b-420b-ad12-a8244c9384de.png

  • Open serial port monitor like “Putty”, set COM port, baudrate, connection type to serial and click on “Open”.

e6a97031-3316-44aa-b31a-8259727b87d8.png

  • Now you can run Python console on ESP32.

2ba64294-f54b-4a64-a837-dae5c60e23d9.png

  • Download and install Thonny IDE.

  • Click on "Tools → Options → Interpreter". In this tab you can choose an interpreter and COM port.

57f3a021-1371-45d6-b13f-c21b10f9d21c.png

  • After all the process Thonny IDE is ready to work.

f70a61dc-1ec9-4ea3-9960-e90cfd98c478.png

  • To flash the demo, open file in Thonny IDE. Next click on green button to run the current script.

Uploading firmware

To upload firmware, you need to use external programmer with Tag-connect.

3665aeb3-48ae-44d7-9f2d-4d2decaefb59 (1).png