Skip to content

Instantly share code, notes, and snippets.



Last active Sep 22, 2015
What would you like to do?
SIM900 Arduino Shield AT Serial
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
char incoming_char=0;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup()
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
void loop()
serialEvent(); //call the function
// print the string when a newline arrives:
if (stringComplete) {
inputString = inputString + "\r";
// clear the string:
inputString = "";
stringComplete = false;
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{; //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char);
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment