Friday, 2 October 2015

SIM900 (and SIM900A) module signal strength.

I've been working on a mains monitor project for a while, and I've wanted to interface it to a mobile phone module, so it will send me data. I'll publish the finished thing up soon, but , in the meantime, reading forums etc, people seem to have a couple of problems.

1) Getting the oh-so-very-cheap SIM900A module to work.

2) Getting a signal strength report from the thing.

The first problem appears to be that the SIM900A module, which I purchased for less than a tenner from eBay, doesn't work outside Asia. Yep. It certainly doesn't work here in the UK. But, never fear, there's a website with all the info to help us out. which, after a little fiddling about, had provided a firmware cure. Now I have used my little FTDI module to flash the firmware on my unit at 57,600 Baud. The website claims you need to set the baudrate of your device to 460800 baud, which mine won't support. It worked fine at 57,600, however. I did have to wait a little while (about 20 mins) for the process to complete though.
The second problem seems to bug a lot of users. I searched in vain for a ready-to-go library to solve all my woes, but couldn't find one, so here's a little routine to get the signal strength out of the unit, so you can do with it what you will...
#include <SoftwareSerial.h>
SoftwareSerial SIM900 (6,7); // SIM900 connected to pins 6 & 7 (pin 6 to SIMT and pin 7 to SIMR)
char Reply[200]; // Serial buffer length
int number = 43; // msg length
int Signal; // Signal strength as reported
int temp1; // 4 temporary integers, used to extract the data from the incoming serial.
int temp2;
int temp3;
int temp4;
int BER; // Bit error rate
int SignaldBm; //Signal in dBm
void setup() { SIM900.
SIM900.begin(9600); // Start serial comms with module
Serial.begin(57600); // Start serial comms with PC
void GetStatus() { SIM900.
SIM900.write("AT+CMGF=1\r"); //set GSM to text mode
delay (150); SIM900.
SIM900.write("AT+CSQ\r"); //Send command for signal report
delay (200);
while(SIM900.available() >0 ) { //wait for responce
for(int i=0; i<44; i++) //read character into array from serial port
Reply[i] =; } Reply[199] =
Reply[199] = '/0'; temp1=Reply[31]-

temp1=Reply[31]-'0'; //convert relevant characters from array into integers
temp2=Reply[32]-'0'; temp3=Reply[33]-
temp3=Reply[33]-'0'; temp4=Reply[34]-

if (temp1 == -48) { //if temp1 is -48 then do it again as the data is not valid (yet)

if (temp3 == -4) { // use temp3 to determine where in the array the relevent integers are (-4 is a ",")
Signal= temp2+ temp1*10; // calculate signal if the first digit is a multiple of 10
BER = temp4;

else{ Signal= temp1;
Signal= temp1; //calculate signal if the first digit is not a multiple of 10
BER = temp3;

if ( Signal == 99) { // if our signal is 99, IE no signal condition , the return a signal of -1
Signal = -1;

SignaldBm = Signal*2 -113; // calculate dBm for geeks like me.
Serial.print ("Signal: "); //output stats to serial interface.
Serial.println (Signal);
Serial.print (SignaldBm);
Serial.println ("dBm");
Serial.print ("BER: ");
Serial.println (BER); }

void loop() { GetStatus (); }
GetStatus ();
There , I hope that eases the pain for a few users! Have fun, and check back soon for the mains monitor!

No comments:

Post a Comment