#include <Wire.
h>
#include <MPU9250_asukiaaa.h>
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include "DHT.h"
#include <SD.h>
#include <SFE_BMP180.h>
#define seaLevelPressure_hPa 1013.25
SFE_BMP180 pressure;
//void bmpinit(void);
//float getalti(void);
//float getpr(void);
//float gettemp(void);
//void checkgps(void);
//void displayInfo();
MPU9250_asukiaaa mySensor;
TinyGPSPlus gps;
SoftwareSerial ss(8, 9);
DHT dht(2, DHT11);
SoftwareSerial xb(7,6);
//File dataFile;
float latt,lngt,galti;
unsigned int t,ct;
double baseline;
void setup()
{
[Link](9600);
[Link](9600);
[Link](115200);
if ()
[Link]('f');
[Link]('f');
[Link]();
[Link]();
[Link]();
bmpinit();
baseline=getpr();
[Link](baseline);
}
void loop()
{
unsigned int t,ct;
float aX,aY,aZ,gX,gY,gZ;
ct=millis();
checkgps();
float T=gettemp();
float P=getpr();
float a=getalti();
float battery = analogRead(A1)*(25.0/1024.0);
/// IMU///////////////////////////
if (![Link]()) {
gX = [Link]();
gY = [Link]();
gZ = [Link]();}
if (![Link]()) {
aX = [Link]();
aY = [Link]();
aZ = [Link]();}
////////////// SERIAL MONITOR//////////////////////
[Link](battery); [Link](F(","));
[Link](latt, 6); [Link](F(","));
[Link](lngt, 6); [Link](F(","));
// [Link]("24.860966"); [Link](F(","));
// [Link]("66.990535"); [Link](F(","));
[Link](T,1);[Link](F(","));
[Link](P,1);[Link](F(","));
[Link](a);[Link](F(","));
[Link]([Link]()); [Link](F(","));
[Link](aX); [Link](F(","));
[Link](aY); [Link](F(","));
[Link](aZ); [Link](F(","));
[Link](atan2(aX, aY) * 180 / 3.142); [Link](F(","));
[Link](gX); [Link](F(","));
[Link](gY); [Link](F(","));
[Link](gZ); [Link](F(","));
[Link](ct-t);
////////////////////SD CARD/////////////////////////////////
// dataFile = [Link]("[Link]", FILE_WRITE);
// if(dataFile)
// {
// [Link]("writing log: ");
// [Link](battery); [Link](F(","));
// [Link](latt,6); [Link](F(","));
// [Link](lngt,6); [Link](F(","));
//// [Link]("24.960966"); [Link](F(","));
//// [Link]("66.996375"); [Link](F(","));
// [Link](T,1);[Link](F(","));
// [Link](P,2);[Link](F(","));
// [Link](a);[Link](F(","));
// // [Link]([Link]()); [Link](F(","));
// [Link](aX); [Link](F(","));
// [Link](aY); [Link](F(","));
// [Link](aZ); [Link](F(","));
// //[Link](atan2(aX, aY) * 180 / 3.142); [Link](F(","));
// [Link](gX); [Link](F(","));;
// [Link](gY); [Link](F(","));
// [Link](gZ); [Link](F(","));
// [Link](ct-t);
// [Link]();
// }
/////////////////// XBEE //////////////////////////
[Link](battery); [Link](F(","));
if(latt>20)
{
[Link](latt,6); [Link](F(","));
[Link](lngt,6); [Link](F(","));
}
else
{
[Link]("24.860966"); [Link](F(","));
[Link]("66.990535"); [Link](F(","));
}
[Link](T,1); [Link](F(","));
[Link](P,1); [Link](',');
[Link](a); [Link](F(","));
[Link]([Link]()); [Link](F(","));
[Link](aX); [Link](F(","));
[Link](aY); [Link](F(","));
[Link](aZ); [Link](F(","));
[Link](atan2(aX, aY) * 180 / 3.142); [Link](F(","));
[Link](gX); [Link](F(","));
[Link](gY); [Link](F(","));
[Link](gZ); [Link](F(","));
[Link](ct-t);
t=ct;
delay(100);
}
//[Link]("24.860966"); [Link](F(","));
//[Link]("66.990535"); [Link](F(","));
///
FUNCTIONSSSSSWS////////////////////////////////////////////////////////////////////
///
void checkgps(void)
{
while ([Link]() > 0)
if ([Link]([Link]()))
displayInfo();
}
void displayInfo()
{
if ([Link]())
{
latt=[Link]();
lngt=[Link]();
galti=[Link]();
}
else
{
[Link](F("INVALID"));
}
void bmpinit(void)
{
if ([Link]())
[Link]("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
[Link]("BMP180 init fail\n\n");
while(1); // Pause forever.
}
}
float getalti(void)
{
char status;
double T,P,p0,a;
// [Link]();
status = [Link]();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = [Link](T);
if (status != 0)
{
// Print out the measurement:
//[Link]("T");
// [Link](T,2);
// [Link](" deg C, ");
// [Link]((9.0/5.0)*T+32.0,2);
// [Link](" deg F");
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res,
longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = [Link](3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature
measurement (T).
// (If temperature is stable, you can do one temperature measurement for a
number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = [Link](P,T);
if (status != 0)
{
// Print out the measurement:
// [Link]("P");
// [Link](P,2);
//[Link](" mb, ");
// [Link](P*0.0295333727,2);
//// [Link](" inHg");
a = [Link](P,baseline);
//a= a*3.28084,0;
// [Link]("H");
//[Link](a,0);
// [Link](" meters, ");
// [Link](a*3.28084,0);
// [Link](" feet");
}
else [Link]("error retrieving pressure measurement\n");
}
else [Link]("error starting pressure measurement\n");
}
else [Link]("error retrieving temperature measurement\n");
}
delay(10); // Pause for 5 seconds.
return a;
}
float getpr(void)
{
char status;
double T,P,p0,a;
// [Link]();
status = [Link]();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = [Link](T);
if (status != 0)
{
// Print out the measurement:
//[Link]("T");
// [Link](T,2);
// [Link](" deg C, ");
// [Link]((9.0/5.0)*T+32.0,2);
// [Link](" deg F");
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res,
longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = [Link](3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature
measurement (T).
// (If temperature is stable, you can do one temperature measurement for a
number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = [Link](P,T);
if (status != 0)
{
// Print out the measurement:
// [Link]("P");
// [Link](P,2);
//[Link](" mb, ");
// [Link](P*0.0295333727,2);
//// [Link](" inHg");
//a = [Link](P,1013.25);
// [Link]("H");
//[Link](a,0);
// [Link](" meters, ");
// [Link](a*3.28084,0);
// [Link](" feet");
}
else [Link]("error retrieving pressure measurement\n");
}
else [Link]("error starting pressure measurement\n");
}
else [Link]("error retrieving temperature measurement\n");
}
delay(10); // Pause for 5 seconds.
return P;
}
float gettemp(void)
{
char status;
double T,P,p0,a;
// [Link]();
status = [Link]();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = [Link](T);
if (status != 0)
{
// Print out the measurement:
//[Link]("T");
// [Link](T,2);
// [Link](" deg C, ");
// [Link]((9.0/5.0)*T+32.0,2);
// [Link](" deg F");
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res,
longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = [Link](3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature
measurement (T).
// (If temperature is stable, you can do one temperature measurement for a
number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = [Link](P,T);
if (status != 0)
{
// Print out the measurement:
// [Link]("P");
// [Link](P,2);
//[Link](" mb, ");
// [Link](P*0.0295333727,2);
//// [Link](" inHg");
// a = [Link](P,1013.25);
// [Link]("H");
//[Link](a,0);
// [Link](" meters, ");
// [Link](a*3.28084,0);
// [Link](" feet");
}
else [Link]("error retrieving pressure measurement\n");
}
else [Link]("error starting pressure measurement\n");
}
else [Link]("error retrieving temperature measurement\n");
}
delay(10); // Pause for 5 seconds.
return T;
}