현재 "Internet of Things"도메인하에 미니 프로젝트를 진행 중입니다. GSM 모듈을 사용하여 무선 게시판을 디자인하기로 결정했습니다.Embedded C에서 GSM 모뎀의 메시지를 읽는 방법은 무엇입니까?
프로젝트를 두 개의 모듈로 나눴습니다. 첫째, 완벽하게 완성 된 Arduino-LED 보드 인터페이스.
둘째, GSM-Arduino 인터페이스. 기본적으로 메시지/SMS가 휴대 전화에서 GSM 모듈로 전송 된 다음 Arduino를 사용하여 GSM 모듈에서 해당 메시지를 읽어야합니다. 나는 여기서 문제를 직면하고있다. 메시지가 GSM 모뎀으로 전송되었지만 읽을 수 없습니다. 다른 코드 작성을 시도했지만 작동하지 않습니다. 메시지가 표시되지 않습니다.
다음은 내가 시도한 코드 단편입니다.
`#include SoftwareSerial.h
SoftwareSerial SIM900A(2,3);// RX | TX
// Connect the SIM900A TX to Arduino pin 2 RX
// Connect the SIM900A RX to Arduino pin 3 TX.
void setup()
{
SIM900A.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor(Arduino)
Serial.println ("SIM900A Ready");
delay(100);
Serial.println (" Press s to send and r to recieve ");
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's': SendMessage();
break;
case 'r': RecieveMessage();
break;
}
if (SIM900A.available()>0)
Serial.write(SIM900A.read());
}
void SendMessage()
{
SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
Serial.println ("Set SMS Number");
SIM900A.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); //Replace with your mobileno.
delay(1000);
Serial.println ("Set SMS Content");
SIM900A.println("Hello, I am SIM900A GSM Module");// The SMS text you want to send
delay(100);
Serial.println ("Finish");
SIM900A.println((char)26);// ASCII code of CTRL+Z
delay(1000);
Serial.println (" ->SMS Sent");
}
void RecieveMessage()
{
Serial.println ("SIM900A Receiving SMS");
delay (1000);
SIM900A.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
Serial.write (" ->Unread SMS Recieved");
}`
하드웨어가 작동하는지는 알 수 없습니다. 하드웨어 디버깅을 지원할 수는 없습니다. 줄의 범위가 무엇으로 보입니까? – ThingyWotsit
하드웨어가 정상적으로 작동합니다! GSM 모듈에 SIM 카드를 삽입하고 휴대 전화에서 보낼 때 메시지가 수신되는지 여부를 테스트 할 때 완전히 작동합니다. 수신 메시지를 읽는 방법은 문제가있는 부분입니다. GSM에서 메시지를 읽을 수 없습니다. –
'Arduino 인터페이스에서 데이터를 수신 할 수 없다면 어떻게 테스트합니까? – ThingyWotsit