Hi everyone
I want make GSM controlled Relay.
I using serial software on arduino nano and simcom sim800L GSm module.
Arduino nano and GSm module not communicate first powered. When reset Arduino nano then can communicate.
How can I fix this problem?
My code are:
#include <SoftwareSerial.h>
SoftwareSerial dtmfPort(2,3); //my software serial name dtmfPort and connected GSM Rx- Arduino3, GSM tx-Arduino2
char dtmfdata;
bool testbit = LOW;
void setup() {
pinMode(12, OUTPUT); // Relay output pin
digitalWrite(12, HIGH); //my relay low level trigged
Serial.begin(9600); // Start serial for PC
dtmfPort.begin(9600); // Start serial For GSm module
delay (30000); // wait for GSm Module startup and registering GSM network
dtmfPort.print("AT"); //Test GSm Module
delay(100); //delay for response
char dtmfdata = dtmfPort.read(); //GSM module response transfering dtmfdata register
Serial.write(dtmfdata); //dtmf data sending to PC
}
void loop() {
if (dtmfPort.available()){
dtmfdata = dtmfPort.read();
Serial.write(dtmfdata);
Serial.println();
}
if(dtmfdata=='1'){
digitalWrite(12, LOW);
testbit = HIGH;
}
if(dtmfdata=='2'){
digitalWrite(12, HIGH);
testbit = LOW;
}
if (testbit==LOW & dtmfdata=='2'){
delay(5000);
}
}