I have similar code that I have running on multiple esp’s in a few different rooms (agriculture related) but every time I make an update, I have to go through and change my tokens (among a few other items). It would be nice to just change one variable at the top of my code (in this case, the room number) and upload. I’m trying to do something like:
int roomNumber = 2
char auth[] = “authCode”
//room 1 token
rm1token = “12312f23234”
//room 2 token
rm2token = “123123ljksdfj”
void setup() {
Switch(roomNumber) {
case 1:
authCode = rm1token;
case 2:
authCode = rm2token;
Blynk.begin(auth, ssid, pass, “x.x.x.x”);
}
Any thoughts? And I’m always up for a simpler solution (perhaps some python script to upload code )
Duplicate your code for all your rooms… but add the following right at the top first.
Then just change the ROOM value and it will pick a difference AUTH code which you can just keep in your code all the time.
#define ROOM 1 // change your room here and your auth code will update during compile
#if (ROOM == 1)
#define AUTH "12312f2234" // auth for room 1
#elif (ROOM == 2)
#define AUTH "1232335443" // auth for room 2
#elif (ROOM == 3)
#define AUTH "1212121211" // auth for room 3
#endif
Darn it… @Jamin, stop being so smrtypnts (kidding, you da man )… I had just found the #if reference I was looking for, and was trying to figure out how it would apply here
Ahh, well… I have my strengths… unfortunately coding isn’t quite one of them… yet…
PS - wouldn’t the AUTH = still require a string? as in #define char auth[] = "12312f2234" // auth for room 1 ? Or are you responding from your phone, while in traffic, or on the beach again, and just providing pseudocode