Page 1 of 1

How to run scripts for esp32 in esp-idf

Posted: Thu Jul 06, 2023 8:00 am
by mmmunir966
Hello,

I am seeking assistance with running scripts on the ESP32 using the ESP-IDF framework. My goal is to develop an application that can host a web server to provide various settings to users. This application will include JavaScript (JS), Cascading Style Sheets (CSS), and Hypertext Markup Language (HTML) files. Additionally, I would like to incorporate configuration files for controlling RGB LEDs. The main objective is to enable the ESP32 device to detect any updates in the JS, CSS, HTML, or configuration files, download them, and store them in the device's flash memory without resorting to an Over-The-Air (OTA) update.

In simpler terms, I want to update the frontend and configuration files on the ESP32 without making any changes to the backend code.

I have a few questions:

Is it possible to achieve the mechanism described above using the ESP32 and ESP-IDF?
What scripting language does the ESP32 support for running scripts?
It would be greatly appreciated if you could provide an example code demonstrating this process.

Re: How to run scripts for esp32 in esp-idf

Posted: Thu Jul 06, 2023 3:52 pm
by bidrohini
It is possible to achieve the mechanism you described using the ESP32 and ESP-IDF framework. The ESP32 supports executing JavaScript (JS) code using the Duktape library, which is included in the ESP-IDF framework. Duktape is an embeddable JavaScript engine that allows you to run JS scripts on the ESP32.

Re: How to run scripts for esp32 in esp-idf

Posted: Fri Jul 07, 2023 7:12 am
by MicroController
I want to update the frontend and configuration files on the ESP32 without making any changes to the backend code
Easily possible. You can use a dedicated partition in flash and read/write/HTTP-serve files from there as desired via VFS, see e.g. https://github.com/espressif/esp-idf/tr ... age/spiffs and https://github.com/espressif/esp-idf/tr ... le_serving
What scripting language does the ESP32 support for running scripts?
Do you need that? From what you wrote, only the frontend (running in a browser) needs to be so flexible. Embedding a whole scripting language in your application would be pretty resource-hungry, compared to interpreting some configuration files at runtime in C.