Is it possible to input and store Blynk AUTH TOKEN via Serial on first boot (ESP32 with Ethernet)?

Hi,

I’ve built a custom board using the ESP32 with an Ethernet connection only — no WiFi support (at least for now). Because of this, I can’t use Blynk.Edgent and I’m currently hardcoding the AUTH TOKEN directly into the sketch.

This setup becomes problematic as the number of deployed devices increases, since I have to recompile and reflash the firmware with a new AUTH TOKEN for each device.

I’d like to know if it’s possible to input the AUTH TOKEN via Serial on the first boot, save it to NVS (non-volatile storage), and use it afterward without recompiling the code for each device.

Here’s the general logic I’m aiming for:

  1. On boot, check if an AUTH TOKEN is stored in NVS.
  2. If it exists, start Blynk using the stored token.
  3. If it doesn’t exist, wait for the user to input the token via Serial.
  4. Once received, save it to NVS and reboot the device.

Is this possible with the current Blynk library (non-Edgent)?
If you have any example code or tips, I’d really appreciate it!

Thanks in advance.

Hello @Jun

You can get AUTH TOKEN via metadata

Bit of a catch-22 with that approach though - the device can’t access the metadata without first connecting to Blynk, and it can’t connect to Blynk without the auth token.

What @Jun is asking is clearly possible, as solutions like WiFi Manager allow the auth token to be inputted and stored, but I don’t have any examples I can point you to.

What NVS system are you planning to utilise?

Pete.

I’m not sure if this fully answers your question, but just to clarify — I’m planning to use the built-in flash of the ESP32 module, and I’ll be using the Preferences library (which uses NVS under the hood) to store the AUTH token.

1 Like