# Programming
## {{@218#bkmrk-open-iot-and-iiot-ga}}
### Install IDE
Please, follow the instructions located [here](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) to install the ESP-IDF framework on your local machine. ESP-IDF is available both on [Windows](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html) and [Linux](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html). It can also be installed through some popular IDEs: [VS Code](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md) or [Eclipse](https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md).
ESP-IDF is required to build the examples written in C for the device. However, it can be also programmed in [MicroPython](https://docs.micropython.org/en/latest/esp32/tutorial/intro.html) ([Thonny](https://thonny.org/)).
### Connect the programmer
ESP32 IoT and IIoT Gateways can be programmed only with the external hardware programmer (for example [**P03**](https://doc.redisage.com/link/219#bkmrk-page-title)) connected via the Tag-Connect connector. After connecting it to the board and a PC, a new COM port should be available.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/image-4.webp) | [](https://doc.redisage.com/uploads/images/gallery/2024-06/image-6.webp) |
### Connect the power supply
In order to successfully flash the device, it has to be connected to the power supply (9 - 30 VDC) using the VCC and GND connectors.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/EkQimage.png)
### Create your own programs
After all of the above steps are done, the device should be ready to be programmed.
### Build, flash and monitor the device
#### VS Code ESP-IDF extension
1. Make sure that there is a ".vscode" folder in the project tree. If not, add it with the "F1" + "ESP-IDF: Add vscode Configuration Folder" command.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/Rpfimage.png)
2. Set your device target with "F1" + "ESP-IDF: Set Espressif Device Target". Then choose current workspace folder and then "esp32". Lastly choose "Custom board" and confirm it.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/GX6image.png)
[](https://doc.redisage.com/uploads/images/gallery/2024-06/ucEimage.png)
[](https://doc.redisage.com/uploads/images/gallery/2024-06/RY3image.png)
3. Set port where the device is attached to with "F1" + "ESP-IDF: Select Port to Use (COM, tty, usbserial)".
[](https://doc.redisage.com/uploads/images/gallery/2024-06/Qkkimage.png)
4. Finally select "UART" flash method with "F1" + "ESP-IDF: Select Flash Method".
[](https://doc.redisage.com/uploads/images/gallery/2024-06/Aa9image.png)
[](https://doc.redisage.com/uploads/images/gallery/2024-06/3PAimage.png)
5. Build your project, flash it to the device and open a serial monitor with the "F1" + "ESP-IDF: Build, Flash and Start a Monitor on your Device". If everything was set properly the serial monitor should open after a successful flash.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/PjNimage.png)
#### Thonny
1. Hit "F5" button in Thonny IDE to run the current script.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/Q0Kimage.png)
2. Click "File" -> "Save copy..." -> "MicroPython device" and save this file as "main.py" in order to execute this code every time the gateway powers on.
[](https://doc.redisage.com/uploads/images/gallery/2024-06/9OGimage.png)
[](https://doc.redisage.com/uploads/images/gallery/2024-06/y5yimage.png)
[](https://doc.redisage.com/uploads/images/gallery/2024-06/Wn4image.png)