BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

TTGO T-Call ( ESP32 + SIM800l ) combine BlynkClient.ino & HttpClient.ino

Thanks. Just place order. Hope will get it within a week.
I hope I still can use the LTE/4G SIM, and the 2G/2+G network here in Canada still not shutdown yet.
They have the plan to shutdown it for many years, just recently extend and close sometime in 2020.

Don’t forget to ask/save also the GPRS_Pin ( the GSM SIM card’s pin if there is set }
B.R.

1 Like

OK, will add.
Is that to use to unlock SIM function if necessary?

simUnlock(const char *pin)

Sorry I’m new here.

Dear @khoih
I made the changes proposed in your message, I tested timeout 10000L & 20000L but no satisfactory result. See the serial log:

09:08:02.166 -> IP5306 KeepOn OK
09:08:08.171 -> Initializing modem...
09:08:13.330 -> Modem: SIM800 R14.18
09:08:13.330 -> Waiting for network... OK
09:08:21.206 -> Network connected
09:08:21.206 -> Connecting to APN: myq OK
09:08:29.663 -> [27517] 
09:08:29.663 ->     ___  __          __
09:08:29.663 ->    / _ )/ /_ _____  / /__
09:08:29.663 ->   / _  / / // / _ \/  '_/
09:08:29.663 ->  /____/_/\_, /_//_/_/\_\
09:08:29.663 ->         /___/ v0.6.1 on ESP32
09:08:29.663 -> 
09:08:29.663 -> [27519] Modem init...
09:08:29.808 -> [27641] Connecting to network...
09:08:29.808 -> [27651] Network: TIM
09:08:29.808 -> [27652] Connecting to myq ...
09:08:36.892 -> [34759] Connected to GPRS
09:08:36.927 -> [34770] Connecting to blynk-cloud.com:80
09:08:38.304 -> [36175] Ready (ping: 424ms).
09:08:38.398 -> Connecting to vsh.pp.ua OK
09:08:39.192 -> Performing HTTP GET request...
09:08:59.219 -> 
09:08:59.253 -> Server disconnected
09:08:59.253 -> GPRS is NOT disconnected

After the above last serial log { 09:08:59.253 -> GPRS is NOT disconnected } there is nothing more and from the beginning there is not Blynk operation ( LED flashing at Blynk App ).
It seems that something is not “compatible” when the BlynkSimpleTinyGSM.h and/or TinyGsmClient.h is used …

Thanks and Best Regards,
Mike Kranidis

From the test result, I guess the culprit is Blynk going to endless loop after trashing the HTTPdata.

This symptom is very similar to other boards (Mega, UNO, etc) using WiFi shields with AT commands.

They experience Packet too big, etc. issue, and sometimes go to random endless loop.

This is hard-to-catch and slippery issue, and I were in the middle of it some time ago. I might go back to look at it whenever I get the TTGO board.

In the mean time, I’ll try to finish the library for you to have a dry test.

1 Like

I think you have to do something like that:

  // Unlock your SIM card with a PIN
  modem.simUnlock("1234");

see also:

1 Like

Dear @mikekgr,

I think we can have 2 simple solutions like this

  1. Bypass Blynk for HTTP
  • create 2 instances of TinyGsm,
  • modem for Blynk and
  • direct_modem fo HTTP
    so that we can bypass Blynk and send HTTP-related commands directly, not via hungry BlynkProtocol.h because we don’t need Blynk for that HTTP purpose.

If not working, we might have to modify TinyGSM library a little bit to simultaneously support 2 instances.

The code is as follows

....
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
// Creating Second instance direct_modem
TinyGsm direct_modem(SerialAT);
#endif

TinyGsmClient client(modem);

// Using Second instance direct_modem
TinyGsmClient direct_client(direct_modem);
HttpClient http(direct_client, server, port);

....

void HTTPClientHandle(void)
{
  if (!connectionStatus)
  {
    SerialMon.print(F("One time connection. Waiting for network..."));
    if (!modem.waitForNetwork())
    {
      SerialMon.println(F(" fail"));
      connectionStatus = false;
      //delay(3000);
      return;
    }
    SerialMon.println(F(" OK"));

    SerialMon.print(F("Connecting to "));
    SerialMon.print(apn);
    if (!modem.gprsConnect(apn, gprsUser, gprsPass))
    {
      SerialMon.println(F(" fail"));
      connectionStatus = false;
      //delay(3000);
      return;
    }
    SerialMon.println(F(" OK"));
    connectionStatus = true;
  }
  #if 1     
    // Test client directly, using direct_modem, bypassing Blynk, see Arduino_TinyGSM.ino
   // Using Second instance direct_modem

    SerialMon.print(F("Connecting to "));
    SerialMon.print(server);
    if (!direct_client.connect(server, port)) 
    {
      SerialMon.println(F(" fail"));
      //delay(10000);
      return;
    }
    SerialMon.println(" OK");
  
      // Make a HTTP GET request:
    SerialMon.println("Performing HTTP GET request...");
    direct_client.print(String("GET ") + resource + " HTTP/1.1\r\n");
    direct_client.print(String("Host: ") + server + "\r\n");
    direct_client.print("Connection: close\r\n\r\n");
    direct_client.println();
  
    unsigned long timeout = millis();
    while (direct_client.connected() && millis() - timeout < 10000L) 
    {
      // Print available data
      while (direct_client.available()) 
      {
        char c = direct_client.read();
        SerialMon.print(c);
        timeout = millis();
      }
    }
    SerialMon.println();
  
    // Shutdown
  
    direct_client.stop();
    
  #else
   // Using Second instance direct_modem

    SerialMon.print(F("Performing HTTP GET request... "));
    int err = http.get(resource);
    if (err != 0)
    {
      SerialMon.println(F("failed to connect"));
      //delay(5000);
      return;
    }
  
    int status = http.responseStatusCode();
    SerialMon.println(status);
    if (!status)
    {
      //delay(5000);
      return;
    }
    /* /// this is for informational reasons only not needed ///
      while (http.headerAvailable()) {
        String headerName = http.readHeaderName();
        String headerValue = http.readHeaderValue();
       //SerialMon.println(headerName + " : " + headerValue);
      }
    */
    int length = http.contentLength();
    if (length >= 0)
    {
      SerialMon.print(F("Content length is: "));
      SerialMon.println(length);
    }
    if (http.isResponseChunked())
    {
      SerialMon.println(F("The response is chunked"));
    }
  
    String body = http.responseBody();
    SerialMon.println(F("Response:"));
    SerialMon.println(body);
  
    SerialMon.print(F("Body length is: "));
    SerialMon.println(body.length());
  
    // Shutdown
  
    http.stop();
  #endif
  
  SerialMon.println(F("Server disconnected"));

  ///modem.gprsDisconnect(); /// leave GPRS connected ///
  ///SerialMon.println(F("GPRS disconnected"));
  SerialMon.println(F("GPRS is NOT disconnected"));
}

void check_status()
{
  ///static unsigned long checkstatus_timeout = 0;
  // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
  if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
  {
    HTTPClientHandle();
    checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
    ///SerialMon.printf("Now millis are:%d \nThe new checkstatus_timeout is: %d\n",millis(),checkstatus_timeout);
  }
}

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

  1. Use Blynk Webhook for HTTP

Another way to try is to use Blynk WebHook (with just one instance of modem)

Dear @khoih,
you are a non stop fantastic supporter and I would like to thank you one more time!

When at home, I will test the first proposed solution and I will let you know.
The second one, the WebHook is a working way, I have test it but I prefer general solutions not tightly bounded to Blynk…

Best Regards,
Mike Kranidis

1 Like

Dear @khoih
YES YOU DID IT !!! You are genius !
I followed your Nr 1 solution.
You need just at the end of your HTTPClientHandle function, you need to reinitialize Blynk.begin( … ) because when the function is started the Blynk is stop working… See:

 ///modem.gprsDisconnect(); /// leave GPRS connected ///
  ///SerialMon.println(F("GPRS disconnected"));
  SerialMon.println(F("GPRS is NOT disconnected"));
  SerialMon.println(F("Reconnecting Blynk..."));
  Blynk.begin(auth, modem, apn, gprsUser, gprsPass);
}

Do you need the serial log ?

Best Regards,
Mike Kranidis

1 Like

Dear @mikekgr

That’s nice.
Could you post the serial log as I’m still curious to see why Blynk is stop working.
I don’t like that and later when I have the board, I will try to find out the root cause and fix if possible as it’s always better to have both working independently.

Regards,
KH

Dear @khoih
here is the log

18:39:19.598 -> IP5306 KeepOn OK
18:39:25.582 -> Initializing modem...
18:39:30.738 -> Modem: SIM800 R14.18
18:39:30.738 -> Waiting for network... OK
18:39:37.890 -> Network connected
18:39:37.890 -> Connecting to APN: myq OK
18:39:44.382 -> [24801] 
18:39:44.382 ->     ___  __          __
18:39:44.382 ->    / _ )/ /_ _____  / /__
18:39:44.382 ->   / _  / / // / _ \/  '_/
18:39:44.382 ->  /____/_/\_, /_//_/_/\_\
18:39:44.382 ->         /___/ v0.6.1 on ESP32
18:39:44.382 -> 
18:39:44.382 -> [24803] Modem init...
18:39:44.489 -> [24926] Connecting to network...
18:39:44.489 -> [24936] Network: TIM
18:39:44.489 -> [24936] Connecting to myq ...
18:39:48.941 -> [29363] Connected to GPRS
18:39:48.941 -> [29373] Connecting to blynk-cloud.com:80
18:39:50.213 -> [30658] Ready (ping: 378ms).
18:39:50.385 -> Connecting to vsh.pp.ua OK
18:39:51.112 -> Performing HTTP GET request...
18:39:51.815 -> HTTP/1.1 200 OK
18:39:51.815 -> Server: nginx/1.10.3 (Ubuntu)
18:39:51.815 -> Date: Wed, 15 Jan 2020 16:39:51 GMT
18:39:51.815 -> Content-Type: text/plain; charset=UTF-8
18:39:51.815 -> Content-Length: 121
18:39:51.815 -> Connection: close
18:39:51.815 -> X-DNS-Prefetch-Control: off
18:39:51.815 -> X-Frame-Options: SAMEORIGIN
18:39:51.815 -> Strict-Transport-Security: max-age=15552000; includeSubDomains
18:39:51.815 -> X-Download-Options: noopen
18:39:51.815 -> X-Content-Type-Options: nosniff
18:39:51.815 -> X-XSS-Protection: 1; mode=block
18:39:51.815 -> Accept-Ranges: bytes
18:39:51.815 -> Cache-Control: public, max-age=0
18:39:51.815 -> Last-Modified: Wed, 27 Sep 2017 09:03:12 GMT
18:39:51.815 -> ETag: W/"79-15ec2936080"
18:39:51.815 -> 
18:39:51.815 -> 
18:39:51.815 ->   _____            _____  _____  _____
18:39:51.815 ->     |  | |\ | \_/ |  ___ |_____ |  |  |
18:39:51.815 ->     |  | | \|  |  |_____| _____||  |  |
18:39:51.815 -> 
18:39:54.158 -> 
18:39:54.205 -> Server disconnected
18:39:54.205 -> GPRS is NOT disconnected
18:39:54.205 -> Reconnecting Blynk...
18:39:54.205 -> [34618] 
18:39:54.205 ->     ___  __          __
18:39:54.205 ->    / _ )/ /_ _____  / /__
18:39:54.205 ->   / _  / / // / _ \/  '_/
18:39:54.205 ->  /____/_/\_, /_//_/_/\_\
18:39:54.205 ->         /___/ v0.6.1 on ESP32
18:39:54.205 -> 
18:39:54.205 -> [34626] Modem init...
18:39:54.299 -> [34752] Connecting to network...
18:39:54.346 -> [34762] Network: TIM
18:39:54.346 -> [34762] Connecting to myq ...
18:39:59.643 -> [40065] Connected to GPRS
18:39:59.643 -> [40074] Connecting to blynk-cloud.com:80
18:40:01.156 -> [41582] Ready (ping: 1025ms).
18:41:01.217 -> Connecting to vsh.pp.ua OK
18:41:02.143 -> Performing HTTP GET request...
18:41:02.940 -> HTTP/1.1 200 OK
18:41:02.940 -> Server: nginx/1.10.3 (Ubuntu)
18:41:02.940 -> Date: Wed, 15 Jan 2020 16:41:02 GMT
18:41:02.940 -> Content-Type: text/plain; charset=UTF-8
18:41:02.940 -> Content-Length: 121
18:41:02.940 -> Connection: close
18:41:02.940 -> X-DNS-Prefetch-Control: off
18:41:02.940 -> X-Frame-Options: SAMEORIGIN
18:41:02.940 -> Strict-Transport-Security: max-age=15552000; includeSubDomains
18:41:02.940 -> X-Download-Options: noopen
18:41:02.940 -> X-Content-Type-Options: nosniff
18:41:02.940 -> X-XSS-Protection: 1; mode=block
18:41:02.940 -> Accept-Ranges: bytes
18:41:02.940 -> Cache-Control: public, max-age=0
18:41:02.940 -> Last-Modified: Wed, 27 Sep 2017 09:03:12 GMT
18:41:02.940 -> ETag: W/"79-15ec2936080"
18:41:02.940 -> 
18:41:02.940 -> 
18:41:02.940 ->   _____            _____  _____  _____
18:41:02.940 ->     |  | |\ | \_/ |  ___ |_____ |  |  |
18:41:02.940 ->     |  | | \|  |  |_____| _____||  |  |
18:41:02.940 -> 
18:41:05.190 -> 
18:41:05.237 -> Server disconnected
18:41:05.237 -> GPRS is NOT disconnected
18:41:05.237 -> Reconnecting Blynk...
18:41:05.237 -> [105662] 
18:41:05.237 ->     ___  __          __
18:41:05.237 ->    / _ )/ /_ _____  / /__
18:41:05.237 ->   / _  / / // / _ \/  '_/
18:41:05.237 ->  /____/_/\_, /_//_/_/\_\
18:41:05.237 ->         /___/ v0.6.1 on ESP32
18:41:05.237 -> 
18:41:05.237 -> [105670] Modem init...
18:41:05.378 -> [105796] Connecting to network...
18:41:05.378 -> [105806] Network: TIM
18:41:05.378 -> [105806] Connecting to myq ...
18:41:10.721 -> [111164] Connected to GPRS
18:41:10.721 -> [111172] Connecting to blynk-cloud.com:80
18:41:11.752 -> [112179] Ready (ping: 424ms).
18:42:11.817 -> Connecting to vsh.pp.ua OK
18:42:12.145 -> Performing HTTP GET request...
18:42:12.890 -> HTTP/1.1 200 OK
18:42:12.890 -> Server: nginx/1.10.3 (Ubuntu)
18:42:12.890 -> Date: Wed, 15 Jan 2020 16:42:12 GMT
18:42:12.890 -> Content-Type: text/plain; charset=UTF-8
18:42:12.890 -> Content-Length: 121
18:42:12.890 -> Connection: close
18:42:12.890 -> X-DNS-Prefetch-Control: off
18:42:12.890 -> X-Frame-Options: SAMEORIGIN
18:42:12.890 -> Strict-Transport-Security: max-age=15552000; includeSubDomains
18:42:12.890 -> X-Download-Options: noopen
18:42:12.890 -> X-Content-Type-Options: nosniff
18:42:12.890 -> X-XSS-Protection: 1; mode=block
18:42:12.890 -> Accept-Ranges: bytes
18:42:12.890 -> Cache-Control: public, max-age=0
18:42:12.890 -> Last-Modified: Wed, 27 Sep 2017 09:03:12 GMT
18:42:12.890 -> ETag: W/"79-15ec2936080"
18:42:12.890 -> 
18:42:12.890 -> 
18:42:12.890 ->   _____            _____  _____  _____
18:42:12.890 ->     |  | |\ | \_/ |  ___ |_____ |  |  |
18:42:12.890 ->     |  | | \|  |  |_____| _____||  |  |
18:42:12.890 -> 
18:42:15.226 -> 
18:42:15.226 -> Server disconnected
18:42:15.226 -> GPRS is NOT disconnected
18:42:15.226 -> Reconnecting Blynk...
18:42:15.226 -> [175654] 
18:42:15.226 ->     ___  __          __
18:42:15.226 ->    / _ )/ /_ _____  / /__
18:42:15.226 ->   / _  / / // / _ \/  '_/
18:42:15.226 ->  /____/_/\_, /_//_/_/\_\
18:42:15.226 ->         /___/ v0.6.1 on ESP32
18:42:15.226 -> 
18:42:15.226 -> [175662] Modem init...
18:42:15.366 -> [175787] Connecting to network...
18:42:15.366 -> [175798] Network: TIM
18:42:15.366 -> [175798] Connecting to myq ...
18:42:19.665 -> [180124] Connected to GPRS
18:42:19.712 -> [180135] Connecting to blynk-cloud.com:80
18:42:20.660 -> [181077] Ready (ping: 342ms).

Dear @mikekgr

The library version v1.0.1 is finally posted here

Thanks and Regards,

Dear @khoih
thanks a lot for your support in this. Did you receive your TTGO T-Call ?
I will test your new release when I have a little time, I am having hard time in my job because my company will be participated in a very big exchibition in the London / UK and I have lot of things to take care …

Best Regards,
Mike Kranidis

A post was split to a new topic: Ttgo t-call (esp32 + sim800l) with NEO-8M GPS

Dear @mikekgr
Just received the TTGO T-Call yesterday.
I updated the Blynk_GSM library to v1.0.2 to enable GSM/GPRS and WiFi to run simultaneously. Already tested OK with TTGO-TCall as well as normal ESP32/ESP8266.
Also update the link here

Hope you find it useful as well as use it somehow somewhere.
Regards,
KH

1 Like

Dear @khoih,
thanks a lot for keeping your fine work and to support the community.
I will test is as soon as I can and I will report the result back to you.
Best Regards,
Mike Kranidis

1 Like

Wow, Mike is back :upside_down_face:

Hello Dear @Blynk_Coeur
I am (almost) constantly here…! Not very active recently, due to very “big load” on my work but I hope to change this soon…

1 Like

Hope we can get blynk v2 soon :joy:

Alexis

as I stated I still quite busy so: PLEASE get your copy first and let me (us) know your impression … !!!

1 Like