1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

iterfacing sim908 with arduino

Discussion in 'Arduino' started by aamir shabbir, Jan 29, 2015.

  1. aamir shabbir

    aamir shabbir Member

    Joined:
    Sep 10, 2013
    Messages:
    48
    Likes:
    0
    Guyz im trying to interface sim908 with arduino uno the problem is when i send AT to sim908 the output should be OK but when i check the output with serial available and check it on serial monitor the serial monitor shows a series of AT and OK AT and OK continuously and the code doesnot get out of the loop of serial available what might be the problem please guide me i tried a lot but could not figure it out


    This is the code for reference

    #include <SoftwareSerial.h>
    int ledPin = 13; // select the pin for the LED
    void setup()
    {
    Serial.begin(115200);
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, LOW);
    delay(1500);
    Serial.println("AT");
    delay(1500);
    }
    void loop()
    {
    while (Serial.available())
    {
    char inChar = (char)Serial.read();
    Serial.write(inChar);
    }



    And this is the output:
    AT
    AT
    OK
    AT
    OK
    OK
    AT
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    OK
    AT
    OK
    OK
    OK
    OK
     
    Last edited: Jan 29, 2015
  2. aamir shabbir

    aamir shabbir Member

    Joined:
    Sep 10, 2013
    Messages:
    48
    Likes:
    0
    al though the output should be only AT but the output is a series of infinite loop what is the problem please guide
     
  3. b.james

    b.james Member

    Joined:
    Feb 4, 2014
    Messages:
    167
    Likes:
    9
    Try dropping your serial speed to 9600
    There should be an extra bracket at the end . You must have it there or it would not compile
    Its repeating setup each time as part of the loop
    It adds an extra OK each time

    All of these should tell you something . You have but to look!
    For your info on my ATMega328P without anything connected it shows AT only once and then outputs anything put into the send line
     
    Last edited: Jan 31, 2015
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,168
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE

    You are reading the output wrong.... The "AT" is sent to the 908 only once... The 908 will only reply with "OK"..
    This can mean only one thing.... The setup function is being called again and again... This is being rebooted... Maybe the compiler has compiled with the missing brace at the end and the processor is having a stack underflow....
     

Share This Page