Help please, blue tooth connection problem

No shouldn’t need any updates. If you can see the NMEA sentences in putty then you should be able to see them in AgIO. Same COM port, same baud rate in AOG as Putty?

Yes you should be able to use the ESP32 as a bluetooth to UART adapter with the right code on it. Then you could do NTRIP from the tablet as well via bluetooth.

Yes same com etc

Hmm odd. I wonder if the Surveyor isn’t sending all the NMEA sentences AOG requires via bluetooth. When you connect with Putty, what messages do you see? AOG needs at least GGA and VTG sentences. I rather wonder if the Surveyor by default is only sending GGA. From the schematic it appears that if the little switch is set to “NMEA” that should cause the bluetooth to send whatever the UART1 of the F9P is sending, so with U-Center you would need to check that GGA and VTG are going out UART1. Also I read on the Sparkfun docs that the default message rate is 4 position messages per second. AOG really wants 5 or 10. Not sure what it does with 4.

Tomorrow I can take a few screenshots of u-center to show these settings. Or maybe someone can point us at a post on the forum where this has already been written up.

Not sure, If i connect the surveyor to laptop via usb i get gps data and it will track where I go in the barn lot. With that said I have no problem using usb, the only issue I tried to use blue tooth was the first time I tried usb it wants to charge surveyor and overloads tablet port. Tried it today with usb c cable and no warnings popped up.
So with that under control kentucky offers free correction service closest station is about 30 miles not ideal but its a start. I need to figure out how to connect to it. I have a account set up with ky cors service.
Thanks for the help and input.

Have you done much coding with the esp32? I’m having trouble getting ntrip working with it. I have data coming out but not sending the corrections back into it

#include <Arduino.h>
#include <BluetoothSerial.h>
#include <HardwareSerial.h>

BluetoothSerial SerialBT;
String id=“ESP to F9P”; //bt id
int uartBaud=9600; //uart baudrate
int btBaud=9600; //bluetooth baudrate
#define RXD2 16 //Rx gpio pin
#define TXD2 17 //Tx gpio pin

void setup() {
Serial.begin(btBaud);
Serial2.begin(uartBaud, SERIAL_8N1, RXD2, TXD2);
delay(10);

SerialBT.begin(id);

}

void loop() {
if (SerialBT.available()) {
Serial2.write(SerialBT.read());
}
if (Serial2.available()) {
SerialBT.write(Serial2.read());
}
}

That looks like it should work. I have a couple of ESP32 modules coming in the mail that I need to set up pretty much exactly like that so I’ll be able to test it in a day or two with your code.

For debugging purposes, you might try a main loop like this to make sure you’re getting ntrip data from the the bluetooth:

void loop() {
	char c;

	if (SerialBT.available()) {
		c = SerialBT.read();

		Serial.write(c);
		Serial2.write(c);
	}

	if (Serial2.available()) {
		SerialBT.write(Serial2.read());
	}
}

That will output the NTRIP data to your serial console as well as passing it to the F9P over Serial2.

I don’t think it would make much difference, but I like to put stuff like that in its own infinite while loop, rather than having loop() be called continuously. Might avoid some buffer overflows in some situations. Might want to at least try it:

void loop() {
	char c;

	while(1) {
		if (SerialBT.available()) {
			c = SerialBT.read();
	
			Serial.write(c);
			Serial2.write(c);
		}

		if (Serial2.available()) {
			SerialBT.write(Serial2.read());
		}
	}
}

Thanks I’ll give it a go

Getting somewhere. The serial monitor is showing heaps of rubbish like a wrong baud rate but changing the baud on agio and the serial monitor does nothing.

Well to be honest NTRIP data looks like that. It’s not plain text. The fact you’re seeing stuff on the screen means at least that the bluetooth serial is receiving data. And baud rate on the bluetooth does not matter (it’s always at its fastest speed). Double check your F9P settings to makes sure it’s expecting RTCM on the serial RX line you have connected to the ESP’s pin 17. And that it is expecting the baud rate to be 9600.

Typically I run my baud rate on the F9P at at least 57600 (because that’s what my radio network uses), but could even ben 115200.

Do you know if there is a difference with the uarts? I’m on uart2 on the f9p as it is already on 3.3v for the xbee. It is set up for rtcm3 input and nmea output. It must be a setting somewhere Ive missed. I’ll keep digging thanks

And the baud rate in u-center for uart2 was set correctly? It should be working. Strange. Got my esp32s now, so I’ll be setting up something similar over the next couple of days. i’ll keep you posted.

1 Like

Did you think to try swapping the TX and RX wires on the F9P going to your ESP32? I was working on this tonight and found that what the F9P board labels as “RX” is actually from the radio’s point of view, so it’s really a TX if that makes any sense. Once I swapped the wires it worked great. Also do you see the GPS>XBEE LED blinking? If not you’ll need to do some setup in U-Center.

Strangely I had nothing on GPS>XBEE at all, even though it was configured in U-center. Then I read online that people couldn’t get anything out of UART2 unless UART1 was configured to accept UBX+NMEA+RTCM3 on the UART1 input. Very weird. Definite bug. Maybe the UBlox firmware has been updated that fixes that. Working great now. Even when UART2 wasn’t transmitting I could still send RTCM from the bluetooth to the XBEE TX line and it achieved an RTK fix.

This is the code I prefer, but it may not make any difference:

#include <BluetoothSerial.h>

BluetoothSerial SerialBT;
#define RXD2 16 //Rx gpio pin
#define TXD2 17 //Tx gpio pin


void setup()
{
	Serial2.begin(57600,SERIAL_8N1, RXD2, TXD2);
	SerialBT.begin("esp32serial");
	Serial.begin(115200);
	delay(5000);
	Serial.println("Bluetooth to F9P bridge.");

}

void loop()
{
	char c;


	while (1) {
		while (SerialBT.available()) {
			c = SerialBT.read();
			Serial2.write(c);
		}

		while (Serial2.available()) {
			c = Serial2.read();
			//Serial.write(c); //sanity check
			SerialBT.write(c);
		}
	}
}

Here’s a sketch I tested tonight that I plan to use on my tractor with a Trimble receiver to let me use radio by default but if radio becomes problematic, lets me connect with my phone and use ntrip:

/* This sketch multiplexes two RTCM serial sources into one.
 * On ESP32,the sources are Radio (Serial2) and Bluetooth SPP.
 *
 * The ESP32 vesion defaults to passing Radio (Serial2) through 
 * to GPS (Serial1) unless data is received on Bluetooth Serial. 
 * In that case, only bluetooth data is passed to GPS (Serial1). 
 * After a timeout of no data received, it switches back to 
 * Radio (Serial2).
 *
 * Speed is usually set to 57600 because that's what I'm using
 * on the Trimble receivers and the radio network.
 *
 * Using pins 16 & 17 for the GPS uart (F9P uart2 or Trimble Port
 * C).  Pins 25 & 26 connect to the radio modem's uart.
 */

#include <BluetoothSerial.h>

BluetoothSerial SerialBT;
HardwareSerial GPS(1);
HardwareSerial Radio(2);

unsigned long last_bt_time;
bool use_bluetooth;

#define BT_TIMEOUT 3000 //3 seconds

#define RADIO_RX 25
#define RADIO_TX 26

#define GPS_RX 16
#define GPS_TX 17

#define TRAFFIC_LED 19

#define RADIO_SPEED 57600
#define GPS_SPEED 57600

void setup() {
	Serial.begin(115200);
	Radio.begin(57600,SERIAL_8N1,RADIO_RX,RADIO_TX); //radio
	GPS.begin(57600,SERIAL_8N1,GPS_RX,GPS_TX); //F9P or Trimble
	SerialBT.begin("TractorRTK"); //hard code name

	//Serial.println("Using Radio.");

	use_bluetooth = false;
	last_bt_time = millis();

	pinMode(18, OUTPUT);
}

void loop() {
	uint8_t c;
	while(1) {
		if (Radio.available()) {
			c = Radio.read();
			if (!use_bluetooth) {
				digitalWrite(TRAFFIC_LED,HIGH);
				GPS.write(c);
			}
		} else if (!use_bluetooth) {
			digitalWrite(TRAFFIC_LED,LOW);
		}

		if (GPS.available()) {
			//pass GGA data onto bluetooth for VRS NTRIP
			c = GPS.read();
			SerialBT.write(c);
		}

		if (SerialBT.available()) {
			//Bluetooth data available, switch to bluetooth
			c = SerialBT.read();
			//if (!use_bluetooth) {
			//	Serial.println ("Switching to Bluetooth.");
			//}

			use_bluetooth = true;
			last_bt_time = millis();
			GPS.write(c);
			
			digitalWrite(TRAFFIC_LED,HIGH);
		} else {
			if ((millis() - last_bt_time) > BT_TIMEOUT) {
				//haven't seen any bt data in a while
				//switch back to radio.

				//if (use_bluetooth) {
				//	Serial.println("Switching back to radio.");
				//}
				use_bluetooth = false;
			}
			if (use_bluetooth) {
				digitalWrite(TRAFFIC_LED,LOW);
			}
		}
	}
}

It’s working!!! When I changed the baud rate up to 115200 the xbee to gps light started flashing. Thanks for your help
Elliot

1 Like