Heet Shukla
Heet Shukla

Reputation: 1

I'm Trying to Connect Internet with ESP32 using Cavlii C16Qs. but ESP32 is not Getting Internet Connectivity

I'm trying OTA Firmware update of ESP32 using Cavlii C16Qs. I'm trying to Connect internet with ESP32 using Cavlii C16Qs. Basically issue is I'm Not getting Internet Connectivity using "AT+PPPSTART" and Cavli C16Qs modem. Cavlii C16Qs is use for Providing a LTE Network. I'm trying to Internet Connection using "AT+PPPSTART" Command. https://cavli.atlassian.net/servicedesk/customer/portal/8/topic/6c7a6bd9-155b-4438-84bb-4807e4f8db19/article/343015460 This is the link of Document for AT Commands Details. So what should I change in the below code so that esp 32 can get internet connectivity through Cavlii C16Qs? So that I can fetch the firmware file from the server.

AIM: ESP32 OTA using External modem Internet Connectivity, HTTP.h and Update.h Library.

Arduino IDE Version: 1.8.19 ESP32 Board Version: 2.0.0

Serial is use for Debug, and Serial1 is use for Serial Communication with Cavlii C16Qs.


#include <HTTPClient.h>
#include <update.h>

/* Cavli_C16QS */
String response = "";
const char *ipAddr;
String st1;
int value1, value2;
int clientID;

void setup() {
 // Power up the ESP32 by toggling the PWRKEY pin
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  delay(100);
  digitalWrite(2, HIGH);

  Serial.begin(115200);
  Serial1.begin(115200, SERIAL_8N1, 32, 33);  // RX, TX

  //////////////////////////////////
  // Send AT command via Serial to Cavli module
  Serial.println("Sending ATI command to Cavli module");
  Serial.println("==================================");
  Serial1.print("ATI");  // Send command via Serial2
  // FeedBack();
  delay(1000);
  while (Serial1.available()) {
    char c = Serial1.read();
    Serial.print(c);
  }
  Serial.println("Sending AT+COPS?");
  //////////////////////////////////
  // Read and print responses from Cavli module via Serial2
  while (!(response.indexOf("+ATREADY") != -1 || response.indexOf("OK") != -1)) {  
    Serial1.print("AT+COPS?\r\n");                                                 
    while (Serial1.available()) {
      char c = Serial1.read();
      response += c;
    }
     Serial.print("response-->");
     Serial.println(response);
  }
  delay(1000);  // Add a delay after sending the command
  response = "";
  //////////////////////////////////
  value1 = value2 = -1;
  Serial.println("Sending AT command... +CEREG? Checking network connectivity");
  while (!(value1 == 0 && (value2 == 1 || value2 == 5))) {
    Serial1.write("AT+CEREG?\r\n");
    delay(500);
    while (Serial1.available()) {
      char c = Serial1.read();
      response += c;
    }
     Serial.print("response-->");
     Serial.println(response);
    response = "";
  }

  delay(5000);  // Add a delay after sending the command
  response = "";
  //////////////////////////////////
  value1 = value2 = -1;
  Serial.println("Sending AT command... +CGACT? Checking internet connectivity");
  while (!(value1 == 1 && value2 == 1)) {
    Serial1.write("AT+CGACT?\r\n");
    delay(500);
    while (Serial1.available()) {
      char c = Serial1.read();
      response += c;
    }
     Serial.print("response-->");
     Serial.println(response);
     response = "";
  }
  //////////////////////////////////
  delay(500);  // Add a delay after sending the command
  response = "";
  Serial.println("Sending AT+NETIF?");
  Serial1.print("AT+NETIF?\r\n");  // Send command via Serial2
  // Read and print responses from Cavli module via Serial2
    while (Serial1.available()) {
      char c = Serial1.read();
      response += c;
    }
     Serial.print("response-->");
     Serial.println(response);
     response = "";

      Serial.println("Sending AT+PPPSTART");
      Serial1.print("AT+PPPSTART=?\r\n");  // Send command via Serial2
      // Read and print responses from Cavli module via Serial2
    while (Serial1.available()) {
      char c = Serial1.read();
      response += c;
    }
     Serial.print("response-->");
     Serial.println(response);
     response = "";

  String _url = url_OTA_code_head + code_ver + url_OTA_code_tail;
  delay(2000);

  HTTPClient http;
  http.begin(_url);
  int httpCode = http.GET();
  Serial.println(httpCode);

  Serial.println("----------------------------End Setup----------------------------");
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

Upvotes: 0

Views: 187

Answers (1)

Haresh Sondagar
Haresh Sondagar

Reputation: 82

You need to use P32C1RM-Arduino library for examples

Below is attached link for that library. Please download it and unzip to libraries folder if you are using arduino.

If you are using platfromio, just define library in platformio.ini file as shown here:

lib_deps = https://github.com/cavli-wireless/P32C1RM-Arduino.git

LINK

Upvotes: -1

Related Questions