Hello everyone, I am new to this community forum. I am making a project
with Arduino Uno , Gsm Module SIM800 , MQ2 Gas Sensor With 2 leds With BLYNK USB serial connection. I want to run AT commands (USES SERIAL MONITOR) for GSM to call a phone Number when MQ2 detects Any gas in environment. But I want to know I am using blynk code in it. So i will be able to run AT commands For gsm Or not with the blynk code ??? And please tell me if there are any errors, also i am send a sensors data from analog pin A5 to Blynk app so please check my code and tell me , i have tested the project partially and i am able to connect to blynk server.
#include <BlynkSimpleStream.h>
#define BLYNK_PRINT SwSerial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(3, 4);
char auth[] = "9af4b603a79f4b1bae0aedd050490f62";
int redled = 8;
int greenled = 9;
int buzzer = 10;
int streetled = 11;
int streetred = 12;
int smokeA0 = A5;
int sensorThres = 400; //Change
BlynkTimer timer;
void TweetEmailAndNotification()
{
int analogSensor = analogRead(smokeA0);
if (analogSensor > sensorThres)
{
Blynk.tweet("DANGER! GAS LEAKAGE DETECTED, location link- maps.app.goo.gl/mzHCg");
Blynk.email("GAS LEAKAGE DETECTED!!", "GAS LEAKAGE HAS BEEN DETECTED!! Location -maps.app.goo.gl/mzHCg");
Blynk.notify("GAS LEAKAGE!!{FLAME & GAS DETECTION SYSTEM} HAS DETECTED GAS LEAKAGE ALERT!");
}
}
void sensorDataSend()
{
int sensorValue = analogRead(A5); // reading sensor from analog pin
Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
void setup() {
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(streetled, OUTPUT);
pinMode(streetred, OUTPUT);
pinMode(smokeA0, INPUT);
timer.setInterval(1000L, sensorDataSend);
Serial.begin(9600);
SwSerial.begin(9600);
Blynk.tweet("MICROCONTROLLER STARTED :)");
delay(100);
}
void loop()
{
int analogSensor = analogRead(smokeA0);
if (analogSensor > sensorThres)
{
digitalWrite(redled, HIGH);
digitalWrite(greenled, LOW);
digitalWrite(streetled, HIGH);
digitalWrite(streetred, HIGH);
Serial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to the module
delay(100);
tone(buzzer, 1000,500);
Serial.println("ATDxxxxxxxx;");
}
else
{
digitalWrite(redled, LOW);
digitalWrite(greenled, HIGH);
noTone(buzzer);
digitalWrite(streetled, HIGH);
digitalWrite(streetred, LOW);
}
{
Blynk.run();
}
{
timer.run();
}
}