Help on displaying SMS data on LCD display

Hi everybody, I am a student working on an arduino project. I am completely new to arduino and I am currently building a project that essentially displays text using the SIM900 module. I am currently confused as to how I can make it work. I only have basic knowledge of coding and can only code by piecing together one tutorial video after another (which worked up until this point).

Right now, I am stuck on this code attached below. Knowing that SIM900.read() will include pretty much every data it can, that includes the number the message it was recieved from, the date and time, and some other data I cannot understand, I discovered the substring().

For my purposes, this solution will not work. I need to send quite a complex message, preferably Data1:Data2:Data3 as the format so I can set it up on the LCD display on different rows and such.

I am in need of a better way to code this, and your suggestions will be greatly appreciated.

Thanks,
Jay

#include <SoftwareSerial.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// Configure software serial port
SoftwareSerial SIM900(7, 8);
//Variable to save incoming SMS characters
String incoming_char;

void setup() {
  // Define the dimensions of the LCD display
  lcd.begin(20,4); 
  // Arduino communicates with SIM900 GSM shield at a baud rate of 19200
  // Make sure that corresponds to the baud rate of your module
  SIM900.begin(19200);
  // For serial monitor
  Serial.begin(19200); 
  // AT command to set SIM900 to SMS mode
  SIM900.print("AT+CMGF=1\r"); 
  delay(100);
  // Set module to send SMS data to serial out upon receipt 
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  delay(100);
}

void loop() {
  // Display any text that the GSM shield sends out on the serial monitor
  if(SIM900.available() >0) {
    incoming_char=SIM900.readString(); 
    //Print the incoming character to the terminal
    Serial.print(incoming_char);
    //Write sms data on lcd display
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(incoming_char.substring(49));
  }
}

I am using a 4x20 LCD display with I2C. I may add that with this code, I am getting weird characters on the LCD. They are stripe-like characters. Again, any help will be greatly appreciated

Check out the following site and youtube video.

The code uses some function to extract the information you need. e.g.

Receiving

sms.GetSMS(sms_position, phone_number, sms_text, 100);
Serial.println(phone_number);
Serial.println(sms_text);

Sending

if (sms.SendSMS("+300000000000", "Arduino SMS"))

Seems quite comfortable to use. Keep on trying it sounds like you are on the right way already.

If you just need the message to print and wrap long lines then you could use the hd44780 library.
It has support for line wrapping of long lines.
While it won't break/wrap on word boundaries, it will wrap the text which will ensure that all the characters get printed to the display.

The hd44780 library is available in the IDE library manager.
You will want to use the hd44780_I2Cexp i/o class for the i2c backpack device.
The hd44780_I2Cexp i/o class is easier to use as it will auto discover the i2c address and the auto detect the pin mappings.
It is also quite a bit faster than library you are using.
See the included extensive documentation for lots of additional information. It is available in the Documentation sketch.
First thing to do is run the included I2CexpDiag sketch to test that everything is working.
Then you can look at the various hd44780_I2Cexp i/o class examples, including LineWrap to see how to enable long line wrapping.

--- bill

Klaus_K:
Check out the following site and youtube video.

Arduino GSM SHIELD (SIM900) SMS tutorial - educ8s.tv - Watch Learn Build

The code uses some function to extract the information you need. e.g.

Receiving

sms.GetSMS(sms_position, phone_number, sms_text, 100);
Serial.println(phone_number);
Serial.println(sms_text);

Sending

if (sms.SendSMS("+300000000000", "Arduino SMS"))

Seems quite comfortable to use. Keep on trying it sounds like you are on the right way already.

Thank you for your response, this is exactly what I needed.

-jay