I have been trying to connect the dGPS board that I purchased a couple of yours ago from Dexter Indust to my redboard and communicating with it using I2C.
The connection was made using a brickbox assembly that provides a direct cable connection between the dGPS and breadboard (see attached pix). Analog pins A4 (SDA) and A5 (SCL) were used. Pin outs of the brickbox are:
1 - analog/9v
2 - gnd
3 - gnd
4 - vin
5 - scl
6 - sda
I have tried with and without the 4.7k pull-up resistors but results seem to be the same.
The I2C communications were set up with 7 bytes of data being sent between the NXT and dGPS. The data requested, sending size, receiving size were as per the Table 1 provided by Dexter Indust.
The arduino code I put together is shown below:
#include <Wire.h>
#define I2C_ADDR 0x03
boolean result = false;
void setup()
{
Serial.begin(9600); // start serial for output
Wire.begin();
delay(15);
Serial.println(“Ready!”);
result = dgpsInit();
if (result = true) {
Serial.println(“Got valid signal”);
}
else(Serial.println(“No valid signal”));
Serial.print("dGPS Time: ");
getgpsTime();
Serial.println();
}
void loop()
{
Serial.print("Lat: “);
getLat();
Serial.print(” ");
Serial.print("Long: ");
getLong();
Serial.println();
delay(5000);
}
boolean dgpsInit()
{
Wire.beginTransmission(I2C_ADDR);
delay(5);
Wire.write(0x02);
Wire.write(I2C_ADDR);
Wire.write(0x01);
Wire.endTransmission();
delay(15);
Wire.requestFrom(I2C_ADDR, 0x01);
while(!Wire.available()) {
}
byte b = Wire.read();
if (b == 1) {
return true;
}
else return false;
}
void getLat() {
byte b[4];
Wire.beginTransmission(I2C_ADDR);
delay(5);
Wire.write(0x02);
Wire.write(I2C_ADDR);
Wire.write(0x02);
Wire.endTransmission();
delay(15);
Wire.requestFrom(I2C_ADDR, 0x04);
while(!Wire.available()) {
}
for (byte n = 0; n < 4; n++) {
b[n] = Wire.read();
Serial.print(b[n]);
}
}
void getLong() {
byte b[4];
Wire.beginTransmission(I2C_ADDR);
delay(5);
Wire.write(0x02);
Wire.write(I2C_ADDR);
Wire.write(0x04);
Wire.endTransmission();
delay(15);
Wire.requestFrom(I2C_ADDR, 0x04);
while(!Wire.available()) {
}
for (byte n = 0; n < 4; n++) {
b[n] = Wire.read();
Serial.print(b[n]);
}
}
void getgpsTime() {
byte b[4];
Wire.beginTransmission(I2C_ADDR);
delay(5);
Wire.write(0x00);
Wire.write(I2C_ADDR);
Wire.write(0x04);
Wire.endTransmission();
delay(15);
Wire.requestFrom(I2C_ADDR, 0x04);
while(!Wire.available()) {
}
for (byte n = 0; n < 4; n++) {
b[n] = Wire.read();
Serial.print(b[n]);
}
}
The serial output indicates a valid gps signal but the latitude and longitude and time data do not appear correct.
I have assumed that the data sent from the arduino to the dGPS ATMega328 consists of three bytes (message size (sending), I2C address and data requested). Message size was taken as 3 bytes, scanning indicated I2C address of 0x03, and data requested was as per Table 1.
I was hoping someone may have tried to do this type of connection and may be able to help with either the hardwired connections or program.
Any help would be appreciated. Thanks.