First of all, thanks for trying to help despite lack of the code.
Here's my code:
#include "FS.h"
#include "SD.h"
#define SIM800L_IP5306_VERSION_20190610
#include "utilities.h" //this is for Lilygo T-call SIM800 board I use
#define SCK 14
#define MISO 2
#define MOSI 15
#define CS 13
SPIClass spi = SPIClass(VSPI);
// Define the serial console for debug prints, if needed
#define TINY_GSM_MODEM_SIM800 // Modem is SIM800
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#include <TinyGsmClient.h>
#define RXD2 26
#define TXD2 27
#define SerialAT Serial2
const char apn2[] = "live.vodafone.com";
const char gprsUser[] = "live";
const char gprsPass[] = "";
String apn;//="live.vodafone.com";//, gprsUser, gprsPass;
#define DUMP_AT_COMMANDS
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, Serial);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#include <ArduinoHttpClient.h>
TinyGsmClient client(modem);
int i;
void setup()
{ int i;
Serial.begin(115200); delay(1500); Serial.println("Hello!");
// Start power management
if (setupPMU() == false) {
Serial.println("Setting power error");
}
// Some start operations
setupModem();
SerialAT.begin(115200, SERIAL_8N1, RXD2, TXD2);
delay(6000);
if (!modem.init()) {
Serial.println("Failed to initialize modem");
delay(2000);
}
SerialAT.println("AT"); //Once the handshake test is successful, it will back to OK
delay(200);
initSDcard();
readInternet(SD, "/internet.txt");
delay(10000);
}
void loop()
{
connectGPRS();
disconnectGPRS();
delay(60000);
}
void connectGPRS(void)
{
if (!modem.gprsConnect(apn.c_str(), gprsUser, gprsPass))
//if (!modem.gprsConnect(apn2, gprsUser, gprsPass))
{
Serial.println(" fail");
delay(10000);
return;
}
Serial.println(" success");
if (modem.isGprsConnected())
{
Serial.println("GPRS connected");
}
}
void disconnectGPRS(void)
{
modem.gprsDisconnect(); Serial.println("GPRS disconnected");
}
char readInternet(fs::FS &fs, const char * path)
{ //return 0 daca e OK
String kkk;
Serial.printf("Reading file: %s\n", path);
File file = fs.open(path);
if(!file){
Serial.println("Failed to open file for reading");
return(1);
}
apn=file.readStringUntil('\n');
Serial.print("APN:"); Serial.println(apn);
file.close();
return(0);
}
unsigned char initSDcard() //returneaza 0 daca e OK
{
spi.begin(SCK, MISO, MOSI, CS);
if (!SD.begin(CS,spi,80000000)) {
Serial.println("Card Mount Failed");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);
return 0;
}
Now, as I said in the first post, I isolated the faulty spot.
If I connect with apn2 (see the commented line) it works.
The output is:
Hello!
AT
OK
ATE0
OK
AT+CMEE=0
OK
AT+CLTS=1
OK
AT+CBATCHK=1
OK
AT+CPIN?
OK
SD Card Size: 7497MB
Reading file: /internet.txt
APN:live.vodafone.com
AT+CIPSHUT
OK
AT+CGATT=0
Call Ready
SMS Ready
+CTZV: +12,1
*PSUTTZ: 2023,10,5,12,47,40,"+12",1
ERROR
AT+CGACT=1,1
OK
AT+SAPBR=1,1
ERROR
AT+SAPBR=2,1
+SAPBR: 1,3,"0.0.0.0"
AT+CIPQSEND=1
OK
AT+CIPRXGET=1
OK
AT+CSTT="live.vodafone.com ","live",""
ERROR
fail
AT+CIPSHUT
SHUT OK
AT+CGATT=0
OK
GPRS disconnected