Can not connect to Blynk Server

The new blynk (IOT), or the old one (legacy) ?

New Blynk (IoT).

Blynk-cloud.com” is the old blynk server, you should change it to “blynk.cloud”

Still not connected sir.

It was a mistake. It’s “blynk.cloud”

Correct me if am wrong: Blynk.begin(auth, modem, apn, user, pass,“blynk.cloud”)
Is this how am suppose to write it?

Yes that’s right.

Still can’t connect…this is what am getting from the serial monitor…


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v1.1.0 on ESP32

#StandWithUkraine https://bit.ly/swua

[12940] Modem init…
[13129] Connecting to network…
[20105] Network: Vodacom Tanzania Limited
[20105] Connecting to internet …
[31676] Connected to GPRS
[31742] Connecting to blynk.cloud:80
[45892] Connecting to blynk.cloud:80
[60066] Connecting to blynk.cloud:80
[74208] Connecting to blynk.cloud:80
[88389] Connecting to blynk.cloud:80
[102538] Connecting to blynk.cloud:80

Posting your whole sketch might help.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
float temperature, humidity, pressure, altitude;
unsigned long startTime_BME280 = 0;
unsigned long interval_BME280 = 1000;

#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "TMPLBKkzV62-"
#define BLYNK_DEVICE_NAME "IoT Based AWS"
//#define BLYNK_AUTH_TOKEN "4R0sSW1yoMZiSnRtV_AFCW_Ixb73Y8Mc"

// Select your modem:
#define TINY_GSM_MODEM_SIM800

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] ="4R0sSW1yoMZiSnRtV_AFCW_Ixb73Y8Mc";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "internet";
char user[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro
//define SerialAT Serial1

// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(16,17); // RX, TX

//#include <HardwareSerial.h>
//HardwareSerial SerialAT(2); // RX, TX

TinyGsm modem(SerialAT);

void setup()
{
  // Debug console
  Serial.begin(115200);

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(9600);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");
  
  //Blynk.begin(BLYNK_AUTH_TOKEN, modem, apn, user, pass,"blynk.cloud");
  Blynk.begin(auth, modem, apn, user, pass,"blynk.cloud");

  while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;
    
    // default settings
    status = bme.begin(0x76);  
    
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        while (1) delay(10);
    }
    
    Serial.println("-- Default Test --");
    delay(1000);

    Serial.println();
}

void loop()
{
  Blynk.run();
  BME280_Sensor();
}
void BME280_Sensor(){
    // Read BME280 module values
    unsigned currentTime = millis();
    if(currentTime - startTime_BME280 >= interval_BME280 ){
    startTime_BME280 = currentTime;
    temperature = bme.readTemperature();
    humidity = bme.readHumidity();
    pressure = bme.readPressure() / 100.0F;
    altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
    
    Blynk.virtualWrite(V0, temperature);
    Blynk.virtualWrite(V1, humidity);
    Blynk.virtualWrite(V2, pressure);
    Blynk.virtualWrite(V3, altitude);
    
    Serial.print("Temperature = ");Serial.print(temperature);Serial.println(" °C");
    Serial.print("Humidity = ");Serial.print(humidity);Serial.println(" %");
    Serial.print("Pressure = "); Serial.print(pressure);Serial.println(" hPa");
    Serial.print("Approx. Altitude = ");Serial.print(altitude);     
    Serial.println(" m"); 
   }
 }```
That the code am using. am trying to send BME280 data to the Blynk cloud using sim800L.

@Ateny Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

Must be on the top of your sketch, the first lines.

Why are you using while loop in the void setup ?

You should read this

@John93, I have considered your suggestions but still have no success. Attached is the code based on suggestions.

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "TMPLBKkzV62-"
#define BLYNK_DEVICE_NAME "IoT Based AWS"
//#define BLYNK_AUTH_TOKEN "4R0sSW1yoMZiSnRtV_AFCW_Ixb73Y8Mc"
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM800 // Select your modem:

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] ="4R0sSW1yoMZiSnRtV_AFCW_Ixb73Y8Mc";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "internet";
char user[] = "";
char pass[] = "";

#include <SoftwareSerial.h> //Software Serial on esp32
SoftwareSerial SerialAT(16,17); //gsm RX @ esp32 pin17, gsm TX @esp32 pin16

//#include <HardwareSerial.h> //Hardware Serial on esp32
//HardwareSerial SerialAT(2); // //gsm RX @ esp32 pin17, gsm TX @esp32 pin16
TinyGsm modem(SerialAT);
BlynkTimer timer; // Announcing the timer

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
float temperature, humidity, pressure, altitude;

void setup() {
  // Debug console
  Serial.begin(115200);

  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(9600);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");
  
 //Blynk.begin(BLYNK_AUTH_TOKEN, modem, apn, user, pass,"blynk.cloud");
  Blynk.begin(auth, modem, apn, user, pass,"blynk.cloud");
  timer.setInterval(1000L, BME280_Sensor); //timer will run every sec 
  bme.begin(0x76);
}
void BME280_Sensor(){
    temperature = bme.readTemperature();
    humidity = bme.readHumidity();
    pressure = bme.readPressure() / 100.0F;
    altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
    
    Blynk.virtualWrite(V0, temperature);
    Blynk.virtualWrite(V1, humidity);
    Blynk.virtualWrite(V2, pressure);
    Blynk.virtualWrite(V3, altitude);
    
    Serial.print("Temperature = ");Serial.print(temperature);Serial.println(" °C");
    Serial.print("Humidity = ");Serial.print(humidity);Serial.println(" %");
    Serial.print("Pressure = "); Serial.print(pressure);Serial.println(" hPa");
    Serial.print("Approx. Altitude = ");Serial.print(altitude);     
    Serial.println(" m"); 
 }
void loop() {
  Blynk.run();
  timer.run();        // run timer every second
}

Kindly review and send more comments…

The ESP32 has 3 UARTS (Hardware serial ports) so I don’t understand why you are using SoftwareSerial at all.

To make it even more strange, you’re using pins 16 and 17 which are hardware serial port Serial2.

Pete.

Thank for your concern, this is the UART2 I used at first, but it didn’t work.

#include <HardwareSerial.h> //Hardware Serial on esp32
HardwareSerial SerialAT(2); // gsm RX @ esp32 pin17, gsm TX @esp32 pin16```
I just tried that out...

That snippet of code doesn’t mean very much on its own, but it looks quite strange.

Pete.

Sure, it’s just an extra part of the above code. I was trying to answer the UART question you posted earlier. I am actually using UART 2 in my code.

No, you’re using a virtual UART created in software by the SoftwareSerial library.

I’d have expected something like:

#define SerialAT Serial1
TinyGsm modem(SerialAT);

void setup()
{
  Serial.begin(115200);
  SerialAT.begin(9600);

Pete.

I have declare exactly as you have stated above, but the error is still…
[4897]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v1.1.0 on ESP32

#StandWithUkraine https://bit.ly/swua

[4903] Modem init…
[5090] Connecting to network…
[12348] Network: Vodacom Tanzania Limited
[12348] Connecting to internet …
[22062] Connected to GPRS
[22127] Connecting to blynk.cloud:80
[36278] Connecting to blynk.cloud:80
[50461] Connecting to blynk.cloud:80
[64598] Connecting to blynk.cloud:80
[78786] Connecting to blynk.cloud:80
[92934] Connecting to blynk.cloud:80
[107116] Connecting to blynk.cloud:80

Please use triple backticks when you post serial output.

Two people from SA have had issues with Vodacom blocking the Blynk protocols. Maybe Vodacom Tanzania does the same thing?..

Pete.

2 Likes