// If you're using the Adafruit GPS shield, change // SoftwareSerial mySerial(3, 2); -> SoftwareSerial mySerial(8, 7); // and make sure the switch is set to SoftSerial // If using software serial, keep this line enabled // (you can change the pin numbers to match your wiring): SoftwareSerial mySerial = SoftwareSerial(3, 2); // If using hardware serial (e.g. Arduino Mega), comment out the // above SoftwareSerial line, and enable this line instead // (you can change the Serial number to match your wiring): //HardwareSerial mySerial = Serial1; Adafruit_GPS GPS = Adafruit_GPS(&mySerial); bool usingInterrupt; GpsSensor::GpsSensor() { } void GpsSensor::Init() { // Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console // Set to 'true' if you want to debug and listen to the raw GPS sentences. #define GPSECHO false // this keeps track of whether we're using the interrupt // off by default!
#include "AssetTracker.h" #include "math.h" //----------------- Tracker ----------------// //#define mySerial Serial1 //Adafruit_GPS gps(&mySerial); Adafruit_GPS gps = Adafruit_GPS(); Adafruit_LIS3DH accel = Adafruit_LIS3DH(A2, A5, A4, A3); AssetTracker::AssetTracker(){ } void AssetTracker::begin(){ accel.begin(LIS3DH_DEFAULT_ADDRESS); // Default to 5kHz low-power sampling accel.setDataRate(LIS3DH_DATARATE_LOWPOWER_5KHZ); // Default to 4 gravities range accel.setRange(LIS3DH_RANGE_4_G); // Turn on the GPS module // gpsOn(); } float AssetTracker::readLat(){ return gps.latitude; }