BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Invalid Auth Token Issue ESP8266

Hi, I’m new here. I started a project and getting the often quoted Invalid Token Issue. As said, I read all the previous Solved answers and tried everything as far as I can understand. Still mine says Invalid auth token. I hope someone can point out what I’m doing wrong. Code compiles and runs without issue. But the serial monitor is always showing invalid auth token.

My Hardware mode is ESP8266. Communication type - Sim800L (I think that’s what you are asking here).

Smartphone Version Android 10. Sony Xperia XZ3

Blynk server

Library Version Tried 1.1 and 0.6.1.

#define BLYNK_TEMPLATE_ID "TMPLrzuqxrUm"
#define BLYNK_DEVICE_NAME "Indrajith"
#define BLYNK_AUTH_TOKEN "BdXKqVOq66d9sh2ngldBB_3rcaXGFGxs"

//------------------------------------------------------------------
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM800
//------------------------------------------------------------------

#include "Adafruit_FONA.h"
#include <SoftwareSerial.h>
//GPS Module RX pin to NodeMCU D3
//GPS Module TX pin to NodeMCU D4
#define rxPin 0
#define txPin 2
#define FONA_RST 13
SoftwareSerial Sim800L(rxPin,txPin);
SoftwareSerial *fonaSerial = &Sim800L;
//Hardware serial is also possible! for ESP32
//HardwareSerial *fonaSerial = &Serial2;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

//------------------------------------------------------------------

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//------------------------------------------------------------------
char auth[] = BLYNK_AUTH_TOKEN;

char apn[]  = "hutch3g";
char user[] = "";
char pass[] = "";
//------------------------------------------------------------------
TinyGsm modem(fona);
BlynkTimer timer;
//------------------------------------------------------------------
//NOTE: Enter the phone number that you want to register with the project
//You can only control the project, with the phone number you entered here
//Must enter your personal phone number with country code.
//Make Sure: never enter the gsm module's phone number here.

const String PHONE = "+94777984078";
//------------------------------------------------------------------
#define pin_relay1 14
//------------------------------------------------------------------
int state_relay1 = 0;
//------------------------------------------------------------------
//Change the virtual pins, as you have set in the blynk account.
#define virtual_pin1    V1
//------------------------------------------------------------------
String gsm_buff ="";
char sendsms[15];
char caller_id[32];
char sms_buffer[255];
int len=0;


//------------------------------------------------------------------
BLYNK_WRITE(virtual_pin1) {
  state_relay1 = param.asInt();
  digitalWrite(pin_relay1, state_relay1);
   Serial.print("Relay 1 is ");
   if(state_relay1==0)
   Serial.println("OFF");
   else
   Serial.println("ON");
}

//------------------------------------------------------------------

void handle_sms(){
  while(Serial.available())  {
    fona.println(Serial.readString());
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  gsm_buff ="";
  //+CMTI: "SM",1 (here! 1 is slot)
  int slot = 0;
  uint16_t smslen;
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //any data available from the fona?
  gsm_buff= fona.readString();
  //if(gsm_buff.length() > 0)
    //{Serial.println();Serial.println(gsm_buff);}
  len = gsm_buff.length();
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //if(gsm_buff.indexOf("+CMTI:")) {
  if (len >10) {
    gsm_buff =gsm_buff.substring(14,len);
    slot = gsm_buff.toInt();
    Serial.print("Slot: ");
    Serial.println(slot);
    if (slot == 0) {
      return;
    }
    //------------------------------------------------------------
    if (!fona.readSMS(slot, sms_buffer, 250, &smslen)) {  // pass in buffer and max len!
      Serial.println(F("Failed!"));
      return;
    }
    //------------------------------------------------------------
    if (! fona.getSMSSender(slot, caller_id, 31)) {
      Serial.println("Didn't find SMS message in slot!");
      return;
    }
    //------------------------------------------------------------
    if(PHONE != String(caller_id)){
      Serial.println("The phone number is not Registered.");
      Serial.println("Please use the Registered Phone Number.");
    }
    else 
    {
      //_________________________________________
      String sms_temp = sms_buffer;
      sms_temp.toLowerCase();
      String caller_temp = caller_id;
      Serial.println("SMS: "+sms_temp);
      Serial.println("From: "+caller_temp);
      //_________________________________________
      if(sms_temp == "1on"){
        state_relay1 =1;
        digitalWrite(pin_relay1, HIGH);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is ON");
        Serial.println("Response: Relay 1 is ON");
      }
      //_________________________________________
      if(sms_temp == "1off"){
        state_relay1 =0;
        digitalWrite(pin_relay1, LOW);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is OFF");
        Serial.println("Response: Relay 1 is OFF");
      }
      
      //_________________________________________
      else
        {
          fona.sendSMS(caller_id, "ERROR: Send SMS with valid command");
        }
      //_________________________________________
    }
    //------------------------------------------------------------
    fona.deleteSMS(slot);
    fona.print(F("AT+CMGD=1,4\n\r"));
    fona.print(F("AT+CMGDA= \"DEL ALL\""));
    //------------------------------------------------------------
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
}
 

 

void setup()
{
  Serial.begin(115200);
    //--------------------------------------------------------------------
  pinMode(pin_relay1, OUTPUT);
 
  //--------------------------------------------------------------------
  //During Starting all Relays should TURN OFF
  digitalWrite(pin_relay1, LOW);
 
  //--------------------------------------------------------------------
  delay(2000);
   fonaSerial->begin(9600);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while(1);
  }
  //--------------------------------------------------------------------
  Serial.println(F("FONA is OK"));
  fona.println("AT+CMGF=1"); // Configuring TEXT mode
  delay(1000);
  fona.print ("AT+CSMP=17,167,0,0\r");// Configuring TEXT mode
  delay(1000);
  fona.print("AT+CNMI=2,1\r\n");  //set up the fona to send a +CMTI notification when an SMS is received
 
  //fona.println(F("AT+CMGDA=\"DEL ALL\""));
  //delay(5000);
  delay(1000);
  Serial.println("FONA Ready");
  //--------------------------------------------------------------------
  modem.restart();
  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  Blynk.virtualWrite(virtual_pin1, state_relay1);
  //--------------------------------------------------------------------
  timer.setInterval(2L, handle_sms);
}

void loop()
{
  Blynk.run();
  timer.run();
}

With Blynk IoT you MUST use library version 1.x.x

What exactly does your serial monitor show?

I have serious doubts about your handle_sms() function, along wiuth the idea of calling it evert 2 milliseconds.

Have you tried a simpler example sketch?

I also doubt very much if this Blynk.virtualWrite command will work as you expect it to…

You’d be better putting it in a BLYNK_CONNECTED function.

Pete.

Hi, thanks for the reply.

I did use library version 1.1 first. Then I read some earlier posts and tried 0.6.1 as well. Neither worked. Just checked again with 1.1. Same result.

The serial monitor shows it trying to connect with blynk cloud, but failing with invalid auth token continuously.

It (handle_sms) does work. It’s not 2 milliseconds, it has 2L, not 2. So that’s 2000 milliseconds or 2 seconds.

Either way, I commented out the sms parts and tried, and there’s no difference. From my understanding, for whatever to happen regards to that, the board should connect to the Blynk cloud right? The whole sms function works by communicating with the platform. That initial part keeps failing because with invalid token error, the board doesn’t even come online, so regardless of how the code works, it won’t make a difference.

Again, the

Blynk.begin(auth, modem, apn, user, pass);

part is what’s failing, because the auth doesn’t go through.

P.S.
Is there some other issue here? I just tried Blynk Legacy, and it works perfectly fine. I think this means the code is okay, only change is the,

#define BLYNK_TEMPLATE_ID "TMPLrzuqxrUm"
#define BLYNK_DEVICE_NAME "Indrajith"

not being included, with only the Legacy Auth code being there. However, because Blynk Legacy is closing down, I want to do this through Blynk IoT

The L means that the value is a long, without the L the value would be interpreted as an integer, which can hold a maximum value of 32,767.

You are calling your function 500 times per second which is letterly overkill.

I’d like to see EXACTLY what your serial monitor says when you power-up the device through to the invalid auth token message. Jut copy the text from the serial monitor and paste it between triple backticks.

What @John93 is correct, it’s 2ms.

That’s not the same thing as…

Did you actually copy/paste the first three lines of code from the device screen in the Blynk IoT web console, or was some manual re-typing involves?

Pete.

@Indrajith when you open the Blynk web console and look at the bottom right hand corner of the web browser screen, what does it say for your Region?

I see that you’re in Sri Lanka (a beautiful country by the way). Blynk has IoT servers in Bangalore and Singapore and your mobile ISP may be resolving a different server to the one where your project (and its associated Auth token) lives, which could give the Invalid Auth Token issue.

Pete.

Hi, thanks. I decided to ditch the L and made it 2000. Also, started clearing the SMS memory each 5s, and reduced SMS buffer to 160 chars. Here’s my new code.

#define BLYNK_TEMPLATE_ID "TMPLuvjpdKYe"
#define BLYNK_DEVICE_NAME "ESP1S"
#define BLYNK_AUTH_TOKEN "KLqSNyeoJu2eP9NoObfiuJ2IleGA8tiV"

//------------------------------------------------------------------
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM800
//------------------------------------------------------------------

#include "Adafruit_FONA.h"
#include <SoftwareSerial.h>
//GPS Module RX pin to NodeMCU D3
//GPS Module TX pin to NodeMCU D4
#define rxPin 0
#define txPin 2
#define FONA_RST 13

SoftwareSerial Sim800L(rxPin,txPin);
SoftwareSerial *fonaSerial = &Sim800L;
//Hardware serial is also possible! for ESP32
//HardwareSerial *fonaSerial = &Serial2;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

//------------------------------------------------------------------

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//------------------------------------------------------------------
char auth[] = BLYNK_AUTH_TOKEN;

char apn[]  = "hutch3g";
char user[] = "";
char pass[] = "";
//------------------------------------------------------------------
TinyGsm modem(fona);
BlynkTimer timer;
//------------------------------------------------------------------
//NOTE: Enter the phone number that you want to register with the project
//You can only control the project, with the phone number you entered here
//Must enter your personal phone number with country code.
//Make Sure: never enter the gsm module's phone number here.

const String PHONE = "+94777984078";
//------------------------------------------------------------------
#define pin_relay1 14
//------------------------------------------------------------------
int state_relay1 = 0;
//------------------------------------------------------------------
//Change the virtual pins, as you have set in the blynk account.
#define virtual_pin1    V1
//------------------------------------------------------------------
String gsm_buff ="";
char sendsms[15];
char caller_id[32];
char sms_buffer[160];
int len=0;


//------------------------------------------------------------------
BLYNK_WRITE(virtual_pin1) {
  state_relay1 = param.asInt();
  digitalWrite(pin_relay1, state_relay1);
   Serial.print("Relay 1 is ");
   if(state_relay1==0)
   Serial.println("OFF");
   else
   Serial.println("ON");
}

//------------------------------------------------------------------

void handle_sms(){
  while(Serial.available())  {
    fona.println(Serial.readString());
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  gsm_buff ="";
  //+CMTI: "SM",1 (here! 1 is slot)
  int slot = 0;
  uint16_t smslen;
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //any data available from the fona?
  gsm_buff= fona.readString();
  //if(gsm_buff.length() > 0)
    //{Serial.println();Serial.println(gsm_buff);}
  len = gsm_buff.length();
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //if(gsm_buff.indexOf("+CMTI:")) {
  if (len >10) {
    gsm_buff =gsm_buff.substring(14,len);
    slot = gsm_buff.toInt();
    Serial.print("Slot: ");
    Serial.println(slot);
    if (slot == 0) {
      return;
    }
    //------------------------------------------------------------
    if (!fona.readSMS(slot, sms_buffer, 250, &smslen)) {  // pass in buffer and max len!
      Serial.println(F("Failed!"));
      return;
    }
    //------------------------------------------------------------
    if (! fona.getSMSSender(slot, caller_id, 31)) {
      Serial.println("Didn't find SMS message in slot!");
      return;
    }
    //------------------------------------------------------------
    if(PHONE != String(caller_id)){
      Serial.println("The phone number is not Registered.");
      Serial.println("Please use the Registered Phone Number.");
    }
    else 
    {
      //_________________________________________
      String sms_temp = sms_buffer;
      sms_temp.toLowerCase();
      String caller_temp = caller_id;
      Serial.println("SMS: "+sms_temp);
      Serial.println("From: "+caller_temp);
      //_________________________________________
      if(sms_temp == "1on"){
        state_relay1 =1;
        digitalWrite(pin_relay1, HIGH);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is ON");
        Serial.println("Response: Relay 1 is ON");
      }
      //_________________________________________
      if(sms_temp == "1off"){
        state_relay1 =0;
        digitalWrite(pin_relay1, LOW);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is OFF");
        Serial.println("Response: Relay 1 is OFF");
      }
      
      //_________________________________________
      else
        {
          fona.sendSMS(caller_id, "ERROR: Send SMS with valid command");
        }
      //_________________________________________
    }
    //------------------------------------------------------------
    fona.deleteSMS(slot);
    fona.print(F("AT+CMGD=1,4\n\r"));
    fona.print(F("AT+CMGDA= \"DEL ALL\""));
    //------------------------------------------------------------
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
}
 
 

void setup()
{
  Serial.begin(115200);
    //--------------------------------------------------------------------
  pinMode(pin_relay1, OUTPUT);
 
  //--------------------------------------------------------------------
  //During Starting all Relays should TURN OFF
  digitalWrite(pin_relay1, LOW);
 
  //--------------------------------------------------------------------
  delay(2000);
   fonaSerial->begin(9600);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while(1);
  }
  //--------------------------------------------------------------------
  Serial.println(F("FONA is OK"));
  fona.println("AT+CMGF=1"); // Configuring TEXT mode
  delay(1000);
  fona.print ("AT+CSMP=17,167,0,0\r");// Configuring TEXT mode
  delay(1000);
  fona.print("AT+CNMI=2,1\r\n");  //set up the fona to send a +CMTI notification when an SMS is received
 
  fona.println(F("AT+CMGDA=\"DEL ALL\""));
  //delay(5000);
  delay(1000);
  Serial.println("FONA Ready");
  //--------------------------------------------------------------------
  modem.restart();
  //Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  Blynk.virtualWrite(virtual_pin1, state_relay1);
  //--------------------------------------------------------------------
  timer.setInterval(2000, handle_sms);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Thanks, I uploaded the code in above reply. Here’s my serial monitor for Blynk IOT. (Sorry for the long reply due to codes and serial monitor data)

Serial monitor IOT

Attempting to open comm with ATs
	---> AT
	<--- OK
	---> ATE0
	<--- OK
	---> ATE0
	<--- OK
	---> AT+CVHU=0
	<--- OK
	---> ATI
	<--- SIM800 R14.18

OK

	---> AT+CPMS="SM","SM","SM"
	<--- +CPMS: 9,10,9,10,9,10
FONA is OK
FONA Ready
[15928] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP8266

[15930] Modem init...
[16118] Connecting to network...
[23400] Network: Hutchison Lanka (Pvt)
[23400] Connecting to hutch3g ...
[30300] Connected to GPRS
[30365] Connecting to blynk-cloud.com:80
[32707] Invalid auth token
[48397] Connecting to blynk-cloud.com:80
[50522] Invalid auth token
[66429] Connecting to blynk-cloud.com:80
[68481] Invalid auth token
[84461] Connecting to blynk-cloud.com:80
[86505] Invalid auth token
[102493] Connecting to blynk-cloud.com:80
[104564] Invalid auth token
[120525] Connecting to blynk-cloud.com:80
[122565] Invalid auth token
[138557] Connecting to blynk-cloud.com:80
[140624] Invalid auth token

However, as I said, I tried using Blynk Legacy, and it works like a charm. Please tell me what the difference is? As far as I can understand, Blynk IOT is not letting my device authenticate for some reason. Any idea what??

Code for legacy


#define BLYNK_AUTH_TOKEN "BSfqpDCrLbCRREGdPnfUAmYYVDlnWQIi"

//------------------------------------------------------------------
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM800
//------------------------------------------------------------------

#include "Adafruit_FONA.h"
#include <SoftwareSerial.h>
//GPS Module RX pin to NodeMCU D3
//GPS Module TX pin to NodeMCU D4
#define rxPin 0
#define txPin 2
#define FONA_RST 13

SoftwareSerial Sim800L(rxPin,txPin);
SoftwareSerial *fonaSerial = &Sim800L;
//Hardware serial is also possible! for ESP32
//HardwareSerial *fonaSerial = &Serial2;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

//------------------------------------------------------------------

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//------------------------------------------------------------------
char auth[] = BLYNK_AUTH_TOKEN;

char apn[]  = "hutch3g";
char user[] = "";
char pass[] = "";
//------------------------------------------------------------------
TinyGsm modem(fona);
BlynkTimer timer;
//------------------------------------------------------------------
//NOTE: Enter the phone number that you want to register with the project
//You can only control the project, with the phone number you entered here
//Must enter your personal phone number with country code.
//Make Sure: never enter the gsm module's phone number here.

const String PHONE = "+94777984078";
//------------------------------------------------------------------
#define pin_relay1 14
//------------------------------------------------------------------
int state_relay1 = 0;
//------------------------------------------------------------------
//Change the virtual pins, as you have set in the blynk account.
#define virtual_pin1    V1
//------------------------------------------------------------------
String gsm_buff ="";
char sendsms[15];
char caller_id[32];
char sms_buffer[160];
int len=0;


//------------------------------------------------------------------
BLYNK_WRITE(virtual_pin1) {
  state_relay1 = param.asInt();
  digitalWrite(pin_relay1, state_relay1);
   Serial.print("Relay 1 is ");
   if(state_relay1==0)
   Serial.println("OFF");
   else
   Serial.println("ON");
}

//------------------------------------------------------------------

void handle_sms(){
  while(Serial.available())  {
    fona.println(Serial.readString());
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  gsm_buff ="";
  //+CMTI: "SM",1 (here! 1 is slot)
  int slot = 0;
  uint16_t smslen;
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //any data available from the fona?
  gsm_buff= fona.readString();
  //if(gsm_buff.length() > 0)
    //{Serial.println();Serial.println(gsm_buff);}
  len = gsm_buff.length();
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  //if(gsm_buff.indexOf("+CMTI:")) {
  if (len >10) {
    gsm_buff =gsm_buff.substring(14,len);
    slot = gsm_buff.toInt();
    Serial.print("Slot: ");
    Serial.println(slot);
    if (slot == 0) {
      return;
    }
    //------------------------------------------------------------
    if (!fona.readSMS(slot, sms_buffer, 250, &smslen)) {  // pass in buffer and max len!
      Serial.println(F("Failed!"));
      return;
    }
    //------------------------------------------------------------
    if (! fona.getSMSSender(slot, caller_id, 31)) {
      Serial.println("Didn't find SMS message in slot!");
      return;
    }
    //------------------------------------------------------------
    if(PHONE != String(caller_id)){
      Serial.println("The phone number is not Registered.");
      Serial.println("Please use the Registered Phone Number.");
    }
    else 
    {
      //_________________________________________
      String sms_temp = sms_buffer;
      sms_temp.toLowerCase();
      String caller_temp = caller_id;
      Serial.println("SMS: "+sms_temp);
      Serial.println("From: "+caller_temp);
      //_________________________________________
      if(sms_temp == "1on"){
        state_relay1 =1;
        digitalWrite(pin_relay1, HIGH);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is ON");
        Serial.println("Response: Relay 1 is ON");
      }
      //_________________________________________
      if(sms_temp == "1off"){
        state_relay1 =0;
        digitalWrite(pin_relay1, LOW);
        Blynk.virtualWrite(virtual_pin1, state_relay1);
        fona.sendSMS(caller_id, "Relay 1 is OFF");
        Serial.println("Response: Relay 1 is OFF");
      }
      
      //_________________________________________
      else
        {
          fona.sendSMS(caller_id, "ERROR: Send SMS with valid command");
        }
      //_________________________________________
    }
    //------------------------------------------------------------
    fona.deleteSMS(slot);
    fona.print(F("AT+CMGD=1,4\n\r"));
    fona.print(F("AT+CMGDA= \"DEL ALL\""));
    //------------------------------------------------------------
  }
  //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
}
 
 

void setup()
{
  Serial.begin(115200);
    //--------------------------------------------------------------------
  pinMode(pin_relay1, OUTPUT);
 
  //--------------------------------------------------------------------
  //During Starting all Relays should TURN OFF
  digitalWrite(pin_relay1, LOW);
 
  //--------------------------------------------------------------------
  delay(2000);
   fonaSerial->begin(9600);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while(1);
  }
  //--------------------------------------------------------------------
  Serial.println(F("FONA is OK"));
  fona.println("AT+CMGF=1"); // Configuring TEXT mode
  delay(1000);
  fona.print ("AT+CSMP=17,167,0,0\r");// Configuring TEXT mode
  delay(1000);
  fona.print("AT+CNMI=2,1\r\n");  //set up the fona to send a +CMTI notification when an SMS is received
 
  fona.println(F("AT+CMGDA=\"DEL ALL\""));
  //delay(5000);
  delay(1000);
  Serial.println("FONA Ready");
  //--------------------------------------------------------------------
  modem.restart();
  //Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  Blynk.virtualWrite(virtual_pin1, state_relay1);
  //--------------------------------------------------------------------
  timer.setInterval(2000, handle_sms);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Here is the Serial monitor for legacy. Check it, everything is working like a charm. Both the legacy android app and SMS function no issues at all!

LEGACY Serial monitor

Attempting to open comm with ATs
	---> AT
	<--- OK
	---> ATE0
	<--- OK
	---> ATE0
	<--- OK
	---> AT+CVHU=0
	<--- OK
	---> ATI
	<--- SIM800 R14.18

OK

	---> AT+CPMS="SM","SM","SM"
	<--- +CPMS: 10,10,10,10,10,10
FONA is OK
FONA Ready
[16943] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP8266

[16945] Modem init...
[17137] Connecting to network...
[24198] Network: Hutchison Lanka (Pvt)
[24198] Connecting to hutch3g ...
[33039] Connected to GPRS
[33105] Connecting to blynk-cloud.com:80
[34946] Ready (ping: 532ms).

Slot: 2
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=2
+CMGR: "REC UNREAD","+94777984078","","22/06/20,17:59:33+22",145,32,0,0,"+9477000003",145,3
1on
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=2
+CMGR: "REC READ","+94777984078","","22/06/20,17:59:33+22",145,32,0,0,"+9477000003",145,3
SMS: 1on
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is ON
^Z
Response: Relay 1 is ON
	---> AT+CMGF=1
	<--- +CMTI: "SM",4
	---> AT+CMGF=1
	<--- +CIEV: 10,"41308","Hutch","", 0, 0
Slot: 5
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=5
+CMGR: "REC UNREAD","+94777984078","","22/06/20,18:12:36+22",145,36,0,0,"+9477000003",145,4
1off
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=5
+CMGR: "REC READ","+94777984078","","22/06/20,18:12:36+22",145,36,0,0,"+9477000003",145,4
SMS: 1off
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is OFF
^Z
Response: Relay 1 is OFF
	---> AT+CMGF=1
	<--- 
Slot: 0
Slot: 7
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=7
+CMGR: "REC UNREAD","+94777984078","","22/06/20,18:13:31+22",145,36,0,0,"+9477000003",145,3
1on
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=7
+CMGR: "REC READ","+94777984078","","22/06/20,18:13:31+22",145,36,0,0,"+9477000003",145,3
SMS: 1on
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is ON
^Z
Response: Relay 1 is ON
	---> AT+CMGF=1
	<--- 
	---> AT+CMGF=1
	<--- 
Slot: 8
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=8
+CMGR: "REC UNREAD","+94777984078","","22/06/20,18:13:46+22",145,36,0,0,"+9477000003",145,4
1off
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=8
+CMGR: "REC READ","+94777984078","","22/06/20,18:13:46+22",145,36,0,0,"+9477000003",145,4
SMS: 1off
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is OFF
^Z
Response: Relay 1 is OFF
	---> AT+CMGF=1
	<--- 
Slot: 0
Relay 1 is ON
Slot: 0
Relay 1 is OFF
Slot: 0
Relay 1 is ON
Relay 1 is OFF

Hmm, so IOT server and Legacy server is resolved differently? Yes I am in Sri Lanka, which doesn’t seem an issue for the legacy server.

Can you please tell me what I can do about that? As you can see from above reply, legacy server is working without any issues. I just need to get that sorted out with IOT, since obviously Blynk wants us to and the legacy server is closing down.

P.S. Answer to a previous question. Obviously copied and pasted the auth code and the rest. I don’t think anyone is retyping those auth tokens right?

Your serial monitor says that you are using library version 0.6.1 which is the old blynk library, I’d suggest that you install the latest version of the library and delete the old libraries.

1 Like

I’d suggest that you install the latest version of the library and delete the old libraries.

That worked. I had updated the library, but guess the old one was lingering. Deleting and installing 1.0.0 worked. Thank you sooooo much!! :heart_eyes: :heart_eyes: :heart_eyes:

Attempting to open comm with ATs
	---> AT
	<--- OK
	---> ATE0
	<--- OK
	---> ATE0
	<--- OK
	---> AT+CVHU=0
	<--- OK
	---> ATI
	<--- SIM800 R14.18

OK

	---> AT+CPMS="SM","SM","SM"
	<--- +CPMS: 0,10,0,10,0,10
FONA is OK
FONA Ready
[15952] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.0 on ESP8266

[15954] Modem init...
[16147] Connecting to network...
[23415] Network: Hutchison Lanka (Pvt)
[23415] Connecting to hutch3g ...
[30096] Connected to GPRS
[30162] Connecting to blynk.cloud:80
[31748] Ready (ping: 535ms).
Relay 1 is ON
Slot: 0
Relay 1 is OFF
Relay 1 is ON
Slot: 0
Relay 1 is OFF
Slot: 0
Relay 1 is ON
Slot: 0
Relay 1 is OFF
Relay 1 is ON
Relay 1 is OFF
Slot: 0
Slot: 0
Slot: 1
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=1
+CMGR: "REC UNREAD","+94777984078","","22/06/20,19:09:47+22",145,36,0,0,"+9477000003",145,3
Hey
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=1
+CMGR: "REC READ","+94777984078","","22/06/20,19:09:47+22",145,36,0,0,"+9477000003",145,3
SMS: hey
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> ERROR: Send SMS with valid command
^Z
	---> AT+CMGF=1
	<--- 
Slot: 0
Slot: 2
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=2
+CMGR: "REC UNREAD","+94777984078","","22/06/20,19:10:16+22",145,36,0,0,"+9477000003",145,4
1off
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=2
+CMGR: "REC READ","+94777984078","","22/06/20,19:10:16+22",145,36,0,0,"+9477000003",145,4
SMS: 1off
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is OFF
^Z
Response: Relay 1 is OFF
	---> AT+CMGF=1
	<--- 
Slot: 3
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=3
+CMGR: "REC UNREAD","+94777984078","","22/06/20,19:10:41+22",145,36,0,0,"+9477000003",145,3
1on
	---> AT+CMGF=1
	<--- OK
	---> AT+CSDH=1
	<--- OK
AT+CMGR=3
+CMGR: "REC READ","+94777984078","","22/06/20,19:10:41+22",145,36,0,0,"+9477000003",145,3
SMS: 1on
From: +94777984078
	---> AT+CMGF=1
	<--- OK
	---> AT+CMGS="+94777984078"
	<--- > 
> Relay 1 is ON
^Z
Response: Relay 1 is ON
	---> AT+CMGF=1
	<--- 
	---> AT+CMGF=1
	<--- 

The latest version is 1.1.0

1 Like

Ah yes. Although as long as it works, I guess I’ll stick with 1.0.0. Thank you so much once again. :heavy_heart_exclamation:

1 Like

You should update to 1.1.0

Pete.