3
1

#include <dht.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
dht DHT;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
// Defining pin for humidity sensor
#define DHT11_PIN 7
// Defining pin for ADXL Analog pins
const int xPin = 3;
const int yPin = 4;
const int zPin = 5;
//ADXL Data
double x,y,z;
// Defining Static values ADXL. TO CHANGE AS NEEDED
int xStatic = 504;
int yStatic = 493;
int zStatic = 617;
void setup()
{      
  //int error;
  //uint8_t c;
  Serial.begin(19200);
  ss.begin(GPSBaud);
}
void loop()
{
  //int error;
  //double dT;
  //char buffer[100];
  //read the analog values from the accelerometer
  int xRead = analogRead(xPin);
  int yRead = analogRead(yPin);
  int zRead = analogRead(zPin);
  x = xStatic - xRead;
  y = yStatic - yRead;
  z = zStatic - zRead;
  //Serial.print("{"x":");
  Serial.print(x);
  Serial.print("#");
  //Serial.print(","y":");
  Serial.print(y);
  Serial.print("#");
 //Serial.print(","z":");
 Serial.print(z);
 //DHT
 if (int chk = DHT.read11(DHT11_PIN)) {
   Serial.print("#");
   //Serial.print(","temperature":");
   Serial.print(DHT.temperature);
   Serial.print("#");
   //Serial.print(","humidity":");
   Serial.print(DHT.humidity);
 }
 while (ss.available() > 0)
    if (gps.encode(ss.read()))
       if(gps.location.isValid())
       {
        //Serial.print(","latitude":");
          Serial.print("#");
          Serial.print(gps.location.lat(), 6);
       // Longitude in degrees (double)
        //Serial.print(","longitude":");
          Serial.print("#");
          Serial.print(gps.location.lng(), 6);
       //DATE
          String date;
          // Day (1-31) (u8)
          date= gps.date.day();
          // Month (1-12) (u8)
          date+= "-";
          date+= gps.date.month();
          // Year (2000+) (u16)
          date+= "-";
          date+= gps.date.year();
          //Serial.print(","date":");
          Serial.print("#");
          Serial.print("""+date+""");
          //TIME
          String time;
          // Hour (0-23) (u8)
          time= gps.time.hour();
          time+= ":";
          // Minute (0-59) (u8)
          time+= gps.time.minute();
          time+= ":";
          // Second (0-59) (u8)
          time+= gps.time.second();
          time+= ":";
          // 100ths of a second (0-99) (u8)
          time+= gps.time.centisecond();
          //Serial.print(","time":");
          Serial.print("#");
          Serial.print("""+time+""");
          //GPS SPEED AND ALTITUDE
          // Speed in kilometers per hour (double)
          Serial.print("#");
          //Serial.print(","speed":");
          Serial.print(gps.speed.kmph());
          //Serial.println("}");
          //Serial.println("$");
          delay(2000);
   }
   Serial.print("$");
   delay(3000);
   if (millis() > 5000 && gps.charsProcessed() < 10)
   {
     Serial.println(F("No GPS detected: check wiring."));
     while(true);
   }

 }

|
  • 1