Separate codebases for different boards using Web IDE

Hi all,

I’ve recently purchased 1 argon and 2 borons and have claimed them in my account. Now, I’d like to add the blynk libraries to them to work with their service.

In the process of getting things working with blynk, I have to update a file with a unique auth token. This token is different for each board… but with the particle Web IDE, it looks like I can only push the exact same code to all 3 boards?..

Ideally, I want each board to have all the same files, except with a few lines different in each, which contains its name and unique auth token.

How would I go about doing this with Particle? I realize this is a noob question. Thank you for the help…

Welcome to the Particle community.

You could maintain 3 separate codebases, or you could include all tokens and names in the firmware and have the device pick its name and token from a table at run time.

The table could be represented using an array of structs:


struct Blynk {
    char device_id[25];
    char auth_token[33];
    char blynk_name[21];

struct Blynk blynk_data[BLYNK_DEVICES] = {
    {"0123456701xxxxxxxxxxxxxx", "9876543201xxxxxxxxxxxxxxxxxxxxxx", "device1"},
    {"0123456702xxxxxxxxxxxxxx", "9876543202xxxxxxxxxxxxxxxxxxxxxx", "device2"},
    {"0123456703xxxxxxxxxxxxxx", "9876543203xxxxxxxxxxxxxxxxxxxxxx", "device3"},

To retrieve the auth_token and blynk_name given a device_id, you could use the following:

char* auth_token = NULL;
char* blynk_name = NULL;

int get_blynk_data(const char* device_id) {
    for (int i = 0; i < BLYNK_DEVICES; ++i) {
        if (strcmp(blynk_data[i].device_id, device_id) == 0) {
            auth_token = blynk_data[i].auth_token;
            blynk_name = blynk_data[i].blynk_name;
            return 0;
    return 1;

Within your firmware you can use System.deviceID() to get the deviceID of the device. During early run time in the setup() function, you can pass the deviceID to get_blynk_data() to have the auth_token and blynk_name global variables set:

void setup() {
    if (get_blynk_data(System.deviceID().c_str()) == 0) {
        Serial.printf("Blynk Auth Token: %s, Blynk Name: %s\n", auth_token, blynk_name);
    } else {
        Serial.println("Failed to get blynk data!");

Afterwards, you can use auth_token and blynk_name anywhere in your application to refer to the data associated with the device currently running the firmware.

I don’t have a Particle device with me at the moment to test this on, but this approach should work.

Excellent, I will try on Monday! Thank you

1 Like