A JavaScript browser library for reading ESP32 Non-Volatile Storage (NVS) entries over USB using WebSerial.
- Reads specified NVS partitions or auto-detects them using device's partition table
- Supports all NVS types (integers, strings, blobs)
- Communicates directly with the ESP32 over USB using WebSerial
- Efficiently reads just enough data to find what you are looking for
- Can retrieve specific entry or get all entries
- Provides both function-based and class-based interfaces
- Includes built-in output formats for JSON and HTML
- Easily customizable output via user-friendly iterator pattern
WebSerial is a non-standard feature and is only supported in Chromium-based browsers. See CanIUse for browser support.
The library can either be downloaded using NPM or loaded on request from a CDN. Local install is only required for full TypeScript types support.
Import the library from CDN into your JavaScript code like this:
import { NVS } from "https://cdn.jsdelivr.net/gh/FanatiQS/esp-nvs-js@master/nvs.js";Install the library through NPM and then import it into your JavaScript code like this:
npm install fanatiqs/esp-nvs-jsimport { NVS } from "esp-nvs-js";Other than the limited browser support mentioned above, WebSerial also only works on HTTPS/localhost and can only be triggered by a UserGesture, not on load. This means that all examples need to be called from some kind of user input, like a button press or other form of user initiated trigger.
Get the value for a specific entry.
Look at examples/simple.html (demo) for a complete example.
const nvs = new NVS(await navigator.serial.requestPort());
const chan = await nvs.get("nvs.net80211", "sta.chan");
console.log(chan);Get all values as JSON.
Look at examples/json.html (demo) for a complete example.
const nvs = new NVS(await navigator.serial.requestPort());
await nvs.all();
console.log(nvs.toJSON());Render all values in HTML table.
Look at examples/table.html (demo) for a complete example.
const nvs = new NVS(await navigator.serial.requestPort());
await nvs.all();
document.body.appendChild(nvs.toHTML());Get all values through iterator.
const nvs = new NVS(await navigator.serial.requestPort());
await nvs.all();
for (const [ namespace, key, value ] of nvs) {
console.log(namespace, key, value);
}- No support for encrypted NVS partitions
- No delete or write support
- Add tests
- Add delete support
- Add write support
- Add support for encrypted partitions