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