You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Arduino Uno连接SIM900 Shield无AT指令响应问题求助

Troubleshooting: SIM900 Doesn't Respond to AT Commands via Serial Monitor (But Sends SMS via Code)

Hey there! I see your Arduino Uno + SIM900 Shield works perfectly when running your SMS-sending code, but you can't get an "OK" response when sending AT commands manually via the Serial Monitor. Let's break down why this is happening and fix it step by step:

1. No Serial Traffic Bridge Between PC and SIM900

Your code uses SoftwareSerial (pins 7 and 8) to communicate with the SIM900, but the Serial Monitor connects to Arduino's hardware USB serial port (pins 0 and 1). Right now, there's no code to pass messages between these two ports—so your PC's AT commands never reach the SIM900, and the module's responses never make it back to your monitor.

Fix this by updating your code to act as a serial bridge:

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);

void setup() {
  SIM900.begin(19200);
  // Add this to initialize hardware serial for Serial Monitor
  Serial.begin(19200);
  delay(20000);
  sendSMS();
}

void loop() {
  // Forward SIM900's responses to Serial Monitor
  if (SIM900.available()) {
    Serial.write(SIM900.read());
  }
  // Forward Serial Monitor commands to SIM900
  if (Serial.available()) {
    SIM900.write(Serial.read());
  }
}

void sendSMS() {
  SIM900.print("AT+CMGF=1\r");
  delay(100);
  SIM900.println("AT+CMGS=\"+212625429762\"");
  delay(100);
  SIM900.println("Message example from Arduino Uno.");
  delay(100);
  SIM900.println((char)26);
  delay(100);
  SIM900.println();
  delay(5000);
}

2. Baud Rate Mismatch

Double-check that your Serial Monitor is set to 19200 baud—the exact same rate you used in SIM900.begin(19200);. If the rates don't match, you'll see garbled text (or nothing at all) instead of the expected "OK" response.

3. Incorrect AT Command Format

SIM900 expects AT commands to end with a carriage return (\r). When sending manually:

  • Make sure you send AT\r (not just "AT")
  • Stick to standard formatting (avoid extra spaces like AT + CMGF=1—use AT+CMGF=1\r instead)
  • Set the Serial Monitor's line ending option to "Both NL & CR"—this automatically appends the required \r\n to your commands

4. Module Busy State (Unlikely, But Worth Checking)

After uploading your original code, the SIM900 might take a few seconds to finish processing the SMS or network registration. Wait 10-15 seconds after uploading the updated code before sending AT commands to ensure the module is idle.

Quick Test After Fixes:

  1. Upload the updated code with the serial bridge
  2. Set Serial Monitor to 19200 baud and "Both NL & CR"
  3. Send AT—you should get an immediate "OK" response

That should resolve the issue! Let me know if you hit any other roadblocks.

内容的提问来源于stack exchange,提问作者amansour

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:02:36