70 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
# esp/cpp
 | 
						|
 | 
						|
```bash
 | 
						|
shaunrd0/klips/esp/cpp
 | 
						|
├── 01_led-button               # Simple LED circuit controlled by an on board button.
 | 
						|
├── 02_led-button-web           # LED controlled by a button or within a web browser.
 | 
						|
├── 03_temp-humidity-web        # Temperature and humidity sensor within a web browser.
 | 
						|
├── 04_esp-idf-arduino          # CMake example instead of Arduino IDE for ESP development.
 | 
						|
├── 05_temp-humidity-web        # Temperature and humidity sensor within a web browser.
 | 
						|
├── 06_i2c-scanner              # Simple I2C device scanner.
 | 
						|
├── 07_lcd-panel-i2c            # Drawing to a LCD display with LVGL over I2C.
 | 
						|
├── ESP32-basic-starter-kit.pdf # PDF for tutorials in ESP32 starter kit.
 | 
						|
├── ESP32-dev-module.png
 | 
						|
└── README.md
 | 
						|
```
 | 
						|
 | 
						|
Examples 1-3 are built using the Arduino IDE.
 | 
						|
 | 
						|
All examples after `04_esp-idf-arduino` are built with cmake and the [ESP-IDF](https://github.com/espressif/esp-idf).
 | 
						|
 | 
						|
[Arduino ESP32 GitHub](https://github.com/espressif/arduino-esp32) \
 | 
						|
[Arduino ESP32 API reference](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html)
 | 
						|
 | 
						|
If you are working in CLion, I recommend reading [this article](https://developer.espressif.com/blog/clion/) to get started.
 | 
						|
Basic instructions for installing the ESP-IDF and creating a project are below.
 | 
						|
 | 
						|
## Dependencies
 | 
						|
 | 
						|
Install the [ESP-IDF](https://github.com/espressif/esp-idf?tab=readme-ov-file#setup-build-environment)
 | 
						|
 | 
						|
```bash
 | 
						|
# https://docs.espressif.com/projects/esp-idf/en/v5.3.2/esp32/get-started/linux-macos-setup.html#for-linux-users
 | 
						|
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
 | 
						|
 | 
						|
git clone --recursive https://github.com/espressif/esp-idf
 | 
						|
cd esp-idf
 | 
						|
./install.sh
 | 
						|
. ./export.sh
 | 
						|
```
 | 
						|
 | 
						|
In CLion there is an official [Serial Monitor](https://plugins.jetbrains.com/plugin/8031-serial-port-monitor) plugin, or use ESP-IDF -
 | 
						|
 | 
						|
```bash
 | 
						|
idf.py monitor -b 115200
 | 
						|
```
 | 
						|
 | 
						|
## Starting Over
 | 
						|
 | 
						|
To set up this project from scratch the following commands were used
 | 
						|
 | 
						|
```bash
 | 
						|
source /path/to/esp-idf/export.sh
 | 
						|
idf.py create-project my-project
 | 
						|
cd my-project
 | 
						|
idf.py set-target esp32
 | 
						|
idf.py add-dependency "espressif/arduino-esp32^3.1.1"
 | 
						|
 | 
						|
# Autostart Arduino for use of `loop()` and `setup()` functions
 | 
						|
# You can also use the esp-idf `app_main()` function if preferred
 | 
						|
# https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html#configuration
 | 
						|
# You can alternatively do this in the GUI tool `idf.py menuconfig`
 | 
						|
echo "CONFIG_AUTOSTART_ARDUINO=y" >> sdkconfig
 | 
						|
sed -i -e 's/CONFIG_FREERTOS_HZ=100/CONFIG_FREERTOS_HZ=1000/' sdkconfig
 | 
						|
 | 
						|
# Build the project
 | 
						|
idf.py build
 | 
						|
```
 | 
						|
 | 
						|
To set this project up in CLion, see [JetBrains documentation](https://www.jetbrains.com/help/clion/esp-idf.html#env-vars).
 |