arduino 101 with gps logger shield

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
daijia
 
Posts: 1
Joined: Tue Apr 26, 2016 11:40 pm

arduino 101 with gps logger shield

Post by daijia »

Can I use Adafruit GPS logger shield with Arduino 10. If.not, what are some.changes.that I need to made?

User avatar
adafruit_support_mike
 
Posts: 66616
Joined: Thu Feb 11, 2010 2:51 pm

Re: arduino 101 with gps logger shield

Post by adafruit_support_mike »

We haven't tried it, but the GPS module uses a standard Serial interface and the SD card uses SPI.

The 101 only exposes its hardware SPI pins on the ICSP header, so you'll need to add a 2x3 header for that connection and wire the pins to the appropriate signals.

User avatar
a_kress
 
Posts: 5
Joined: Wed Apr 27, 2016 12:37 am

Re: arduino 101 with gps logger shield

Post by a_kress »

I'm wanting to do the exact same thing!

I've the gps shield and the 101. The SD card works like a champ. GPS just isn't playing nice.

Are there any links of how to test with the iscp headers?

User avatar
adafruit_support_mike
 
Posts: 66616
Joined: Thu Feb 11, 2010 2:51 pm

Re: arduino 101 with gps logger shield

Post by adafruit_support_mike »

What pins are you using for the Serial connection?

User avatar
a_kress
 
Posts: 5
Joined: Wed Apr 27, 2016 12:37 am

Re: arduino 101 with gps logger shield

Post by a_kress »

Im not sure I've just got the headers soldered where they'd normally get soldered (I'm pretty new). Here's a pic of what I've got.

In the code it's using ping 7 & 8 for the soft serial pins.

Image

User avatar
adafruit_support_mike
 
Posts: 66616
Joined: Thu Feb 11, 2010 2:51 pm

Re: arduino 101 with gps logger shield

Post by adafruit_support_mike »

The switch down at the end of the GPS shield is set for 'direct connect' on pins 0 and 1. Try flipping that to the 'software serial' side.

User avatar
a_kress
 
Posts: 5
Joined: Wed Apr 27, 2016 12:37 am

Re: arduino 101 with gps logger shield

Post by a_kress »

adafruit_support_mike wrote:The switch down at the end of the GPS shield is set for 'direct connect' on pins 0 and 1. Try flipping that to the 'software serial' side.
I double checked the switch. It's switched up on soft serial. Same result. Nothing logged.

I pulled out an UNO and tested the shield with that and the data log sketch. The gps works just as it should. I loaded the same sketch on the 101 without modifying it and it won't compile.

Code: Select all

exit status 1
no matching function for call to ‘Adafruit_GPS::Adafruit_GPS(SoftwareSerial*)’

User avatar
Franklin97355
 
Posts: 23370
Joined: Mon Apr 21, 2008 2:33 pm

Re: arduino 101 with gps logger shield

Post by Franklin97355 »

I don't thing the 101 has support for software serial.

User avatar
a_kress
 
Posts: 5
Joined: Wed Apr 27, 2016 12:37 am

Re: arduino 101 with gps logger shield

Post by a_kress »

So I've got this kind of working.

I had to move the switch over to hardware serial then wire the TX & RX of the gps shield to the 101's RX & TX. Then in the code it will read from the serial.read().

It's definitely not optimal yet but they're now talking. So far it's spitting out incomplete sentences. I'll have to post a picture of it later.

With the switch moved to hardware the SD card still seems to work perfectly.

User avatar
a_kress
 
Posts: 5
Joined: Wed Apr 27, 2016 12:37 am

Re: arduino 101 with gps logger shield

Post by a_kress »

Here is what I did:

https://learn.adafruit.com/adafruit-ult ... n-leonardo
I used these steps and loaded the leo_echo example sketch.

ImageImage
using that sketch I added some code for the logging and gyro info.

Here is my code so far:

Code: Select all

#include <BMI160.h>
#include <CurieIMU.h>
#include <MadgwickAHRS.h>
#include <CurieBLE.h>
#include <CurieTime.h>
#include <Adafruit_GPS.h>
#include <SD.h>
#include "defs.h"
  
#define mySerial Serial1
Adafruit_GPS GPS(&mySerial);
  
File logfile;
char filename[15];
  
BLEPeripheral blePeripheral; // create peripheral instance
BLEService ledService("FastApp-2016-04-12");
// create switch characteristic and allow remote device to read and write
BLECharCharacteristic ledCharacteristic("FastApp-2016-04-12", BLERead | BLEWrite);
// create button characteristic and allow remote device to get notifications
BLECharCharacteristic buttonCharacteristic("FastApp-2016-04-12", BLERead | BLENotify); // allows remote device to get notifications
  
  
// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
  
Madgwick filter; // initialise Madgwick object
int ax, ay, az;
int gx, gy, gz;
float yaw;
float pitch;
float roll;
int factor = 800; // variable by which to divide gyroscope values, used to control sensitivity
  
int count = 0; // need a counter because we only get seconds level time from CurieTime.h
String gps="";
  
void setup() {
  CurieIMU.begin();  
  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  while(!Serial);
  Serial.println(VERSION);
  // set the local name peripheral advertises
  blePeripheral.setLocalName("FastApp");
  // set the UUID for the service this peripheral advertises:
  blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
  
  // add service and characteristics
  blePeripheral.addAttribute(ledService);
  blePeripheral.addAttribute(ledCharacteristic);
  blePeripheral.addAttribute(buttonCharacteristic);
  
  ledCharacteristic.setValue(0);
  buttonCharacteristic.setValue(0);
  // use the code below to calibrate accel/gyro offset values
  Serial.println("Internal sensor offsets BEFORE calibration...");
  Serial.print(CurieIMU.getAccelerometerOffset(X_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Y_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Z_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getGyroOffset(X_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getGyroOffset(Y_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getGyroOffset(Z_AXIS)); Serial.print("\t");
  Serial.println("");
   
  Serial.println("Starting Gyroscope calibration...");
  CurieIMU.autoCalibrateGyroOffset();
  Serial.println("Starting Acceleration calibration...");
  CurieIMU.autoCalibrateAccelerometerOffset(X_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Y_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Z_AXIS, 1);
   
  Serial.println("Internal sensor offsets AFTER calibration...");
  Serial.print(CurieIMU.getAccelerometerOffset(X_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Y_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Z_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(X_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Y_AXIS)); Serial.print("\t");
  Serial.print(CurieIMU.getAccelerometerOffset(Z_AXIS)); Serial.print("\t");
  Serial.println("");
  // advertise the service
  blePeripheral.begin();
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  mySerial.begin(9600);
  
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
  GPS.sendCommand(PGCMD_NOANTENNA);
  // Ask for firmware version
  mySerial.println(PMTK_Q_RELEASE);
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {      // if you're using an UNO, you can use this line instead
    Serial.println("Card init. failed!");
  }
   
  strcpy(filename, "GPSLOG00.TXT");
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = '0' + i/10;
    filename[7] = '0' + i%10;
    // create if does not exist, do not open existing, write, sync after write
    if (!SD.exists(filename)) {
      break;
    }
  }
  logfile = SD.open(filename, FILE_WRITE);
}
  
void loop() {
  boolean endofline=false;
  char c = GPS.read();
   
  if (GPSECHO){
    if (c) Serial.print(c);
    gps+=c;
  } 
   
  if(c=='\n') endofline=true;
   
  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {  
    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another
  }
  
  // approximately every 2 seconds or so, print out the current stats
  if (endofline) { 
    CurieIMU.readMotionSensor(ax, ay, az, gx, gy, gz); 
   
    // use function from MagdwickAHRS.h to return quaternions
    filter.updateIMU(gx / factor, gy / factor, gz / factor, ax, ay, az);
   
    // functions to find yaw roll and pitch from quaternions
    yaw = filter.getYaw();
    roll = filter.getRoll();
    pitch = filter.getPitch();
    String sql = "$AGYRO,";
  
    String timestamp = "20";
    timestamp += GPS.year; timestamp += "-"; timestamp += GPS.month; timestamp += "-"; timestamp += GPS.day;
    timestamp += " "; timestamp += GPS.hour; timestamp += ":"; timestamp += GPS.minute; timestamp += ":"; timestamp += GPS.seconds;
     
    sql+= timestamp; sql+=",";
    sql+= gx; sql+= ", ";
    sql+= gy; sql+= ", ";
    sql+= gz; sql+= ", ";
    sql+= ax; sql+= ", ";
    sql+= ay; sql+= ", ";
    sql+= az;
    Serial.println(sql);
     
    logfile.println(gps);
    logfile.println(sql);
    gps="";
  }
   
  logfile.flush();
}

User avatar
MPer
 
Posts: 7
Joined: Mon May 22, 2017 11:49 am

Re: arduino 101 with gps logger shield

Post by MPer »

Attached is the patch for Arduino 101. Use SoftSerial.

PS:Had to append .txt as an extension as .diff was not allowed.
Attachments
Adafruit_GPS_101.diff.txt
(3.18 KiB) Downloaded 214 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”