Well, I am making a device, which havehas to receive smsSMS and print the text using am LCD display. Now I have a code whichthat can receive smsSMS and store it into Stringa string variable using serial connection. Here is my code:
#include <LiquidCrystal.h> #include <SoftwareSerial.h> const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //LCD pins LiquidCrystal lcd(rs, en, d4, d5, d6, d7); String Arsp, Grsp; SoftwareSerial gsm(6,7); // RX, TX void setup() { Serial.begin(9600); Serial.println("Testing GSM SIM800L"); gsm.begin(9600); gsm.println("AT"); //checking delay(1000); gsm.println("AT+CMGF=1"); //Set to Text mode delay(1000); gsm.println("AT+CNMI=1, 2, 0, 0, 0"); //Set to notification for new message, New message indication lcd.begin(16, 2); } void loop() { if(gsm.available()) { //Check if GSM Send any data { Grsp = gsm.readString(); //Read data received from SIM800L GSM Module lcd.clear(); //Clear LCD Screen lcd.setCursor(0,0); //Set LCD cursor to First line, first row for(int i = 0; i<=100; i++) { //Print received string character by character { lcd.clear(); lcd.setCursor(0,0); lcd.print(Grsp); //Print string which received from GSM (sms, sender, sms index, receive time, etc) lcd.print(" "); lcd.print(i); //Print the string index delay(500); } } } When my Arduino UNOUno is connected to PC and the Arduino serial monitor is already open, it prints correctly this text received from GSM
In this case i senI sent a message whchwith text was "0". When i When I disconnect the USB and connect my arduinoArduino Uno to 9V power supply and send the same message text it printprints:
inIn this case 40 is the index of the message which receivereceived. I I want to get the whole string აasas in the first case when the USB was connected. I
I using arduniArduino GND and 5V to power the SIM800L. What I am doing wrong? Is this due to incorrect serial connection or incorrect code error?