Arduino Asked by Reza Qasemi on December 24, 2021
I tried to receive an array of characters using SIM900, but I couldn’t. I can receive just one character like 'G'
, but I want to receive a string "abcd"
. When I used char*
to save the SMS, I failed.
Does anyone know how?
My code:
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
void setup()
{
pinMode(3,OUTPUT);
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(20000); // give time to log on to network. `
SIM900.print("AT+CMGF=1r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button24
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{
char *in = SIM900.read();
if (in =="abcd") digitalWrite(3,HIGH);
if (in == "00") digitalWrite(3,LOW);
}
}
It solved . I used another library that manipulated . And just support sim900 U can get it in this below link and include to your arduino IDE This library written by digispark group
Answered by Reza Qasemi on December 24, 2021
#use this code and then inform me"
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
void setup()
{
pinMode(3,OUTPUT);
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(20000); // give time to log on to network. `
SIM900.print("AT+CMGF=1r"); // set SMS mode to text
SIM900.write(0x22);
SIM900.write(0x0D);
SIM900.write(0x0A);
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button24
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{
char *in = SIM900.read();
if (in =="abcd") digitalWrite(3,HIGH);
if (in == "00") digitalWrite(3,LOW);
}
}
Answered by user38182 on December 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP