GSM 800L module connectivity

SOURCE CODE :

#include <SoftwareSerial.h>
SoftwareSerial sim(3, 2);
int _timeout;
String _buffer;
String number = “+91xxxxxxxxxx”; //-> change with your number
void setup() {
delay(7000); //delay for 7 seconds to make sure the modules get the signal
Serial.begin(9600);
_buffer.reserve(50);
Serial.println(“System Started…”);
sim.begin(9600);
delay(1000);
Serial.println(“Type s to send an SMS, r to receive an SMS, and c to make a call”);
}
void loop() {
if (Serial.available() > 0)
switch (Serial.read())
{
case ‘s’:
SendMessage();
break;
case ‘r’:
RecieveMessage();
break;
case ‘c’:
callNumber();
break;
}
if (sim.available() > 0)
Serial.write(sim.read());
}
void SendMessage()
{
//Serial.println (“Sending Message”);
sim.println(“AT+CMGF=1”); //Sets the GSM Module in Text Mode
delay(1000);
//Serial.println (“Set SMS Number”);
sim.println(“AT+CMGS="+91xxxxxxxxxx"”); //Mobile phone number to send message
delay(1000);
String SMS = “Hello, how are you?”;
sim.println(SMS);
delay(100);
sim.println((char)26);// ASCII code of CTRL+Z
delay(1000);
_buffer = _readSerial();
}
void RecieveMessage()
{
Serial.println (“SIM800L Read an SMS”);
delay (1000);
sim.println(“AT+CNMI=2,2,0,0,0”); // AT Command to receive a live SMS
delay(1000);
Serial.write (“Unread Message done”);
}
String _readSerial() {
_timeout = 0;
while (!sim.available() && _timeout < 12000 )
{
delay(13);
_timeout++;
}
if (sim.available()) {
return sim.readString();
}
}
void callNumber() {
sim.print (F(“ATD”));
sim.print (number);
sim.print (F(“;\r\n”));
_buffer = _readSerial();
Serial.println(_buffer);
}

OUTPUT :
System Started…
Type s to send an SMS, r to receive an SMS, and c to make a call

+CMGS: 137(When ‘s’ is pressed)

OK
SIM800L Read an SMS(when 'r ’ is pressed)
Unread Message doneAT+CNMI=2,2,0,0,0

OK

+CMT: “+91xxxxxxxxxx1”,“”,“19/09/07,15:05:06+22”
Hi arduino
ATD+91xxxxxxxxxx;(when ‘c’ is pressed)

OK

NO CARRIER

Can you please help me rectify the error

In general its really bad to just post a blob of code to any forum and say “fix please”. What did you try? what isnt working exactly? where did the code come from and what is it supposed to do? You need to show you understand the source code well enough to simplify the problem to what the actual error is and show you did preliminary debugging.

For general debugging of hologram simcards the first step is to get to a state where you can manually run AT commands and go thorugh: https://help.hologram.io/en/articles/1944384-modem-sim-annotated-diagnostic-test

You also need to set the APN per: https://help.hologram.io/en/articles/1928455-how-do-i-set-the-apn I dont see this done anywhere. There may be many other reasons why a specific piece of code doesnt do what you want it to do but its up to the author to debug that. If the code is copy / pasted from somewhere I suggest asking the source of where you found it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.