Howdy.
I’m trying to use a neo6mv2 with the asset tracker.
Now, I know you’ll say the asset tracker already has a GPS chip in it, but my experience with it has been subpar, and I need good quality GPS for this project.
So, the setup:
VCC -> VIN
GND -> GND
RX -> TX
TX -> RX
The code:
// This #include statement was automatically added by the Particle IDE.
// This #include statement was automatically added by the Particle IDE.
#include <TinyGPS.h>
// This #include statement was automatically added by the Particle IDE.
// This #include statement was automatically added by the Spark IDE.
#include "TinyGPS.h"
// Variables
int temperature;
int humidity;
SYSTEM_THREAD(ENABLED);
int DHpin = 6;
byte dat [5];
byte read_data () {
byte data;
for (int i = 0; i < 8; i ++) {
if (digitalRead (DHpin) == LOW) {
while (digitalRead (DHpin) == LOW); // wait for 50us
delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'
if (digitalRead (DHpin) == HIGH)
data |= (1 << (7-i)); // high front and low in the post
while (digitalRead (DHpin) == HIGH); // data '1 ', wait for the next one receiver
}
}
return data;
}
void start_test () {
digitalWrite (DHpin, LOW); // bus down, send start signal
delay (30); // delay greater than 18ms, so DHT11 start signal can be detected
digitalWrite (DHpin, HIGH);
delayMicroseconds (40); // Wait for DHT11 response
pinMode (DHpin, INPUT);
while (digitalRead (DHpin) == HIGH);
delayMicroseconds (80); // DHT11 response, pulled the bus 80us
if (digitalRead (DHpin) == LOW);
delayMicroseconds (80); // DHT11 80us after the bus pulled to start sending data
for (int i = 0; i < 4; i ++) // receive temperature and humidity data, the parity bit is not considered
dat[i] = read_data ();
pinMode (DHpin, OUTPUT);
digitalWrite (DHpin, HIGH); // send data once after releasing the bus, wait for the host to open the next Start signal
}
TinyGPS gps;
char szInfo[64];
// Every 15 minutes
int sleep = 10 * 1000;
void setup(){
pinMode (DHpin, OUTPUT);
Serial1.begin(9600);
}
void loop(){
bool isValidGPS = false;
for (unsigned long start = millis(); millis() - start < 1000;){
// Check GPS data is available
while (Serial1.available()){
char c = Serial1.read();
// parse GPS data
if (gps.encode(c))
isValidGPS = true;
}
}
// If we have a valid GPS location then publish it
if (isValidGPS){
float lat, lon;
unsigned long age;
gps.f_get_position(&lat, &lon, &age);
sprintf(szInfo, "%.6f,%.6f", (lat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lat), (lon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : lon));
}
else{
// Not a vlid GPS location, jsut pass 0.0,0.0
// This is not correct because 0.0,0.0 is a valid GPS location, we have to pass a invalid GPS location
// and check it at the client side
sprintf(szInfo, "0.0,0.0");
}
start_test ();
Particle.publish("temp=", dat [0]);
Spark.publish("temperature", dat [0] + " °C");
//Spark.publish("gpsloc", szInfo);
// Sleep for some time
delay(sleep);
}
Nothing shows up on the console as a publish event.
The neo6mv2 starts blinking red after a while, but no data.
I had an older GPS chip I used previously where this worked, but my soldering skills put an end to that.
Any suggestions?