Oct. 26, 2024, 11:45 p.m.

ESP32 Setup

First thing we need to do is to install all the software that's needed to build ESP32 projects. We do that by cloning the esp-idf repository.




  1. To do that we create a folder with mkdir -p ~/esp the -p option means that no error is thrown if the folder already exists and also creates all parent folders. Then we cd into the folder just created, and inside we use the command git clone --recursive https://github.com/espressif/esp-idf.git.


  2. Now we need to set up the tools we need to compile projects and such things. For this, we go to the folder ~/esp/esp-idf and run the command .install.sh esp32,esp32s2,esp32s3 to install the packages for these three esp chips.


  3. To add the installed tools to the path so we can use them from the command line, we add an alias to our .bash_aliases file. The line we need to add is alias get_idf='. $HOME/esp/esp-idf/export.sh'. So whenever we start to work on esp projects, we can just run get_idf and everything gets set up.


  4. After that, we go back to the ~/esp folder. With the command cp -r $IDF_PATH/examples/get-started/hello_world . we copy an example project into the folder we are currently inside, so ~/esp in our case. Remember that before that command will work, we will need to run get_idf, the alias we created in the step before.


  5. Now we cd into the folder that we copied with cd hello_world/.


  6. Inside that folder, we choose what esp chip we want to target, in my case it's an ESP32S3, so we run idf.py set-target esp32s3.


  7. Then we run idf.py menuconfig which will open up a CLI menu to make some configurations.


  8. Because I have an ESPS3 with octal ram I enter the serial flasher config and make the changes, I also set the flash size to 32MB because that's what my chip has. Now we can close the menu with ESC and save with Y.


  9. Now we can build our program with idf.py build. If no errors occur, we can flash it onto the device with idf.py -p PORT flash where PORT is the port you have to look up on your computer, on Linux likely something like /dev/ttyACM0.


  10. The last step to see if everything is running fine is to monitor the output of our program we just uploaded. We do that with idf.py -p PORT monitor. When everything works, you should see some printout about your esp chip that restarts every ten seconds, you can stop the program with CTRL-].


Congratulations, you just created and uploaded a program on your ESP32. :)