This commit is contained in:
parent
3a439aeac1
commit
d0408d5f9b
1 changed files with 32 additions and 4 deletions
36
piread
36
piread
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_L3GD20_U.h>
|
||||
|
|
@ -8,6 +9,7 @@
|
|||
#include <Wire.h>
|
||||
#define mySerial Serial1
|
||||
#define GPSECHO true
|
||||
const int timeresetpin = 50;
|
||||
|
||||
|
||||
Adafruit_10DOF dof = Adafruit_10DOF();
|
||||
|
|
@ -21,6 +23,7 @@ char gpstext[ ] = "";
|
|||
String gpstalk;
|
||||
String inputString = ""; // a string to hold incoming data
|
||||
boolean stringComplete = false; // whether the string is complete
|
||||
boolean eventhappened = false; //has an event been detected?
|
||||
String lastgpsread;
|
||||
int energy1 = random(10000, 20000);
|
||||
int energy2 = random(10050, 19950);
|
||||
|
|
@ -36,7 +39,7 @@ double magx = 0;
|
|||
double magy = 0;
|
||||
double magz = 0;
|
||||
|
||||
|
||||
int timereset = 0;
|
||||
|
||||
int exacttime =0;
|
||||
int uptime = 0;
|
||||
|
|
@ -64,11 +67,15 @@ void setup()
|
|||
delay(1000);
|
||||
Serial.println("GPS online");
|
||||
inputString.reserve(200);
|
||||
pinMode(timeresetpin, INPUT);
|
||||
attachInterrupt(50, beep, RISING);
|
||||
|
||||
}
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
exacttime++;
|
||||
|
||||
if (stringComplete) {
|
||||
lastgpsread = inputString;
|
||||
lastgpsread.trim();
|
||||
|
|
@ -78,10 +85,28 @@ void loop() // run over and over again
|
|||
stringComplete = false;
|
||||
}
|
||||
|
||||
|
||||
if (eventhappened) {
|
||||
Serial.println("Beep");
|
||||
eventhappened = false;
|
||||
sensorreadout();
|
||||
printdatajson();
|
||||
delay(100);
|
||||
exacttime = 0;
|
||||
}
|
||||
|
||||
// timereset = digitalRead(timeresetpin);
|
||||
// exacttime++;
|
||||
// if (timereset != digitalRead(timeresetpin))
|
||||
// {
|
||||
// if (digitalRead(timeresetpin) == HIGH )
|
||||
// {
|
||||
// exacttime = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//delay(100);
|
||||
}
|
||||
|
||||
void printdatajson()
|
||||
|
|
@ -243,11 +268,14 @@ void sensorreadout()
|
|||
humidity = (htu.readHumidity());
|
||||
}
|
||||
|
||||
exacttime++;
|
||||
energy1= energy1 + random(-100,100);
|
||||
energy2= energy2 + random(-100,100);
|
||||
uptime++;
|
||||
|
||||
}
|
||||
|
||||
void beep()
|
||||
{
|
||||
eventhappened = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue