Hi guys, I know this sounds a basic topic but I have the difficult with sending the AT commands from ESP32 to WisLink Cellular BG96 Arduino Shield module. I connected the pins between EPS32 and BG96 modules as follows: RX2 (ESP32) → TXD1,TX2(ESP32)–> RXD1 and GND–GND. I used the following code:
String inputString1 = “”; // a String to hold incoming data
bool stringComplete1 = false; // whether the string is complete
String inputString2 = “”; // a String to hold incoming data
bool stringComplete2 = false; // whether the string is complete
#define RXD2 16
#define TXD2 17
void setup() {
// initialize serial:
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
// reserve 200 bytes for the inputString:
inputString1.reserve(200);
inputString2.reserve(200);
Serial.println(“ready to test”);
}
void loop() {
// print the string when a newline arrives:
if (stringComplete1) {
Serial2.println(inputString1);
// clear the string:
inputString1 = “”;
stringComplete1 = false;
}
if (stringComplete2) {
Serial.println(inputString2);
// clear the string:
inputString2 = “”;
stringComplete2 = false;
}
serialEvent();
serialEvent1();
}
/*
SerialEvent occurs whenever a new data comes in the hardware serial RX. This
routine is run between each time loop() runs, so using delay inside loop can
delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
Serial.println(“SENDED”);
char inChar = (char)Serial.read();
// add it to the inputString:
inputString1 += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == ‘\n’) {
stringComplete1 = true;
}
}
}
void serialEvent1() {
while (Serial2.available()) {
// get the new byte:
char inChar = (char)Serial2.read();
// add it to the inputString:
inputString2 += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == ‘\n’) {
stringComplete2 = true;
}
}
}
The serial monitor does return anything when I type the command in the Message. Any help is appreciated. Thank you.