3

Recently I got new Arduino Mega 2560 and GSM/GPRS module - SIM900A v3.8.2.

I live in Europe, so I flashed European firmware for SIM900 and it was working OK (sending SMS, receive calls, sending http requests with GPRS) on my PC using PuTTY serial port terminal. After few tests, I ran default sketches from MarcoMartines GSMSHIELD library (other libraries weren't working for me) with Arduino Mega 2560 and they were running ok. After that I decided to make my own sketch. Here you go:

#include "SIM900.h"
#include "inetGSM.h"
#include "sms.h"
#include "call.h"
char NumberCalling[20];
char CorrectNumber[20] = {"5", "0", rest of my number here..... };
void InstantSendSms()
{
 Serial.print(F("SMS: Preparing a text message to be sent to: "));
 Serial.println(CorrectNumber);
 char Message[155];
 sprintf(Message, "Hello from Arduino :)");
 Serial.print(F("Message to be sent : "));
 Serial.println(Message);
 sms.SendSMS(CorrectNumber, Message);
 delay(50);
 Serial.println(F("SMS: Message has been sent."));
}
void InstantSendHttp()
{ 
 char Address[155];
 sprintf(Address, "test.php?text=test-message");
 Serial.println(F("GPRS: Opening a new Internet connection..."));
 if (inet.attachGPRS("internet", "", ""))
 Serial.println(F("GPRS: Attached!"));
 else 
 Serial.println(F("GPRS: NOT attached! Error."));
 delay(1000);
 //Read IP address.
 gsm.SimpleWriteln("AT+CIFSR");
 delay(5000);
 //Read until serial buffer is empty.
 gsm.WhileSimpleRead();
 Serial.print(F("GET request : "));
 Serial.println(Address);
 char ReturnedMsg[50];
 int NumberRetMsg;
 NumberRetMsg = inet.httpGET("myserver.com", 80, Address, ReturnedMsg, 50);
 //Print the results.
 Serial.println(F("GPRS: Number of data received:"));
 Serial.println(NumberRetMsg); 
 Serial.println(F("GPRS: Data received:")); 
 Serial.println(ReturnedMsg); 
 inet.dettachGPRS();
 Serial.println(F("GPRS: Query has been sent."));
 delay(2000); // time to finish
}
void setup()
{
 Serial.begin(9600); // Serial connection via USB for debugging purposes
 Serial.println(F("*** Device is starting... ***"));
 delay(50);
 Serial.println(F("* Setting up the GSM Module... *"));
 // connection state
 boolean Connected = false;
 // establish network connection...
 while (!Connected)
 {
 if (gsm.begin(9600))
 {
 Serial.println(F("** GSM : GSM connection established. Ready. **"));
 Connected = true;
 }
 else 
 {
 Serial.println(F("** GSM : Failed to connect to the GSM network. **"));
 }
 }
 delay(50);
 Serial.println(F("*** Setup complete! All systems are ON ***"));
}
void loop()
{
 Serial.println(F("GSM: Checking voice call status..."));
 switch(call.CallStatusWithAuth(NumberCalling, 0, 0))
 {
 case CALL_INCOM_VOICE_AUTH: // Yes! Someone is calling us
 Serial.print(F("GSM: Receiving call... Caller ID: "));
 Serial.println(NumberCalling);
 if(strcmp(NumberCalling, CorrectNumber) == 0)
 {
 Serial.println(F("GSM: Number IS matching whitelist!"));
 delay(1800); // Wait 1,8 seconds before hang up
 call.HangUp(); // Hang up on me
 InstantSendSms();
 InstantSendHttp();
 }
 else
 {
 Serial.println(F("GSM: Caller is unknown."));
 call.HangUp();
 }
 break;
 case CALL_NONE:
 Serial.println(F("GSM: No one is callin us right now."));
 break;
 default:
 Serial.println(F("GSM: Talking or not responding..."));
 break;
 }
 delay(10);
}

At first, I used 9600 baud for GSM in the sketch. It successfully sent an SMS, but no luck with GPRS - in the Serial Monitor I got always the error message:

GPRS: NOT attached! Error.

I read on the Internet that the baud rate is very important here. Somewhere on this forum I got the information that I should change baud rates in HWSerial.cpp and GSM.cpp in the library files to 4800 baud.

Well, I tried different bauds in my sketch. Finally I got this working with this configuration: in my sketch - 19200 baud, in library - 4800 baud. I run Arduino, SMS was sent ok, GPRS said "GPRS: Attached!" but no data came to my website. Then suddenly SIM900 module stopped working it is weirdly blinking. Power LED is brightening and darkening, and never goes off, and Status LED is quickly blinking. You can see that on the video, SIM900A Mini v3.8.2 - Weird blinking | Module not responding.

I connected it directly to my PC, PuTTy was receiving crazy input from the SIM900, as you can see below:

PuTTY Receives corrupted input

I thought that maybe the firmware had broken and I flashed again new firmware. It went smoothly and ok, but then again, module is acting in a strange way, the same as before.

What can I do to get it working normally?


UPDATE: Hello. Today I tried again to work with my module. I communicated with sim900 using http://m2msupport.net/m2msupport/module-tester/ , things are getting better, SIM900 is responding to AT commands. Module still doesn't work as it is supposed to - PowerLed is ON, StatusLed is indicating connecting to the network. It seems to be connected for about a second and then SIM900 is self-resetting and doing that over and over. How to fix that? I don't think here power supply is guilty - it's 5V 2A.

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Dec 31, 2015 at 10:02
9
  • There are pieces missing from your code I think. Please post the full code. Commented Dec 31, 2015 at 15:40
  • Well, I am designing a system which has GSM connection and GPS receiver and few more feautures. I started with GSM module and I got stuck with it, so I haven't wrote any more code. For now it's all I have. Commented Dec 31, 2015 at 18:42
  • What baudrate SIM900 is specified to work at? (The current output you get on your PC seems like you are using the wrong baudrate) Commented Dec 31, 2015 at 20:37
  • Also, you should not use if GSM.begin, use while(!GSM.begin). Commented Dec 31, 2015 at 20:40
  • SIM900 is supposed to work at 19200 but many people reccomned lower bauds. Thanks for the tip. I'll absolutely do that, now I'm facing SIM900 problem, with the arduino code I'll deal later :) Commented Jan 2, 2016 at 14:50

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.