My template id is not exist and the APP's display sometimes changes

• ESP8266 with NodeMCU 1.0 (ESP-12F).
• Smartphone Android
• Blynk server
• Blynk Library version 1.0.1

I encountered some problems when learning how to use templates to connect the ESP8266 to my smart phone app. I use the sample of blynk.Edgent_ESP8266 in Arduino IDE, that is part of my code.

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPL5_FF_0-F"
#define BLYNK_DEVICE_NAME "Quickstart Template"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD

#include "BlynkEdgent.h"

void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
}

and the result in Serial is above.

>[397] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266

[399] --------------------------
[402] Product:  Quickstart Template
[405] Firmware: 0.1.0 (build May 22 2022 22:55:04)
[409] Token:    ...M01_
[411] Device:   ESP8266 @ 80MHz
[414] MAC:      98:CD:AC:0C:C2:0A
[417] Flash:    4096K
[419] ESP core: 3.0.2
[421] ESP SDK:  2.2.2-dev(38a443e)
[424] Boot Ver: 31
[426] Boot Mode:1
[428] FW info:  467904/1626112, MD5:9cb7cd9755cf9a7b3608ee4e6f89366c
[635] Free mem: 31256
[635] --------------------------
[635] INIT => CONNECTING_NET
[637] Connecting to WiFi: qsf2902
[4677] Using Dynamic IP: 192.168.0.102
[4677] CONNECTING_NET => CONNECTING_CLOUD
[20306] Current time: Sun May 22 14:56:08 2022
[20307] Connecting to blynk.cloud:443
[23259] Redirecting to ny3.blynk.cloud:443
[23272] Current time: Sun May 22 14:56:11 2022
[23272] Connecting to ny3.blynk.cloud:443
[26104] Ready (ping: 12ms).
[26475] CONNECTING_CLOUD => RUNNING
[26506] Server: Template with id TMPL5_FF_0-F doesn't exist
[35412] RUNNING => CONNECTING_CLOUD
[35424] Current time: Sun May 22 14:56:23 2022
[35424] Connecting to blynk.cloud:443
[46814] Redirecting to ny3.blynk.cloud:443
[46827] Current time: Sun May 22 14:56:34 2022
[46827] Connecting to ny3.blynk.cloud:443
[49639] Ready (ping: 12ms).
[49922] Server: Template with id TMPL5_FF_0-F doesn't exist
[49922] CONNECTING_CLOUD => RUNNING
[58992] RUNNING => CONNECTING_CLOUD
[59004] Current time: Sun May 22 14:56:46 2022
[59004] Connecting to blynk.cloud:443
[69463] Redirecting to ny3.blynk.cloud:443
[69475] Current time: Sun May 22 14:56:57 2022
[69476] Connecting to ny3.blynk.cloud:443
[72256] Ready (ping: 12ms).
[72563] Server: Template with id TMPL5_FF_0-F doesn't exist

I checked my template ID carefully and I don’t know what happen.

The another question is that my APP is sometimes similar to the Cloud (two device) and sometimes different (one device named quickstart Device), that’s my screenshot, I want to know what happened.


I wish someone can help me. Thank you!

Have you copied and pasted the template ID and device name from the web console into your sketch?

I’m a bit confused by the fact that you’re using QuickStart (which uses static provisioning of Auth tokens and WiFi credentials) with the Edgent sketch - which uses dynamic provisioning.

You would be far better deleting the QuickStart template via the web console, creating a template and adding the datastreams you want, then pasting the template ID and device name into your sketch and going from there.

Also, you really need to un-comment a board type and check that the pins in Settings.h correspond exactly to your board. You should read this for more info on that subject…

Pete.

Thank you for your prompt reply, Pete!

It worked like you said it would, and it still wrong, so I tried to use the QuickStart template that connected successfully to my console and APP to run my code. As before, this still not work.

I have copied and pasted them, but it still wrong. Then I tried to constructed different template and copy their ID and name, that my new code.

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPL232uG5ga"
#define BLYNK_DEVICE_NAME "DHT11"

#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define USE_NODE_MCU_BOARD
#include "BlynkEdgent.h"
#include "DHT.h"
#define DHTPIN D2 
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
float t, h;

void sendSensor()
{
  h = dht.readHumidity();
  t = dht.readTemperature();  
  Blynk.virtualWrite(V0, h);
  Blynk.virtualWrite(V1, t);
}

void setup()
{
  Serial.begin(9600);
  dht.begin();
  BlynkEdgent.begin();
  delay(2000); 
  timer.setInterval(1000L, sendSensor); 
}

void loop() 
{
  BlynkEdgent.run();
  timer.run(); // Initiates SimpleTimer
}

that’s my setting.h code

#define BOARD_HARDWARE_VERSION        "1.0.0"

/*
 * Board configuration (see examples below).
 */

#if defined(USE_NODE_MCU_BOARD)

  #warning "NodeMCU board selected"

  // Example configuration for NodeMCU v1.0 Board
  #define BOARD_BUTTON_PIN            0
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN_R             2
  //#define BOARD_LED_PIN_G           D7
  //#define BOARD_LED_PIN_B           D6
  #define BOARD_LED_INVERSE           true
  #define BOARD_LED_BRIGHTNESS        255

#elif defined(USE_SPARKFUN_BLYNK_BOARD)

  #warning "Sparkfun Blynk board selected"

  // Example configuration for SparkFun Blynk Board
  #define BOARD_BUTTON_PIN            0
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN_WS2812        4
  #define BOARD_LED_BRIGHTNESS        64

#elif defined(USE_WITTY_CLOUD_BOARD)

  #warning "Witty Cloud board selected"

  // Example configuration for Witty cloud Board
  #define BOARD_BUTTON_PIN            4
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN_R             15
  #define BOARD_LED_PIN_G             12
  #define BOARD_LED_PIN_B             13
  #define BOARD_LED_INVERSE           false
  #define BOARD_LED_BRIGHTNESS        64

#else

  // Custom board configuration
  #define BOARD_BUTTON_PIN            0                     // Pin where user button is attached
  #define BOARD_BUTTON_ACTIVE_LOW     true                  // true if button is "active-low"

  #define BOARD_LED_PIN               15                    // Set LED pin - if you have a single-color LED attached
  //#define BOARD_LED_PIN_R           15                    // Set R,G,B pins - if your LED is PWM RGB 
  //#define BOARD_LED_PIN_G           12
  //#define BOARD_LED_PIN_B           13
  //#define BOARD_LED_PIN_WS2812      4                     // Set if your LED is WS2812 RGB
  #define BOARD_LED_INVERSE           false                 // true if LED is common anode, false if common cathode
  #define BOARD_LED_BRIGHTNESS        64                    // 0..255 brightness control

#endif


/*
 * Advanced options
 */

#define BUTTON_HOLD_TIME_INDICATION   3000
#define BUTTON_HOLD_TIME_ACTION       10000

#define BOARD_PWM_MAX                 1023

#define CONFIG_AP_URL                 "blynk.setup"
#define CONFIG_DEFAULT_SERVER         "blynk.cloud"
#define CONFIG_DEFAULT_PORT           443

#define WIFI_NET_CONNECT_TIMEOUT      30000
#define WIFI_CLOUD_CONNECT_TIMEOUT    60000
#define WIFI_AP_CONFIG_PORT           80
#define WIFI_AP_IP                    IPAddress(192, 168, 4, 1)
#define WIFI_AP_Subnet                IPAddress(255, 255, 255, 0)
//#define WIFI_CAPTIVE_PORTAL_ENABLE

#define USE_TICKER
//#define USE_TIMER_ONE
//#define USE_TIMER_THREE

#define BLYNK_NO_DEFAULT_BANNER

#if defined(APP_DEBUG)
  #define DEBUG_PRINT(...) BLYNK_LOG1(__VA_ARGS__)
#else
  #define DEBUG_PRINT(...)
#endif

but the response is always like this:

?)⸮⸮L⸮⸮⸮⸮m⸮&j⸮[303] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266

[4491] Using Dynamic IP: 192.168.0.101
[4692] Current time: Mon May 23 07:49:18 2022
[4692] Connecting to blynk.cloud:443
[15722] Redirecting to ny3.blynk.cloud:443
[15735] Current time: Mon May 23 07:49:29 2022
[15735] Connecting to ny3.blynk.cloud:443
[15837] Connection failed
[20743] Current time: Mon May 23 07:49:34 2022
[20743] Connecting to ny3.blynk.cloud:443
[23150] Ready (ping: 41ms).
[23487] Server: Template with id TMPL232uG5ga doesn't exist
[23809] Current time: Mon May 23 07:49:37 2022
[23809] Connecting to blynk.cloud:443
[32151] Redirecting to ny3.blynk.cloud:443
[32164] Current time: Mon May 23 07:49:45 2022
[32164] Connecting to ny3.blynk.cloud:443
[35778] Ready (ping: 714ms).
[36772] Server: Template with id TMPL232uG5ga doesn't exist
[37823] Current time: Mon May 23 07:49:51 2022
[37823] Connecting to blynk.cloud:443
[40685] Redirecting to ny3.blynk.cloud:443
[40698] Current time: Mon May 23 07:49:54 2022
[40698] Connecting to ny3.blynk.cloud:443
[44310] Ready (ping: 39ms).
[44599] Server: Template with id TMPL232uG5ga doesn't exist
[44906] Current time: Mon May 23 07:49:58 2022
[44907] Connecting to blynk.cloud:443
[55548] Connection failed
[55585] Current time: Mon May 23 07:50:09 2022
[55585] Connecting to blynk.cloud:443
[59289] Redirecting to ny3.blynk.cloud:443
[59302] Current time: Mon May 23 07:50:12 2022
[59302] Connecting to ny3.blynk.cloud:443
[61849] Ready (ping: 39ms).
[62154] Server: Template with id TMPL232uG5ga doesn't exist
[62633] Current time: Mon May 23 07:50:16 2022
[62633] Connecting to blynk.cloud:443
[72668] Redirecting to ny3.blynk.cloud:443
[72671] Current time: Mon May 23 07:50:26 2022
[72671] Connecting to ny3.blynk.cloud:443
[75743] Ready (ping: 585ms).
[76050] Server: Template with id TMPL232uG5ga doesn't exist


I think my copy is correct.
It is strange that I can use the QuickStart code to connected my console and APP and device, the code is:

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLSwkvn-Vx"
#define BLYNK_DEVICE_NAME "LED Blink"
#define BLYNK_AUTH_TOKEN "C3QGEgoZkYNXvyExjcz5hQiyqcY0FwCM"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "qsf2902";
char pass[] = "29022902";

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();
  if(value==1){
    digitalWrite(D2,HIGH);
  }
  else{
    digitalWrite(D2,LOW);
  }
  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  pinMode(D2,OUTPUT);
  // Debug console
  Serial.begin(115200);
  delay(100);
  Blynk.begin(auth, ssid, pass,"blynk.cloud", 80);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

And I can use it to light my LED by APP, I think there is something wrong in the process of validating the template id.

Thank you for you reply!
Best wishes!
Yang.

What EXACTLY does this mean?

There is no point dumping lots of code into your replies if you aren’t going to include screenshots of your template setup in the web console as well.

The problem with mixing and matching static QuickStart examples with dynamic Edgent examples is that QuickStart creates the device for you, and with Edgent you add the device when you do the provisioning.

Stick to one method or another, don’t mix them up.

Pete.

Thanks again for your reply

I’m sorry about my unclear description. That’s means that I referred to your teachings and the Edgent related links, and I operated following the instructions, but it still mistake about my template id, even though I deleted the QuickStart template and created a new template.

In my next attempt, I just use the template to create a device by console and use some code like this to connect my device and it can work well both in console and APP.

This is the same template id I had before I created the device, but it now takes effect.

That’s a good suggestion and I will using my successful method to operate and make some project.

Thank you again for your reply in your busy schedule.

Best wishes!

Yang.