Last active
March 26, 2021 20:07
-
-
Save gptshubham595/f51cfb9b863fc5103b07ef26f7bc119f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLYNK_PRINT Serial | |
#include <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
#include <SoftwareSerial.h> | |
#include <SimpleTimer.h> | |
#include <Servo.h> | |
#include <TinyGPS++.h> | |
Servo servo1,servo2,servo3,servo4,servo5,servo6; | |
static const uint32_t GPSBaud = 9600; | |
TinyGPSPlus gps; | |
WidgetTerminal terminal(V3); | |
const int RXpin=4,TXpin=5; | |
SoftwareSerial ssgps(RXpin,TXpin); //D1,D2 | |
//char auth[] = "AchgYJbDu5IG_TpbkIbM3C3jcIOY6vau"; | |
char auth[] = "Cj--EuczUexATBFYGngLlTFBh2rdWNOy"; //BLYNK APP WILL GIVE THIS | |
//char auth[] = "7BwXBh4TJs9w0wHyU9My4SE9ARU0mhiz"; //Your Project authentication key | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "shubhamisback"; | |
char pass[] = "hello123"; | |
//char server[]= "192.168.43.22"; | |
SimpleTimer timer; | |
WidgetMap myMap(V0); | |
String myString; // complete message from arduino, which consistors of snesors data | |
char rdata; // received charactors | |
int firstVal, secondVal,thirdVal; // sensors | |
int led1,led2,led3,led4; | |
String latv="NULL",lngv="NULL"; | |
void myTimerEvent() | |
{ | |
// You can send any value at any time. | |
// Please don't send more that 10 values per second. | |
Blynk.virtualWrite(V1, millis() / 1000); | |
} | |
int selected=0; | |
String book_status="unbooked"; | |
BLYNK_WRITE(V22) | |
{ | |
int Press=param.asInt(); | |
if(Press==1 && selected!=0){ | |
opengate(selected); | |
}else{ | |
closegate(selected); | |
} | |
} | |
BLYNK_WRITE(V21) | |
{ int Press=param.asInt(); | |
if(Press==1 && selected!=0){ | |
//Book | |
book_status="booked"; | |
}else{ | |
//UNBOOK | |
book_status="unbooked"; | |
} | |
} | |
BLYNK_WRITE(V20) | |
{ | |
selected=param.asInt(); | |
switch (param.asInt()) | |
{ | |
case 1: { // Item 1 | |
Serial.println("Item 1 selected"); | |
break; | |
} | |
case 2: { // Item 2 | |
Serial.println("Item 2 selected"); | |
break; | |
} | |
case 3: { // Item 3 | |
Serial.println("Item 2 selected"); | |
break; | |
} | |
case 4: { // Item 4 | |
Serial.println("Item 2 selected"); | |
break; | |
} | |
} | |
} | |
String space="0"; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Serial.println(F("Working")); | |
ssgps.begin(GPSBaud); | |
Blynk.begin(auth, ssid, pass,IPAddress(192,168,43,22), 8080); | |
timer.setInterval(1000L,sensorvalue1); | |
timer.setInterval(1000L,sensorvalue2); | |
timer.setInterval(1000L,sensorvalue3); | |
timer.setInterval(1000L,sensorvalue4); | |
timer.setInterval(1000L,setlat); | |
timer.setInterval(1000L,setspace); | |
timer.setInterval(1000L,showterminal); | |
servo1.attach(15); //D8 | |
servo2.attach(13); //D7 | |
servo3.attach(12); //D6 | |
servo4.attach(14); //D5 | |
servo5.attach(0); //D3 | |
servo6.attach(2); //D4 | |
} | |
String latval="NULL",lngval="NULL"; | |
String entry="closed",entry2="closed"; | |
BLYNK_WRITE(V23){ | |
if(ssgps.available()>0){ | |
if(gps.encode(ssgps.read())){ | |
if(gps.location.isValid()){ | |
latval=String(gps.location.lat()); lngval=String(gps.location.lng()); | |
Serial.println("Location:"+latval); | |
}else{ | |
Serial.println("Location: INVALID"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment