Jump to content


Photo

SMS not printing to Serial monitor when running sim900a on uno r3

sms serial arduino uno sim900a

  • Please log in to reply
1 reply to this topic

#1 precociousmouse

precociousmouse

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 20 December 2016 - 09:30 AM

Hey there!

 

I am running a linksprite sim900a gsm/gprs shield on an arduino uno r3, but am trouble checking if SMS are reaching the device. I am running the following code:

#include <SoftwareSerial.h>
#include <FastLED.h>

#define DATA_PIN 6
#define NUM_LEDS 100
#define COLOR_ORDER RGB

CRGB leds[NUM_LEDS]; 

int whichLED = 0;
int message[] = {79,93,10,10,28,255,89,79,14,77,16,18,69,93,16,255,83,14,8,69,255,81,18,91};

char alphalookup[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int alphacompare[26] = {93,91,89,87,85,83,81,79,77,75,73,71,69,6,8,10,12,14,16,18,20,22,24,26,28,30};


int offset = 0;
SoftwareSerial SIM900(7, 8);
char incoming_char=0;

void setup()
{
  
  Serial.begin(19200);
  SIM900.begin(19200);
  Serial.print(".");
  delay(20000);
  SIM900.print("AT+CMGF=1\r");
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  delay(100);
  SIM900.print("AT+CSMS?\r");
  delay(100);
  
  FastLED.addLeds<WS2811, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

  for(int clearThis = 0; clearThis < NUM_LEDS; clearThis++){
    leds[clearThis] = CRGB (255,0,0);
    FastLED.show();
    delay(10);
  }
  for(int clearThis = 0; clearThis < NUM_LEDS; clearThis++){
    leds[clearThis] = CRGB (0,0,0);
    FastLED.show();
    delay(10);
  }
}



void SIM900power()
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}
void loop()
{
  if(SIM900.available() >0)
  {
    incoming_char=SIM900.read();
    Serial.print(incoming_char);

    if(incoming_char == ' '){
      delay(250);
    } else {
      for(int whichPos = 0; whichPos < 26; whichPos++){
      
        if(incoming_char == alphalookup[whichPos]){
        FastLED.clear();
        leds[alphacompare[whichPos]] = CRGB (floor(random(255)),floor(random(255)),floor(random(255)));
        leds[alphacompare[whichPos] + 1] = CRGB (floor(random(255)),floor(random(255)),floor(random(255)));
        FastLED.show();
        delay(250);
        leds[alphacompare[whichPos]] = CRGB (0,0,0);
        leds[alphacompare[whichPos] + 1] = CRGB (0,0,0);
        FastLED.show();
        }
      }
    }
  }
}

The AT commands are setting up ok, AT+CSMS is responding 0,1,1,1 as expected - but when I send an sms to the device it doesn't print out to the serial monitor. I am running the arduino through a usb connection and I am running the sim900a shield from an external power source.



#2 precociousmouse

precociousmouse

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 03 January 2017 - 01:42 PM

Ok, so I found the issue was that the board had a sim900a module, not a sim900 - so it wouldn't connect to my networks







Also tagged with one or more of these keywords: sms, serial, arduino, uno, sim900a

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users