How to run scripts for esp32 in esp-idf

mmmunir966
Posts: 12
Joined: Tue Feb 08, 2022 2:02 pm

How to run scripts for esp32 in esp-idf

Postby mmmunir966 » Thu Jul 06, 2023 8:00 am

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.

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

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

Postby bidrohini » Thu Jul 06, 2023 3:52 pm

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.

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

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

Postby MicroController » Fri Jul 07, 2023 7:12 am

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.

Who is online

Users browsing this forum: Baidu [Spider] and 282 guests