It is not possible to receive responses to AT commands from the esp32 from the lilygo t-sim 7670SA card. Although when connected directly to the modem, I receive responses from AT commands. I use the following code:
#include "Arduino.h"
//
#define MODEM_RX_PIN 27 // TX
#define MODEM_TX_PIN 26 // RX
#define BOARD_PWRKEY_PIN 4
#define MODEM_RESET_PIN 25
#define BOARD_POWERON_PIN 12
// Настройки UART
HardwareSerial SerialAT(1); //
#define MODEM_BAUDRATE 115200
uint32_t AutoBaud() {
static uint32_t rates[] = {115200, 9600, 57600, 38400, 19200, 74880, 230400};
for (uint8_t i = 0; i < sizeof(rates)/sizeof(rates[0]); i++) {
uint32_t rate = rates[i];
Serial.printf("Пробуем скорость %u...\n", rate);
SerialAT.begin(rate, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);
delay(500);
for (int j = 0; j < 5; j++) {
SerialAT.println("AT");
delay(150);
if (SerialAT.available()) {
String response = SerialAT.readString();
if (response.indexOf("OK") >= 0) {
Serial.printf("Успех! Скорость: %u\n", rate);
return rate;
}
}
}
}
SerialAT.begin(MODEM_BAUDRATE, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);
return 0;
}
void setup() {
Serial.begin(115200);
delay(1000);
//
pinMode(BOARD_POWERON_PIN, OUTPUT);
digitalWrite(BOARD_POWERON_PIN, HIGH); //
delay(500);
//
pinMode(MODEM_RESET_PIN, OUTPUT);
digitalWrite(MODEM_RESET_PIN, LOW);
delay(200);
digitalWrite(MODEM_RESET_PIN, HIGH);
delay(2000); //
digitalWrite(MODEM_RESET_PIN, LOW);
//
pinMode(BOARD_PWRKEY_PIN, OUTPUT);
digitalWrite(BOARD_PWRKEY_PIN, LOW);
delay(100);
digitalWrite(BOARD_PWRKEY_PIN, HIGH);
delay(500); //
digitalWrite(BOARD_PWRKEY_PIN, LOW);
delay(2000); //
//
if(AutoBaud()) {
Serial.println(F("\n************************************************"));
Serial.println(F(" The modem is ready to work"));
Serial.println(F(" AT:"));
Serial.println(F(""));
Serial.println(F("************************************************\n"));
} else {
Serial.println(F("error"));
Serial.println(F("error"));
Serial.println(F("error"));
Serial.println(F("error"));
while(1); //
}
}
void loop() {
//
if(SerialAT.available()) {
Serial.write(SerialAT.read());
}
if(Serial.available()) {
SerialAT.write(Serial.read());
}
delay(1);
}
Please tell me what could be my mistake?
When connected directly to the module, I get the answers to the AT commands. When connected via esp32, I do not receive it.