element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Need help with arduino programming
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 1 reply
  • Subscribers 400 subscribers
  • Views 285 views
  • Users 0 members are here
Related

Need help with arduino programming

Former Member
Former Member over 12 years ago

Hello all. Nice forum!

 

I am new to arduino programming and electronics. So I am having problem trying to figure out what to put where.image Please tell me if there is anything to be done to improve and also if there is any mistakes in code or poor programming practice. 

 

I have an arduino mega 2560 board connected to a GSM sim 900 module. I need to send text messages from the GSM module.

 

Hardware connections: VCC of GSM connected to 5Vpin of mega. V interface pin of GSM is supplied with same voltage as microcontroller (from Vin pin of mega) as specified in its manual. TXD of GSM is connected to RX3 of arduino and RXD of GSM to TX3 of mega board.

image

Problem :

I am able to send blank text messages with the program I have. But when I insert a new statement to enter text into message body, GSM module do not send message. The instructions to be send to GSM modem is:

AT+CMGF=1 // for setting GSM modem to text message mode

AT+CMGS="<phone number>" text message <enter>

 

This is the program I used:

 

char mobileno[]="+xxxxxxxxxxxx";     

void setup()

{


   Serial.begin(115200);      //For pc and arduino communication.

  Serial3.begin(115200);    // Gsm Modem baud rate

 

}


void loop()

{

  Serial3.println("AT+CMGF=1"); // to set in text mode

  delay(800);

  Serial3.print("AT+CMGS=");

  Serial3.write(34);  //34 is the ASCII value for "

  for(int i=0;i<13;i++)

  {

    Serial3.print(mobileno[i]);

  }

  Serial3.write(34); // 34= ASCII for double quotes

  Serial3.println();

  Serial3.print("Text message"); // This is the new statement inserted. GSM doesn't send message when this is inserted.

  Serial3.println();

  delay(1000);

  Serial3.write(26);   // 26=ASCII for enter

  delay(800);


}

 

Do I have to print the text message some where else? Or is there any mistake in this code? Any pointers would be much appreciated.



  • Sign in to reply
  • Cancel
  • ntewinkel
    0 ntewinkel over 12 years ago

    Hi Liza,

     

    I think the problem might be that "enter" is often two characters (Carriage Return and Line Feed).

     

    Instead of writing the ASCII characters, try this:

     

    Serial3.write("\""); // backslash before the double quote means it's part of the string

    Serial3.write("\n"); // enter

     

    You could also try sending it to the serial debugger screen to see what is actually being sent.

     

    Hope that helps!

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube