I just got my full stack of boards and I am a great fan of Tinycircuits already!
However, somehow I cannot figure out how to send GPS lat/long/time over Bluetooth to a nRF UART app on Android or another Arduino.
I used the
http://makezine.com/projects/make-37/gps-cat-tracker-2/ and on my Serial Monitor I get the NMEA format. I can also display it in Google Earth. This is all great.
Then I try the TinyShield_NRF8001_BLE_Example with Accelerometer on Codebender and that also works well.
Putting both together gives me significant headache. If I use the TinyGPS++ library, I got as far as being able to receive empty gps strings in the Android app. However, I dont think the GPS shield reads any data. I tried for 3 days, I am lost. Who can help to give me a sketch to collect GPS data and send it over Bluetooth to another Arduino, Raspberry or Android app.
#include <TinyGPS++.h>
#include <Wire.h>
#include "BMA250.h"
// accel
//BMA250 accel;
#define BLE_DEBUG false
#include "SPI.h"
#include "lib_aci.h"
#include "aci_setup.h"
#include "uart_over_ble.h"
#include "services.h"
#include <SoftwareSerial.h>
// The Arduino pins used by the GPS module
static const int GPS_ONOFFPin = A3;
static const int GPS_SYSONPin = A2;
static const int GPS_RXPin = A1;
static const int GPS_TXPin = A0;
static const int GPSBaud = 4800;
// The TinyGPS++ object
TinyGPSPlus gps;
// The GPS connection is attached with a software serial port
SoftwareSerial Gps_serial(GPS_RXPin, GPS_TXPin);
uint8_t ble_rx_buffer[21];
uint8_t ble_rx_buffer_len = 0;
//when using this project in the Arduino IDE, delete the following include and rename UART.h to UART.ino
#include "UART.h"
void setup(void)
{
// Init the GPS Module to wake mode
pinMode(GPS_SYSONPin, INPUT);
pinMode(GPS_ONOFFPin, OUTPUT);
digitalWrite( GPS_ONOFFPin, LOW );
delay(5);
if( digitalRead( GPS_SYSONPin ) == LOW )
{
// Need to wake the module
digitalWrite( GPS_ONOFFPin, HIGH );
delay(5);
digitalWrite( GPS_ONOFFPin, LOW );
}
Serial.begin(9600);
// Open the GPS serial port
Gps_serial.begin(GPSBaud);
Wire.begin();
//accel.begin(BMA250_range_2g, BMA250_update_time_64ms);//This sets up the BMA250 accelerometer
BLEsetup();
//uart.setDeviceName("DINO"); /* 7 characters max! */
}
int inByte = 0; // incoming serial byte
byte pbyGpsBuffer[100];
int byBufferIndex = 0;
void loop() {
while (Gps_serial.available() > 0)
gps.encode(Gps_serial.read());
aci_loop();//Process any ACI commands or events
// Serial.println(msg);
if(ble_rx_buffer_len){
//accel.read();//This function gets new data from the accelerometer
Serial.println(ble_rx_buffer_len);
Serial.println((char*)ble_rx_buffer);
String msg = String(gps.location.lat(), 3);
msg += ":";
msg += String(gps.location.lng(), 3);
msg += ":";
msg += String(gps.altitude.value());
uint8_t sendBuffer[20];
uint8_t length = 20;
msg.getBytes(sendBuffer, 20);
lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, sendBuffer, length);
ble_rx_buffer_len=0;
}
// Debug: if we haven't seen lots of data in 5 seconds, something's wrong.
if (millis() > 5000 && gps.charsProcessed() < 10) // uh oh
{
Serial.println("ERROR: not getting any GPS data!");
// dump the stream to Serial
Serial.println("GPS stream dump:");
while (true) // infinite loop
if (Gps_serial.available() > 0) // any data coming in?
Serial.write(Gps_serial.read());
}
}
Thank you for help