I have setup an esp8266 to communicate to a gsm800l to control 3 leds. I can control the LED on/off state either via M SMS text message or via the blynk app. However, If I change the LED status via SMS, the state of the LED in the blynk app is not updated or sync. Below code is how I set it up.
What code needs to be added so that the LED on/off state in the blynk app reflects the hardware gpio states when it is changed via SMS.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial1
#define gsm_buff_size 256
char gsm_data_ready;
char gsm_buff[gsm_buff_size];
char auth_mobile_01[13];
char auth_mobile_02[13];
char auth_mobile_03[13];
char auth_mobile_04[13];
char auth_mobile_05[13];
char auth[] = "************************";
char ssid[] = "*************";
char pass[] = "******************";
int redLED = 12; // D5, GPIO12
int yellowLED = 4; // D2, GPIO4
int greenLED = 5; // D1, GPIO5
void setup(void) {
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED , LOW);
digitalWrite(yellowLED , LOW);
digitalWrite(redLED , LOW);
Serial.begin(115200);
delay(100);
Serial.swap();
delay(100);
Serial.setTimeout(100);
delay(100);
Serial1.begin(115200);
delay(100);
Serial1.println(F("\r\n"));
Serial1.println(F("Serial 0 port initilized at 115200 baud"));
Serial1.println(F("Serial 1 port initilized at 115200 baud"));
Serial1.print(F("\r\n"));
Serial1.println(F("Setting up the GSM modem"));
Serial1.println(F("[ESP]---| AT |-->[Sim800L]"));
Serial.println("AT");
delay(50);
Check_Serial_Data();
if (received_OK()){
Serial1.println(F("[ESP]<--| OK |---[Sim800L]"));
}
Serial1.println(F("[ESP]---| ATE0 |-->[Sim800L]"));
Serial.println("ATE0");
delay(50);
Check_Serial_Data();
if (received_OK()){
Serial1.println(F("[ESP]<--| OK |---[Sim800L]"));
}
Serial1.println(F("[ESP]---| AT+CMGF=1 |--->[Sim800L]"));
clear_gsm_buffer();
Serial.println("AT+CMGF=1");
delay(50);
Check_Serial_Data();
if (received_OK()){
Serial1.println(F("[ESP]<--| OK |---[Sim800L]"));
}
Serial1.println(F("[ESP]---| AT&W |--->[Sim800L]"));
clear_gsm_buffer();
Serial.println("AT&W");
delay(50);
Check_Serial_Data();
if (received_OK()){
Serial1.println(F("[ESP]<--| OK |---[Sim800L]"));
}
Blynk.begin(auth, ssid, pass);
Serial1.println(F("Going to the main loop"));
}