Hello! now about 7 days im stuck at this issue
i would like to got AT commands run with my setup:
sim800l v2.0 5V : supplied by dc 5v - nano connected to pc via usb
the at commands never response, unfort i dont have osciloscope to track if the command sent or not.
current wiring:
External regulated +5 V -> SIM800L 5V
External supply negative -> SIM800L GND
Nano GND -> SIM800L GND
Nano 5V -> SIM800L VDD
SIM800L SIM_TXD -> Nano D2
SIM800L SIM_RXD -> Nano D3
sim led blink 1 after 3 secs so registered - issue solved by cp 3k uf
I also tried using resistors way : 10k + 20k and did not works
also tried reverse rx tx and did not works
i played with code in baud side but not help
test code:
#include <SoftwareSerial.h>
const byte SIM_RX_PIN = 2; // Nano D2 <- SIM800L SIM_TXD
const byte SIM_TX_PIN = 3; // Nano D3 -> SIM800L SIM_RXD
SoftwareSerial sim800(SIM_RX_PIN, SIM_TX_PIN);
const long baudRates[] = {
2400,
4800,
9600,
19200,
38400,
57600,
115200
};
const byte baudCount = sizeof(baudRates) / sizeof(baudRates[0]);
bool waitForOK(unsigned long timeoutMs) {
String response = "";
unsigned long start = millis();
while (millis() - start < timeoutMs) {
while (sim800.available()) {
char c = sim800.read();
response += c;
if (c >= 32 && c <= 126) {
Serial.write(c);
} else if (c == '\r') {
Serial.print(F("[CR]"));
} else if (c == '\n') {
Serial.print(F("[LF]"));
} else {
Serial.print(F("[?]"));
}
if (response.indexOf("OK") >= 0) {
return true;
}
}
}
return false;
}
bool sendATandCheck(const char *command, unsigned long timeoutMs) {
while (sim800.available()) {
sim800.read();
}
Serial.print(F("\n[SEND] "));
Serial.println(command);
sim800.print(command);
sim800.print("\r\n");
Serial.println(F("[RESPONSE]"));
bool result = waitForOK(timeoutMs);
Serial.println();
if (result) {
Serial.println(F("[OK DETECTED]"));
} else {
Serial.println(F("[NO OK]"));
}
return result;
}
bool findWorkingBaud() {
for (byte i = 0; i < baudCount; i++) {
long baud = baudRates[i];
Serial.println();
Serial.println(F("================================"));
Serial.print(F("Testing modem baud: "));
Serial.println(baud);
sim800.end();
delay(100);
pinMode(SIM_RX_PIN, INPUT);
pinMode(SIM_TX_PIN, OUTPUT);
digitalWrite(SIM_TX_PIN, HIGH);
sim800.begin(baud);
delay(500);
// Several attempts help an auto-baud SIM800L synchronize.
for (byte attempt = 1; attempt <= 5; attempt++) {
Serial.print(F("Attempt "));
Serial.println(attempt);
if (sendATandCheck("AT", 1500)) {
Serial.print(F("Working baud found: "));
Serial.println(baud);
return true;
}
delay(500);
}
}
return false;
}
bool verifyAt9600() {
sim800.end();
delay(200);
sim800.begin(9600);
delay(500);
for (byte attempt = 1; attempt <= 5; attempt++) {
Serial.print(F("9600 verification attempt "));
Serial.println(attempt);
if (sendATandCheck("AT", 2000)) {
return true;
}
delay(500);
}
return false;
}
void setup() {
Serial.begin(115200);
pinMode(SIM_RX_PIN, INPUT);
pinMode(SIM_TX_PIN, OUTPUT);
digitalWrite(SIM_TX_PIN, HIGH);
Serial.println();
Serial.println(F("SIM800L baud detector and permanent 9600 locker"));
Serial.println(F("Serial Monitor must be 115200 baud"));
Serial.println(F("D2 <- SIM_TXD"));
Serial.println(F("D3 -> SIM_RXD"));
Serial.println(F("Waiting 5 seconds for modem startup..."));
delay(5000);
if (!findWorkingBaud()) {
Serial.println();
Serial.println(F("FAILED: No modem response at any tested baud."));
Serial.println(F("AT+IPR cannot be used until UART communication works."));
return;
}
Serial.println();
Serial.println(F("Changing modem UART to 9600..."));
// This command changes the modem's UART rate.
// The response may be sent just before the change.
sim800.print("AT+IPR=9600\r\n");
delay(1000);
// Reopen the Nano-side UART at the new modem speed.
sim800.end();
delay(200);
sim800.begin(9600);
delay(500);
Serial.println(F("Verifying AT at 9600..."));
if (!verifyAt9600()) {
Serial.println(F("FAILED: Modem did not answer after AT+IPR=9600."));
Serial.println(F("The speed may not have changed or the UART is unstable."));
return;
}
Serial.println(F("Sending AT&W to save 9600 permanently..."));
if (!sendATandCheck("AT&W", 3000)) {
Serial.println(F("WARNING: 9600 works, but AT&W was not confirmed."));
return;
}
Serial.println();
Serial.println(F("SUCCESS"));
Serial.println(F("SIM800L is configured for 9600 baud and saved."));
Serial.println(F("Future sketches should use sim800.begin(9600)."));
}
void loop() {
// No repeated commands.
}
reposne:
================================
Testing modem baud: 2400
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 4800
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 9600
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 19200
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 38400
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 57600
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
================================
Testing modem baud: 115200
Attempt 1
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 2
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 3
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 4
[SEND] AT
[RESPONSE]
[NO OK]
Attempt 5
[SEND] AT
[RESPONSE]
[NO OK]
FAILED: No modem response at any tested baud.
AT+IPR cannot be used until UART communication works.