Hi, I’m trying to get my code to connect through a TTGO T-CALL to a private server.
Over wifi, locally and externally there’s no problem so far.
However, when trying to connect through the gprs modem it fails when using the private server, but works with the public cloud server?
Code:
// TTGO T-Call pin definitions
#define MODEM_RST 5
#define MODEM_PWKEY 4
#define MODEM_POWER_ON 23
#define MODEM_TX 27
#define MODEM_RX 26
#define I2C_SDA 21
#define I2C_SCL 22
#define BLYNK_PRINT Serial
#define BLYNK_HEARTBEAT 30
#define TINY_GSM_MODEM_SIM800
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <Wire.h>
// #include <TinyGsmClient.h>
#include "utilities.h"
// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial
// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1
const char apn[] = "natcom";
const char user[] = "";
const char pass[] = "";
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
const char auth[] = "ChF_4Yd8Wp2Urm5L3h9RwUd8-cLr6ATB";
WidgetLED led1(V2);
BlynkTimer timer;
TinyGsm modem(SerialAT);
// V1 LED Widget is blinking
void blinkLedWidget()
{
if (led1.getValue()) {
led1.off();
Serial.println("LED on V1: off");
} else {
led1.on();
Serial.println("LED on V1: on");
}
}
void setup()
{
// Set console baud rate
SerialMon.begin(115200);
delay(10);
// Keep power when running from battery
Wire.begin(I2C_SDA, I2C_SCL);
bool isOk = setPowerBoostKeepOn(1);
SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL"));
// Set-up modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);
// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println("Initializing modem...");
modem.restart();
String modemInfo = modem.getModemInfo();
SerialMon.print("Modem: ");
SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork(240000L)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
if (modem.isNetworkConnected()) {
SerialMon.println("Network connected");
}
SerialMon.print(F("Connecting to APN: "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass, "http://bynk.xxx.net", 8080)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
Blynk.begin(auth, modem, apn, user, pass);
timer.setInterval(1000L, blinkLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
Log:
14:36:57.908 -> Initializing modem...
14:37:04.877 -> Modem: SIM800 R14.18
14:37:04.877 -> Waiting for network... OK
14:37:12.284 -> Network connected
14:37:12.284 -> Connecting to APN: natcom OK
14:37:21.144 -> [26271]
14:37:21.144 -> ___ __ __
14:37:21.144 -> / _ )/ /_ _____ / /__
14:37:21.144 -> / _ / / // / _ \/ '_/
14:37:21.144 -> /____/_/\_, /_//_/_/\_\
14:37:21.144 -> /___/ v0.6.1 on ESP32
14:37:21.144 ->
14:37:21.144 -> [26274] Modem init...
14:37:21.181 -> [26297] Connecting to network...
14:37:21.181 -> [26309] Network: 37203
14:37:21.181 -> [26309] Connecting to natcom ...
14:37:30.357 -> [35474] Connected to GPRS
14:37:30.357 -> [35485] Connecting to blynk.xxx.net:8080
14:37:32.582 -> [37697] Ready (ping: 968ms).
14:37:48.574 -> [53708] Connecting to blynk.xxx.net:8080
14:39:07.602 -> [132716] Connecting to blynk.xxx.net:8080
14:40:34.433 -> [211724] Connecting to blynk.xxx.net:8080
14:41:49.612 -> [290732] Connecting to blynk.xxx.net:8080
However with public blynk cloud log:
14:50:52.349 -> IP5306 KeepOn OK
14:50:55.482 -> Initializing modem...
14:51:02.446 -> Modem: SIM800 R14.18
14:51:02.446 -> Waiting for network... OK
14:51:09.072 -> Network connected
14:51:09.072 -> Connecting to APN: natcom OK
14:51:59.701 -> [67224]
14:51:59.701 -> ___ __ __
14:51:59.701 -> / _ )/ /_ _____ / /__
14:51:59.701 -> / _ / / // / _ \/ '_/
14:51:59.701 -> /____/_/\_, /_//_/_/\_\
14:51:59.701 -> /___/ v0.6.1 on ESP32
14:51:59.701 ->
14:51:59.701 -> [67226] Modem init...
14:51:59.701 -> [67249] Connecting to network...
14:51:59.701 -> [67260] Network: 37203
14:51:59.701 -> [67260] Connecting to natcom ...
14:52:07.144 -> [74686] Connected to GPRS
14:52:07.144 -> [74697] Connecting to blynk-cloud.com:80
14:52:08.946 -> [76486] Ready (ping: 907ms).
14:52:10.050 -> LED on V1: on
14:52:11.057 -> LED on V1: off
14:52:12.043 -> LED on V1: on
14:52:13.045 -> LED on V1: off
14:52:14.030 -> LED on V1: on
14:52:15.042 -> LED on V1: off
Does anybody know what might be causing this?