Click here to Skip to main content
15,504,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.
I want to make a project using an arduino and SIM900 to send a sms,but doesn't work and I want your help to figure it out,because I do not understand some things.
I asked in arduino forum,but I also ask here.
Code:

What I have tried:

C++
<pre>#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 7);

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);

  Serial.println("Initializing...");
  delay(1000);
  mySerial.println("AT+CPIN = \"7394\""); // sim password
  updateSerial();
 
  mySerial.println("AT");
  updateSerial();

  mySerial.println("AT+CMGF=1");
  updateSerial();

  mySerial.println("AT+CMGS=\"+30XXXXXXXXXX\"");  // I don't show phone number
  updateSerial();
  mySerial.print("Hello world"); //text content
  updateSerial();
  mySerial.write(26);
}

void loop()
{
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available())
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}




Output:

Initializing...
AT+CPIN = "7394"

OK
AT

OK
AT+CMGF=1

OK

+CREG: 2
AT+CMGS="+30XXXXXXXXXX" // I don't show phone number right here

> Hello world




So,I don't receive any messages.
Also,I don't understand what is the meaning of +CREG: 2

I searched in google and I found:
2 not registered, but MT is currently searching a new operator to register to
but I don't understand what is the meaning of this.

I use Arduino Uno and here is sim900[^]
Posted
Updated 5-Apr-21 12:46pm

1 solution

Hello
Try to swap pins 8 and 7:

SoftwareSerial mySerial(7, 8);

Regards

Gil
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900