I am making small monitoring system using Arduino Uno and SIM800L , my device get the sms using arduino and blinking leds and print some text on the display(LCD 16x2);
here is code:
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
String Arsp, Grsp, Indata;
SoftwareSerial gsm(6, 7); // RX, TX
void setup() {
// put your setup code here, to run once:
pinMode(A5, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A3, OUTPUT);
Serial.begin(9600);
Serial.println("Testing GSM SIM800L");
gsm.begin(4800);
gsm.println("AT");
delay(1000);
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CNMI=1,2,0,0,0");
lcd.begin(16, 2);
lcd.setCursor(0, 1);
lcd.clear();
}
void _blinkingLed(int led)
{
delay(250);
digitalWrite(led, HIGH);
delay(250);
digitalWrite(led, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
char c;
if(gsm.available())
{
Grsp = gsm.readString();
Serial.println(Grsp);
lcd.clear();
lcd.setCursor(0,0);
int size_of_array = Grsp.length();
lcd.print(Grsp[51]);
bool condition = true;
if(Grsp[51] == '1')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("PPM1 Error");
while(condition)
{
Grsp = gsm.readString();
Serial.println(Grsp);
delay(250);
digitalWrite(A5, HIGH);
delay(250);
digitalWrite(A5, LOW);
if(Grsp[51] == '0')
condition = false;
}
}
}
if(Serial.available())
{
Arsp = Serial.readString();
gsm.println(Arsp);
}
}
Well what i want is to use serial connection but not USB.
Any ideas?