Saturday, August 17, 2019

IOT Based Real time GPS Tracker Using Blynk App


CODE


#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YOUR BLYNK AUTH ID";
char ssid[] = "WI-FI NAME";
char pass[] = "WI-FI PASSWORD";
int GPSBaud = 9600;
float lat;
float lon;
TinyGPSPlus gps;
int RXPin = D2;
int TXPin = D3;
float startTime;
SoftwareSerial gpsSerial(RXPin, TXPin);
WidgetMap myMap(V1);
WidgetLCD lcd(V4);
BlynkTimer timer;
void yn()
{
 int index = 0;
float lat = (gps.location.lat());
float lon = (gps.location.lng());
myMap.location(index, lat, lon, "value"); 
lcd.print(1, 0, lat); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
lcd.print(1, 1, lon); 
}
void setup()
{
gpsSerial.begin(GPSBaud);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);

}

void loop()
{

if (millis() > startTime + 60000) {    
       startTime = millis();
}
while (gpsSerial.available() > 0)
 if (gps.encode(gpsSerial.read()))
 if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println("No GPS detected");
  while(true);
  }   
if (gps.location.isValid())
{
Serial.print(" lat: ");
Serial.print(gps.location.lat(),7); 
Serial.println();
// use: (position X: 0-15, position Y: 0-1, "Message you want to print")
Serial.print(" lng: ");
Serial.println(gps.location.lng(),7);
yn();
  }
  else
  {
Serial.print(F("INVALID"));
Serial.println();
}
Blynk.run();
timer.run();
}

IOT Based Accelerometer Sensor controlled Robot using Blynk App



CODE

#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "Your Blynk Auth ID ";
char ssid[] = "Your WI-FI Name";
char pass[] = "Your WI-FI Password";
const int ml1 = D1;
const int ml2 = D2;
const int mr1 = D3;
const int mr2 = D4;
void setup()
{
  pinMode(ml1, OUTPUT);
  pinMode(ml2,OUTPUT);
  pinMode(mr1, OUTPUT);
  pinMode(mr2,OUTPUT);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V1)
{
int x = param[0].asFloat(); //acceleration force applied to axis x
int y = param[1].asFloat(); //acceleration force applied to axis y
int z = param[2].asFloat();//acceleration force applied to axis y
/*x = map(x, -10, 10, 255, -255);
y = map(y, -10, 10, 255, -255);
z = map(z, -10, 10, 255, -255);*/
Serial.print("x axis:");
Serial.println(x);
Serial.print("y axis:");
Serial.println(y);
Serial.print("z axis:");
Serial.println(z);
if(y==0&&x==0)
{
digitalWrite(ml1, HIGH);//stop
digitalWrite(ml2, HIGH);
digitalWrite(mr1, HIGH);
digitalWrite(mr2, HIGH);
}
else if(y<0)
{
 digitalWrite(ml1, HIGH);//forward
digitalWrite(ml2, LOW);
digitalWrite(mr1, HIGH);
digitalWrite(mr2, LOW);
}
else if(z<6)
{
 digitalWrite(ml1, LOW);//reverse
digitalWrite(ml2, HIGH);
digitalWrite(mr1, LOW);
digitalWrite(mr2, HIGH);
}
else if(x>1)
{
 digitalWrite(ml1,HIGH);
digitalWrite(ml2, LOW);//right
digitalWrite(mr1, LOW);
digitalWrite(mr2, HIGH); 
}
else if(x<0)
{
digitalWrite(ml1,LOW);
digitalWrite(ml2, HIGH);
digitalWrite(mr1, HIGH);//left
digitalWrite(mr2, LOW);
}
else
{

}
}

CIRCUITS WITH PROJECTS SOURCE CODES

Flex Sensor And Accelerometer-based Gesture Controlled Robot With Robot...