AnswerBun.com

Receive an array of characters using SIM900 module

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);
    }
}

2 Answers

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

Add your own answers!

Related Questions

Strange Arduino Serial Behavior

1  Asked on September 25, 2021 by interrobang

     

NodeMCU ESP8266

1  Asked on September 25, 2021 by anirudh-garg

     

Arduino Due Master Programming

0  Asked on September 25, 2021 by vamshi-krishna

       

Arduino Modbus Slave Library Needed

1  Asked on September 25, 2021 by a-h-shukry

 

2xArduinos, 2xDevices, I2C setup

0  Asked on September 25, 2021 by tomasito

     

ESP8266 OTA update with different flash size settings?

1  Asked on September 25, 2021 by brick

       

Esp32: is OTA compatible with FREERTOS

1  Asked on September 25, 2021 by glamis

   

regarding ardunio error

0  Asked on September 25, 2021 by pratham-maheshwari

     

ESP12E motorshield analogWrite issue when powering DC motor

1  Asked on February 28, 2021 by ameya-savale

     

Arduino Turn Signals

2  Asked on February 22, 2021

 

Arduino Pro Micro bricked?

2  Asked on February 17, 2021 by george-sp

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir