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

Blynk and answering an incoming call

OK, I now have no idea what you want…

Again…

If Blynk IS NOT connected, then as long as your programming is setup to keep running without that link (see here for an example), then you should be able do whatever you want with the modem… attempt reconnection to Blynk, ET phone home, answer spam calls, whatever…

If, however, Blynk IS connected, then generally that is ALL the modem (or any other method of link, WiFi, USB, BT/BLE) can do (maintain that connection), and thus unable to do anything else.

Perhaps a little more clarity of your “problem” :stuck_out_tongue_winking_eye:

1 Like

Perhaps due to the fact that I use a translator, the essence of my text changes. If the SIM800L module is connected to the server and data is transmitted, there is no problem. I make a call to the module, he answers it and executes DTMF commands from the phone. As soon as the call is over, it again starts sending data to the server without reconnecting again. But, if the module has lost connection with the server due to a bad “GPRS” signal and is constantly trying to reconnect, then at that moment I call the module, the call goes on, but does not answer this call. And it is necessary that if there is no connection with the server, the modem constantly tries to connect, but also accepts an incoming call.

As @Gunner’s example (that he linked to in his last post) shows, using Blynk.config and Blynk.connect instead of Blynk.begin (which is a blocking command and prevents any other code execution when there is no Blynk connection) should solve the problem you’re describing.

Pete.

1 Like

Sorry for my persistence. Still nothing works. If replace Blynk.begin with Blynk.config and Blynk.connect gives the error "no matching function for call to 'BlynkSIM :: config (char [33], TinyGsm &, char [9], char [1], char [1]) ’ "

Post your code.

Pete.

Yes… posting code helps us actually see what you’re talking about.

Also, searching this forum just might help a bit :stuck_out_tongue: I used these keywords (Blynk.config GSM)… and for example, this showed up… I suggest reading whole topic, and looking through others as well…

1 Like

This code is designed to work with Arduino Mega 2560 and GSM module SIM800L. It is controlled by Blynk via GPRS and by using DTMF commands when calling the module from a mobile phone. The code contains the following:

  1. reading readings from three temperature sensors DS18b20
  2. readout of input voltage readings
  3. control of turning on two relays to open and close car doors, and automatically start the engine
  4. turning on one relay to start the tablet PC installed in the car, after starting the engine
  5. turning on one relay to activate the air conditioner button in the car

DTMF commands duplicate relay activation for doors and engine start.

#define BLYNK_PRINT Serial                                                                        
#define TINY_GSM_MODEM_SIM800                                                                      
#include <TinyGsmClient.h>                                                                        
#include <BlynkSimpleSIM800.h>                                                                    
#include <SoftwareSerial.h>                                                                        
#include <OneWire.h>                                                                              
String temp; 
//////////////////////////////////////////
//////////////////////////////////////////
OneWire ds(A3);                                                                                    
OneWire dsx(A5);                                                                                 
OneWire dsy(A4);                                                                                  
                                                                                                  
#define RT0x 10000   
#define Bx 3977      
#define VCCx 4.88    
#define Rx 220                                                                       
                                                                                                  
int temperature = 0; 
long lastUpdateTime = 0; 
const int TEMP_UPDATE_TIME = 1000; 
                                                                                                  
int temperaturex = 0; 
long lastUpdateTimex = 0; 
const int TEMP_UPDATE_TIMEx = 1000; 
                                                                                                  
int temperaturey = 0; 
long lastUpdateTimey = 0; 
const int TEMP_UPDATE_TIMEy = 1000; 
///////////////////////////////////////////
///////////////////////////////////////////
#define VREF 4.88                                 
#define DIV_R1 10000                            
#define DIV_R2 4700                             
///////////////////////////////////////////
//////////////////////////////////////////
float voltage;                                                                      
//////////////////////////////////////////
//////////////////////////////////////////
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";                                   
//////////////////////////////////////////
//////////////////////////////////////////
char apn[]  = "internet";                                                           
char user[] = "";                                                                   
char pass[] = "";                                                                   
//////////////////////////////////////////
//////////////////////////////////////////
SoftwareSerial SerialAT(10, 11); // RX, TX                                          
TinyGsm modem(SerialAT);                                                            
///////////////////////////////////////////
///////////////////////////////////////////
BLYNK_CONNECTED() 
{                                                                                   
  Blynk.syncAll();                                                                  
}
////////////////////////////////////////////
////////////////////////////////////////////
int flag = 0;                                                                       
int flagx = 0;                                                                      
int flagy = 0;                                                                      
int flagxy = 0;                                                                     
int flagP = 0;                                                                      
int flagPX = 0;                                                                    
int flagPY = 0;                                                                      
int flagPXY = 0;                                                                     
////////////////////////////////////////////
////////////////////////////////////////////
void setup()                                                                        
{                                                                                   
  Serial.begin(9600);                                                               
  delay(10);                                                                        
  SerialAT.begin(9600);                                                             
  delay(3000);                                                                      
  Serial.println("Initializing modem...");
  modem.init(); 
  Blynk.config (modem, auth, BLYNK_DEFAULT_DOMAIN, BLYNK_DEFAULT_PORT);  
////////////////////////////////////////////
////////////////////////////////////////////
  pinMode(6, INPUT);                                                                  
  digitalWrite(6, LOW);                                                             
  pinMode(2, OUTPUT);                                                               
////////////////////////////////////////////
////////////////////////////////////////////
  pinMode(4, INPUT);                                                                
  digitalWrite(4, LOW);                                                               
  pinMode(3, OUTPUT);                                                                                      
////////////////////////////////////////////
////////////////////////////////////////////
}                                                                                   
void loop()                                                                         
{                                                                                   
  Blynk.run();                                                                      
/////////////////////////////////////////////
/////////////////////////////////////////////
  voltage = (float)analogRead(A2) * VREF * ((DIV_R1 + DIV_R2) / DIV_R2) / 1024;                   
  Blynk.virtualWrite(V3, voltage);                                                                
/////////////////////////////////////////////
/////////////////////////////////////////////
  detectTemperature();                               
  }                                                                                               
int detectTemperature() {                                                                         
  byte data[2];                                                                                   
  ds.reset();                                                                                     
  ds.write(0xCC);                                                                                 
  ds.write(0x44);                                                                                 
  if (millis() - lastUpdateTime > TEMP_UPDATE_TIME)                                               
  {                                                                                               
    lastUpdateTime = millis();                                                                    
    ds.reset();                                                                                     
    ds.write(0xCC);                                                                               
    ds.write(0xBE);                                                                               
    data[0] = ds.read();                                                                          
    data[1] = ds.read();                                                                          
    // Формируем значение                                                                         
    temperature = (data[1] << 8) + data[0]; temperature = temperature >> 4;                       
  }                                                                                               
  Blynk.virtualWrite(V1, temperature);                                                            
///////////////////////////////////////////////
///////////////////////////////////////////////
  detectTemperaturey(); 
}                                                                                                 
int detectTemperaturey() {                                                                        
  byte data[2];                                                                                   
  dsy.reset();                                                                                      
  dsy.write(0xCC);                                                                                
  dsy.write(0x44);                                                                                
  if (millis() - lastUpdateTimey > TEMP_UPDATE_TIMEy)                                             
  {                                                                                               
    lastUpdateTimey = millis();                                                                   
    dsy.reset();                                                                                  
    dsy.write(0xCC);                                                                              
    dsy.write(0xBE);                                                                              
    data[0] = dsy.read();                                                                         
    data[1] = dsy.read();                                                                         
    // Формируем значение                                                                         
    temperaturey = (data[1] << 8) + data[0]; temperaturey = temperaturey >> 4;                    
  }                                                                                               
  Blynk.virtualWrite(V4, temperaturey);                                                           
///////////////////////////////////////////
//////////////////////////////////////////
  detectTemperaturex();                              
}                                                                                                 
int detectTemperaturex() {                                                                        
  byte data[2];                                                                                   
  dsx.reset();                                                                                     
  dsx.write(0xCC);                                                                                
  dsx.write(0x44);                                                                                
  if (millis() - lastUpdateTimex > TEMP_UPDATE_TIMEx)                                             
  {                                                                                               
    lastUpdateTimex = millis();                                                                   
    dsx.reset();                                                                                  
    dsx.write(0xCC);                                                                              
    dsx.write(0xBE);                                                                              
    data[0] = dsx.read();                                                                         
    data[1] = dsx.read();                                                                         
    // Формируем значение                                                                         
    temperaturex = (data[1] << 8) + data[0]; temperaturex = temperaturex >> 4;                    
  }                                                                                               
  Blynk.virtualWrite(V5, temperaturex);                                                           
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
  Blynk.virtualWrite(V2, 255);                                                                      
  delay(100);                                                                                       
  Blynk.virtualWrite(V2, 0);                                                                        
  delay(100);                                                                                       
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
  if (digitalRead(6) == HIGH && flag == 0) 
  {                                                                                                 
    flag = 1;                                                                                       
    flagx = 1;                                                                                      
  }                                                                                                 
  if (digitalRead(6) == LOW && flag == 1)                                                           
  {                                                                                                 
    flag = 0;                                                                                       
  }                                                                                                 
  if (flagx == 1)                                                                    
  {                                                                                                 
    digitalWrite(2, HIGH);                                                         
    delay(300);                                                                                     
    flagx = 0;                                                                                      
    digitalWrite(2, LOW);                                                                           
  }                                                                                                 
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
  if (digitalRead(4) == HIGH && flagy == 0) 
  {                                                                                                 
    flagy = 1;                                                                                      
    flagxy = 1;                                                                                     
  }                                                                                                 
  if (digitalRead(4) == LOW && flagy == 1)                                                          
  {                                                                                                 
    flagy = 0;                                                                                      
  }                                                                                                 
  if (flagxy == 1)                                                                   
  {                                                                                                 
    digitalWrite(3, HIGH);                                                          
    delay(300);                                                                                     
    flagxy = 0;                                                                                     
    digitalWrite(3, LOW);                                                                           
  }                                                                                                 
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
  if (voltage > 13.5 && flagP == 0)                                                                 
  {                                                                                                 
    flagP = 1;                                                                                      
    flagPX = 1;                                                                                     
  }                                                                                                 
  if (voltage < 13.5 && flagP == 1)                                                                 
  {                                                                                                 
    flagP = 0;                                                                                      
  }                                                                                                 
  if (flagPX == 1)                                                                  
  {                                                                                                 
    digitalWrite(8, HIGH);                                                         
    delay(3000);                                                                                    
    flagPX = 0;                                                                                     
    digitalWrite(8, LOW);                                                                           
  }                                                                                                 
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
  if (digitalRead(8) == HIGH && flagPY == 0)                                                        
  {                                                                                                 
    flagPY = 1;                                                                                     
    flagPXY = 1;                                                                                    
  }                                                                                                 
  if (digitalRead(8) == LOW && flagPY == 1)                                                         
  {                                                                                                 
    flagPY = 0;                                                                                     
  }                                                                                                 
  if (flagPXY == 1)                                                                  
  {                                                                                                 
    digitalWrite(8, HIGH);                                                         
    delay(3000);                                                                                    
    flagPXY = 0;                                                                                    
    digitalWrite(8, LOW);                                                                           
  }                                                                                                 
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
if(SerialAT.find("RING")){                                                        
Serial.println("RING!");                                                                            
SerialAT.println("AT+DDET=1");                                                     
delay(10);                                                                                          
SerialAT.println("ATA");                                                        
                                                                                                    
while(1){                                                                                 
temp=ReadGSM();                                                                                     
delay(500);                                                                                         
                                                                                                    
if(temp == "\r\n+DTMF: 1\r\n"){                                                                     
    digitalWrite(3, HIGH);                                                         
    delay(300);                                                                                                                                                            
    digitalWrite(3, LOW);                                                                                 
Serial.println("1");                                                              
}                                                                                                               
else if(temp == "\r\n+DTMF: 2\r\n"){                                                                          
    digitalWrite(2, HIGH);                                                                      
    delay(300);                                                                                                                                                                  
    digitalWrite(2, LOW);                                                                                    
Serial.println("2");                                                             
}                                                                                                           
else if(temp == "\r\n+DTMF: 3\r\n"){                                                                            
Serial.println("3");                                                                 
}                                                                                                           
else if(temp == "\r\n+DTMF: 4\r\n"){                                                                                  
Serial.println("4");                                                                                    
}                                                                                                                 
else if(temp == "\r\n+DTMF: 5\r\n"){                                                                                                                  
Serial.println("5");                                                                                                                   
}                                                                                                                 
else if(temp == "\r\n+DTMF: 6\r\n"){                                                                                                                  
Serial.println("6");                                                                                                                   
}                                                                                                                 
else if(temp == "\r\n+DTMF: 7\r\n"){                                                                                                                  
Serial.println("7");                                                                                                                   
}                                                                                                                 
else if(temp == "\r\n+DTMF: 8\r\n"){                                                                                                                  
Serial.println("8");                                                                                                                   
}                                                                                                                 
else if(temp == "\r\n+DTMF: 9\r\n"){                                                                                                                  
Serial.println("9");                                                                                                                   
}                                                                                                                 
else if(temp == "\r\n+DTMF: 0\r\n"){                                                                                                                  
Serial.println("0");                                                                                                                   
}                                                                                                                  
else if(temp == "\r\nNO CARRIER\r\n"){                                                                                                                   
break;                                                                                                                  
}                                                                                                                  
                                                                                                                 
}                                                                                                                  
Serial.println("OK!");                                                                                                                  
}                                                                                                                  
                                                                                                                 
}                                                                                                                  
                                                                                                                                                                                                                                   
String ReadGSM() {                                                                                                                  
int c;                                                                                                                  
String v;                                                                                                                  
while (SerialAT.available()) {                                                                                                                   
c = SerialAT.read();                                                                                                                  
v += char(c);                                                                                                                  
delay(10);                                                                                                                  
}                                                                                                                  
return v;                                                                                                                 
///////////////////////////////////////////////////             
}                                                                                                                 

The code you posted still uses Blynk.begin

Pete.

Posted the code as is when it works. After all, with config it gives a compilation error.

I understood what my mistake was. Thank you so much Pete and GTT !!! Everything works as I wanted :smiley:
Pete, please delete this topic so that other users don’t read my mistakes in vain.

I’d asked you to post the code that gave the compilation error, so we could see if you’d correctly implemented the Blynk.config/begin commands correctly.
It appears that you’ve now worked-out the error for yourself, so I’ll mark the topic as ‘solved’.
It may help others in future if you post your working code.

Pete.

The code has changed, in this form it works

1 Like

Surprising… considering the bad form of loading your void loop with too much logic and delays.

I’m just learning and this is not the final code.
What would you change?

And yet it does not work quite correctly … If the modem is connected to GPRS and I install a sketch with “Blynk.config” then everything works. And if there is no GPRS connection and I install a sketch with “Blynk.config” then the modem does not connect to GPRS. This can be seen in the “port monitor” and on the diode of the modem itself. Help me please! I thought it worked, but alas … I’m very upset …

If I am not mistaken, then APN is not entered with Blynk.config

Please open the question.
And yet it does not work quite correctly … If the modem is connected to GPRS and I install the sketch with “Blynk.config”, then everything works. And if there is no GPRS connection and I install the sketch with “Blynk.config”, then the modem does not connect to GPRS. This can be seen on the “port monitor” and on the diode of the modem itself.

You’re using variables called BLYNK_DEFAULT_DOMAIN and BLYNK_DEFAULT_PORT in the code you posted, but those variables aren’t declared anywhere in your sketch, so the code would fail to compile.
If you post the actual code you are using then we might be able to spot the error.

I’ve recently been doing some tests with a TTGO T-Call ESP32 board and I use this as my connection commands for Blynk cloud and it works perfectly:

Blynk.config (modem, auth, "blynk-cloud.com", 8080);
Blynk.connect();

BTW, there is no need to post the same reply twice.

Pete.

#define BLYNK_PRINT Serial                                                                        
#define TINY_GSM_MODEM_SIM800                                                                      
#include <TinyGsmClient.h>                                                                        
#include <BlynkSimpleSIM800.h>                                                                    
#include <SoftwareSerial.h>                                                                        
#include <OneWire.h>                                                                              
//////////////////////////////////////////
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";                                   
//////////////////////////////////////////
char apn[]  = "internet";                                                           
char user[] = "";                                                                   
char pass[] = "";                                                                   
//////////////////////////////////////////
SoftwareSerial SerialAT(10, 11); // RX, TX                                          
TinyGsm modem(SerialAT);                                                            
///////////////////////////////////////////
BLYNK_CONNECTED() 
{                                                                                   
  Blynk.syncAll();                                                                  
}
////////////////////////////////////////////
void setup()                                                                        
{                                                                                   
  Serial.begin(9600);                                                               
  delay(10);                                                                        
  SerialAT.begin(9600);                                                             
  delay(3000);                                                                      
  Serial.println("Initializing modem...");
  modem.init(); 
  Blynk.config (modem, auth, "blynk-cloud.com", 8080);
  Blynk.connect();  
////////////////////////////////////////////
}                                                                                   
void loop(){                                                                         
                                                                                   
  Blynk.run(); 
  }

And what does your serial monitor show when you run this code?

Pete.