Blynk with Sim800A get stuck

Thank Pete, now I can add my code.
My issue:
Why I can not connect to Blynk server via Sim800A-esp32.
Blynk library in my app is ver 1.1.0 on esp32

#define BLYNK_PRINT Serial

#include <HardwareSerial.h>

#define TINY_GSM_MODEM_SIM800

//#define BLYNK_HEARTBEAT 8

#include <TinyGsmClient.h>

//#include <BlynkSimpleEsp32.h>

#include <BlynkSimpleTinyGSM.h>

//

#define RXPIN 17

#define TXPIN 16

#define RELAY_PIN 14

// Replace with your SIM800A serial RX and TX pins

HardwareSerial SIM800A(1);

TinyGsm modem(SIM800A);

TinyGsmClient client(modem);

//

BlynkTimer timer;
#define BLYNK_TEMPLATE_ID "TMPLsRzNtXDr"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "9dIhPuh0GfdgdfgK6z8dWRUqs"
//
char auth[] = BLYNK_AUTH_TOKEN ;
char apn[] = "m-wap";
char user[] = "mms";
char pass[] = "mms";

//
void setup() {
 Serial.begin(115200);
 Serial.println("START");
SIM800A.begin(115200, SERIAL_8N1, RXPIN , TXPIN);
Serial.println("SIM800A serial initial");
delay(3000);
pinMode(RELAY_PIN, OUTPUT);
 Serial.println("Initializing modem...");
modem.restart();
 Serial.println("CHECK!");
//Blynk.begin(auth , modem, apn, user, pass );
Blynk.config(modem, auth);
Blynk.connect();
delay(3000);
 Serial.println("CHECK ok!");
//String modemInfo = modem.getModemInfo();
//Serial.println(modemInfo);
if (Blynk.connected()) {
Serial.println("Blink connected!");
} else {
// Do something if Blynk is not connected
Serial.println("Blink connection Failed!");
}
//
timer.setInterval(1000L, sendtoBlynk); //timer will run every sec
}
//
 BLYNK_WRITE(V1)
{
 int pinValue = param.asInt();
 digitalWrite(RELAY_PIN, HIGH);
}
//
 BLYNK_WRITE(V2)
{
 int pinSleep = param.asInt();
 if (pinSleep == 1) {
 //ESP.deepSleep(10);
 esp_deep_sleep_start();
}
else {
ESP.deepSleep(0);
}
}
//
void sendtoBlynk()
{
Blynk.virtualWrite(V3, random(5000));  
}
void loop()
{
 Blynk.run();
 timer.run();
}

You’re getting that message because you’re using the wrong symbols. The correct symbols are:
```

Pete.

1 Like

These need to be the very first lines of your sketch.

Pete.

I have change it into first line. But it still there
Serial output as below:

[15104] Connecting to blynk-cloud.com:8080
CHECK ok!
Blink connection Failed!
[96196] Connecting to blynk-cloud.com:8080
[174288] Connecting to blynk-cloud.com:8080

and Blynk continue try to connect again but not success.

Post your revised sketch, along with your full serial output, including the part with the Blynk logo.

Pete.

My revised code:

#define BLYNK_TEMPLATE_ID "TMPLsRzNtXDr"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "9dIhPuh0GqlU9..."
#define BLYNK_PRINT Serial
#include <HardwareSerial.h>
#define TINY_GSM_MODEM_SIM800
//#define BLYNK_HEARTBEAT 8
#include <TinyGsmClient.h>
//#include <BlynkSimpleEsp32.h>
#include <BlynkSimpleTinyGSM.h>
#define RXPIN 17
#define TXPIN 16
#define RELAY_PIN 14
// Replace with your SIM800A serial RX and TX pins
HardwareSerial SIM800A(1);
TinyGsm modem(SIM800A);
TinyGsmClient client(modem);
//BlynkTimer timer;
char auth[] = BLYNK_AUTH_TOKEN ;
char apn[] = "m-wap";
char user[] = "mms";
char pass[] = "mms";
//
void setup() {
Serial.begin(115200);
Serial.println("START");
SIM800A.begin(9600, SERIAL_8N1, RXPIN , TXPIN);
Serial.println("SIM800A serial initial");
delay(3000);
pinMode(RELAY_PIN, OUTPUT);
 Serial.println("Initializing modem...");
modem.restart();
Serial.println("CHECK1!");
//Blynk.begin(auth , modem, apn, user, pass );
Blynk.config(modem, auth);//, "blynk-cloud.com", 8080);
Blynk.connect();
delay(3000);
Serial.println("CHECK ok!");
//String modemInfo = modem.getModemInfo();
//Serial.println(modemInfo);
if (Blynk.connected()) {
Serial.println("Blink connected!");
} else {
// Do something if Blynk is not connected
Serial.println("Blink connection Failed!");
}
}
//
BLYNK_WRITE(V1)
{
int pinValue = param.asInt();
digitalWrite(RELAY_PIN, HIGH);
}
//
BLYNK_WRITE(V2)
{
int pinSleep = param.asInt();
if (pinSleep == 1) {
//ESP.deepSleep(10);
esp_deep_sleep_start();
}
else {
ESP.deepSleep(0);
}
}
//

void sendtoBlynk()
{
Blynk.virtualWrite(V3, random(5000));
}
void loop()
{
sendtoBlynk();
Blynk.run();
}

then Output Serial:

START
SIM800A serial initial
Initializing modem...
CHECK1!
[13064] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP32

[15105] Connecting to blynk.cloud:80
CHECK ok!
Blink connection Failed!
[96191] Connecting to blynk.cloud:80
[174277] Connecting to blynk.cloud:80

It’s difficult to help when you tell us that your serial output says…

when it actually says…

It’s also difficult when your latest sketch is massively different (and breaks all of the Blynk rules) compared to your initial sketch.

I’d suggest that you choose which sketch you’re going to use, share it - along with your serial output - then stick with that sketch making changes based on the feedback you receive from the forum. Otherwise, you’re going to find it difficult to get any assistance.

Pete.

Sorry about that confuse, just a try I want to change port only. My sketch above is what i’m testing up to now.

You should remove

from your void loop, you will flood the server. Re-instate the timer from your first sketch.

Personally, I’d suggest that you start with a very simple standard SIM800 Blynk sketch, rather than this messy hacked-around code, to prove that you have proper communication with your SIM800.

Pete.

Thank for your advice. I shrten my code to focus only connect to Blynk for easy checking and also remove call function in loop()

#define BLYNK_TEMPLATE_ID "TMPLsRzNtXDr"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "9dIhPuh0GqlU9..."
#define BLYNK_PRINT Serial
#include <HardwareSerial.h>
#define TINY_GSM_MODEM_SIM800
#include <TinyGsmClient.h>
//#include <BlynkSimpleEsp32.h>
#include <BlynkSimpleTinyGSM.h>
//#include <BlynkSimpleEsp32.h>
//#include <BlynkSimpleEsp32_SSL.h>
#define RXPIN 17
#define TXPIN 16
#define RELAY_PIN 14
// Replace with your SIM800A serial RX and TX pins
HardwareSerial SIM800A(1);
TinyGsm modem(SIM800A);
TinyGsmClient client(modem);
//BlynkTimer timer;
char auth[] = BLYNK_AUTH_TOKEN;
char apn[] = "m-wap";
char user[] = "mms";
char pass[] = "mms";
//
void setup() {
Serial.begin(115200);
Serial.println("START");
SIM800A.begin(115200, SERIAL_8N1, RXPIN , TXPIN);
Serial.println("SIM800A serial initial");
delay(3000);
pinMode(RELAY_PIN, OUTPUT);
 Serial.println("Initializing modem...");
modem.restart();
Serial.println("CHECK1!");
Blynk.config(modem, auth);
Blynk.connect();
delay(3000);
Serial.println("CHECK ok!");
if (Blynk.connected()) {
Serial.println("Blink connected!");
} else {
// Do something if Blynk is not connected
Serial.println("Blink connection Failed!");
}
}

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

Output still have issue

[15240] Connecting to blynk.cloud:80
CHECK ok!
Blink connection Failed!
[96246] Connecting to blynk.cloud:80
[174252] Connecting to blynk.cloud:80
[252258] Connecting to blynk.cloud:80
[330264] Connecting to blynk.cloud:80

if wonder I miss some library for Blynk to connect ?

but that’s not what I suggested is it?

There are several things that look dodgy to me with this sketch, which is why I described it as…

Pete.

I hope it cleaner, sorry cause of this messing.

#define BLYNK_TEMPLATE_ID "TMPLsRzNtXDr"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "9dIhPuh0GqlU9..."
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM800
#include <HardwareSerial.h>
#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
#define RXPIN 17
#define TXPIN 16
#define RELAY_PIN 14
//
HardwareSerial SIM800A(1);
TinyGsm modem(SIM800A);
TinyGsmClient client(modem);
//
char auth[] = BLYNK_AUTH_TOKEN;
char apn[] = "m-wap";
char user[] = "mms";
char pass[] = "mms";
//
void setup() {
Serial.begin(115200);
SIM800A.begin(115200, SERIAL_8N1, RXPIN , TXPIN);
Serial.println("SIM800A serial initial");
Serial.println("Initializing modem...");
modem.restart();
Blynk.config(modem, auth);
Blynk.connect();
delay(3000);
//
if (Blynk.connected()) {
Serial.println("Blynk connected!");
} 
else {
Serial.println("Connection Failed!");
}
}

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

I’m not going to keep repeating the same advice, so good luck with your project.

Pete.

Thank you for your help untill now. But I see that code is just a sequence step by step to connect Blynk only, there is not any other purpose. If I can fix this mess I’ll come back and up my sketch for anyone have same problem like this.
Thank Pete.

Have you tried

Blynk.begin(BLYNK_AUTH_TOKEN, modem, apn, user, pass);
}

Instead of

Blynk.config(modem, auth);

?

Here is output from Blynk debug:

[10237] Modem init...

[20439] Cannot init

Are you sure that the SIM800A module is correctly configured and has a valid SIM card installed?
Are you sure that the power source provides enough current for the SIM800A to run properly?

Hi John93,
Power supply: around 5.2v for module, it connected after 10-15s after power supply (3s/blink).
RX Sim800A to TX2 (pin 17) and TX Sim800A to RX2 (pin 16)
I just guess that I miss some necessary library for Blynk to connect and try to find out.
Today output have some better info:

[11813] Modem init...
[11840] Connecting to network...
[19222] Network: Mobifone
[19222] Connecting to m-wap ...
[27528] Connected to GPRS
[27536] Connecting to blynk.cloud:80
[31791] Connecting to blynk.cloud:80
[35716] Connecting to blynk.cloud:80
[39755] Connecting to blynk.cloud:80
[43670] Connecting to blynk.cloud:80
[47687] Connecting to blynk.cloud:80
[51855] Connecting to blynk.cloud:80

But still not connect to Blynk server.

This is just one of the reasons why you should stop trying to get this screwed-up code to work and do what I’ve suggested multiple times before - use the Blynk GSM SIM800 example - but you seem to stubborn to do this!!

Pete.

I don’t know what you mean, that the name TX2 or RX2 that the name printed on ESP32 for everyone can image what I connect. And the variable name I define for code is

#define RXPIN 17 // RXPIN of Sim800A to pin 17 of ESP32
#define RXPIN 16 // TXPIN of Sim800A to pin 16 of ESP32

I just want to discus and learn each other. If I’m wrong, someone can advise, thank.
I have been tried to run all example on library (but it did not work in my case) before I send it to this communicate for help. Thank all I stop here.
Problem “SOLVED”. I’ll try another another way to send my data to app.