I have a smartphone app that transmits RTCM data over Bluetooth to a SparkFun Thing Plus - ESP32 WROOM board. I want to pipe this data to a NEO-M8P-W board that I’m borrowing from someone else. The most logical way is to send the data via I2C using the existing QWIIC connection, especially since I’m not able to solder anything to the NEO-M8P-2.
Thing Plus:
https://www.sparkfun.com/products/retired/14689
NEO-M8P-2:
https://www.sparkfun.com/products/15005 … 1561122775
I’ve modified SparkFun’s provided “Example3_GetPosition” sketch to add Bluetooth. I collect the incoming bytes of RTCM data in an array and send them out all at once after the entire message is received.
Original here; my code pasted below:
https://github.com/sparkfun/SparkFun_Ub … sition.ino
When using serial and jumping the TX pin on the Thing Plus to the RX pin on the NEO-M8P-2 using a wire jumper, this communication works. However, when using the same exact array over I2C, I can’t seem to get it working. According to SparkFun’s hookup guide, it should be possible to pipe the data over I2C.
Hookup guide here:
https://learn.sparkfun.com/tutorials/gp … -guide/all
I’ve seen in a couple places that adding a 0xFF byte before the data transmission is required. I tried this, but it doesn’t seem to make any difference.
Is there something I’m missing, or is this module not capable of receiving RTCM data over I2C?
/*
Reading lat and long via UBX binary commands - no more NMEA parsing!
By: Nathan Seidle
SparkFun Electronics
Date: January 3rd, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to query a Ublox module for its lat/long/altitude. We also
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
dramatically.
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
to something google maps understands simply divide the numbers by 10,000,000. We
do this so that we don't have to use floating point numbers.
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Plug a Qwiic cable into the GPS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;
#include "BluetoothSerial.h"
BluetoothSerial ESP_BT;
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");
Wire.begin();
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
ESP_BT.begin("ESP32");
Serial1.begin(9600);
}
void loop()
{
//Query module only every second. Doing it more often will just cause I2C traffic.
//The module only responds when a new position is available
if (millis() - lastTime >= 1000)
{
if (ESP_BT.available()){ //check Bluetooth for incoming data
int msgIdx = 0;
byte msgIn[1023] = {};
while (ESP_BT.available())
{
msgIn[msgIdx] = (byte)ESP_BT.read(); //insert new data into array
msgIdx++; //keep track of position in array
}
Wire.beginTransmission(0x42);
//Wire.write(0xFF); //doesn't seem to make a difference
Wire.write(msgIn, msgIdx); //not working; unknown reason
Wire.endTransmission();
Serial1.write(msgIn, msgIdx); //works; pin 17 on WROOM to RX/MOSI on NEO-M8P-2
}
lastTime = millis(); //Update the timer
long latitude = myGPS.getLatitude();
//Serial.print(F("Lat: "));
//Serial.print(latitude);
long longitude = myGPS.getLongitude();
//Serial.print(F(" Long: "));
//Serial.print(longitude);
//Serial.print(F(" (degrees * 10^-7)"));
long altitude = myGPS.getAltitude();
//Serial.print(F(" Alt: "));
//Serial.print(altitude);
//Serial.print(F(" (mm)"));
byte SIV = myGPS.getSIV();
//Serial.print(F(" SIV: "));
//Serial.print(SIV);
//Serial.println();
double fLat = (double)latitude;
double fLon = (double)longitude;
Serial.print(fLat/10000000.0, 7);
Serial.print(", ");
Serial.print(fLon/10000000.0, 7);
Serial.println();
}
}