Skip to content

Instantly share code, notes, and snippets.

@biskandar
Created October 16, 2013 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biskandar/7010357 to your computer and use it in GitHub Desktop.
Save biskandar/7010357 to your computer and use it in GitHub Desktop.
Arduino Uno + GSM Shield + StarHub Sim Card : Intro
// import the GSM Library
#include <GSM.h>
// define PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess( true ) ; // true with debug enabled
GSMScanner scannerNetworks ;
GSMModem modemTest ;
// save data variables
String IMEI = "862170010105474" ;
// serial monitor result messages
String errorText = "ERROR" ;
void setup() {
// initialize serial communications
Serial.begin( 9600 ) ;
Serial.println( "GSM networks scanner" ) ;
scannerNetworks.begin() ;
// connection state
boolean notConnected = true ;
// start gsm shield
// if your sim has pin , pass it as a parameter of begin() in quotes
while ( notConnected ) {
if ( gsmAccess.begin( PINNUMBER) == GSM_READY ) {
notConnected = false ;
} else {
Serial.println( "Not connected" ) ;
delay( 1000 ) ;
}
}
// get modem parameters
Serial.print( "Modem IMEI : " ) ;
IMEI = modemTest.getIMEI() ;
IMEI.replace( "\n" , "" ) ;
if ( IMEI != NULL ) {
Serial.println( IMEI ) ;
}
// currently connected carrier
Serial.print( "Current carrier: " ) ;
Serial.println( scannerNetworks.getCurrentCarrier() ) ;
// return strength and ber
// signal strength in 0-31 scale, 31 means power > 51 dBm
// ber is the bit error rate, 0-7 scale, 99 ~ not detectable
Serial.print( "Signal strength: " ) ;
Serial.println( scannerNetworks.getSignalStrength() ) ;
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment