[SOLVED]How to receive spp bluetooth data with esp-wrover-kit

spp = serial port profile

I have one question concerning how to receive nmea0183 serial mode data sent by gps module + hc-05 slave.
As receiver I am going to use esp-wrover-kit's bluetooth classic.

It is easy to send serial mode data with hc-05 that is fed by gps module. No trics at all, just set hc-05 as slave. But how to receive nmea0183 data with esp-wrover-kit data sent by hc-05?

Does someone know how to do that with Arduino libraries with with Arduino IDE, or with PlatformIO , or does someone have a link to some example that impelements the thing.

Note that esp-wrover-kit does not use another hc-05 module as receiver, esp-wrover-kit just uses its own bluetooth classic library and bluetooth hardware.

At the moment I receive gps data sent by hc-05 with my desktop Ubuntu that has bluetooth dongle and uses BlueZ bluetooth library.

Take a look at the EP32 example files for Bluetooth Serial and use "SerialToSerialBTM".

Use the MAC address of the HC05 and you should connect. The example is set up for the pin "1234".

Thanks for cattledog's help. I managed to connect to hc-05 and read data with esp-wrover-kit. I'll put the code and platformio.ini in comments just for remind me and for others who are interested this kind of bluetooth communication.

// This example code is in the Public Domain (or CC0 licensed, at your option.)
// By Victor Tchistiak - 2019
//
// This example demonstrates master mode Bluetooth connection to a slave BT device using PIN (password)
// defined either by String "slaveName" by default "OBDII" or by MAC address
//
// This example creates a bridge between Serial and Classical Bluetooth (SPP)
// This is an extension of the SerialToSerialBT example by Evandro Copercini - 2018
//
// DO NOT try to connect to phone or laptop - they are master
// devices, same as the ESP using this code - it will NOT work!
//
// You can try to flash a second ESP32 with the example SerialToSerialBT - it should
// automatically pair with ESP32 running this code

// No symbol "a10" in current context. (from data-evaluate-expression a10)

// my question : https://forum.arduino.cc/t/how-to-receive-spp-bluetooth-data-with-esp-wrover-kit/1138989
// example : https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino

/*
platformio.ini :
[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
board_build.mcu = esp32
board_build.f_cpu = 240000000L
debug_tool = ftdi
build_type = debug
debug_init_break = tbreak setup
monitor_port = /dev/ttyUSB1
#upload_speed = 115200

#lib_deps =
#	espressif/WROVER KIT LCD@^1.0.3
#	adafruit/Adafruit GFX Library@^1.11.5
#	moononournation/GFX Library for Arduino@^1.3.5


upload_speed  = 1500000
build_flags =  -DWROVERKIT=1
			   -DDEBUG=1
			   -DUSESCREEN=1
			   -DUSE_PSRAM=0
			   -DBOARD_HAS_PSRAM=0
			   -std=gnu++17
			   #-Ofast
			   #-mfix-esp32-psram-cache-issue

upload_protocol = ftdi
*/

#include "BluetoothSerial.h"

// #define USE_NAME // Comment this to use MAC address instead of a slaveName
const char *pin = "1234"; // Change this to reflect the pin expected by the real slave BT device

#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif

BluetoothSerial SerialBT;

#ifdef USE_NAME
String slaveName = "SLAVE01"; // Change this to reflect the real name of your slave BT device
#else
String MACadd = "98:D3:36:81:03:F6";					   // This only for printing
uint8_t address[6] = {0x98, 0xD3, 0x36, 0x81, 0x03, 0xF6}; // Change this to reflect real MAC address of your slave BT device
#endif

String myName = "ESP32-BT-Master";

void setup()
{
	bool connected;
	Serial.begin(115200);

	SerialBT.begin(myName, true);
	Serial.printf("The device \"%s\" started in master mode, make sure slave BT device is on!\n", myName.c_str());

#ifndef USE_NAME
	SerialBT.setPin(pin);
	Serial.println("Using PIN");
#endif

// connect(address) is fast (up to 10 secs max), connect(slaveName) is slow (up to 30 secs max) as it needs
// to resolve slaveName to address first, but it allows to connect to different devices with the same name.
// Set CoreDebugLevel to Info to view devices Bluetooth address and device names

#ifdef USE_NAME
	connected = SerialBT.connect(slaveName);
	Serial.printf("Connecting to slave BT device named \"%s\"\n", slaveName.c_str());
#else
	connected = SerialBT.connect(address);
	Serial.print("Connecting to slave BT device with MAC ");
	Serial.println(MACadd);
#endif

	if (connected)
	{
		Serial.println("Connected Successfully!");
	}
	else
	{
		while (!SerialBT.connected(10000))
		{
			Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app.");
		}
	}

	Serial.println("before 500ms delay!");
	delay(500);
	Serial.println("after after 500ms delay!");	

}


void loop()
{
	while (SerialBT.available())
	{
		String rxbuff = SerialBT.readStringUntil('\n');
		if (rxbuff.length() > 0)
		{
			for (int i = 0; i < rxbuff.length(); i++)
				Serial.print(rxbuff[i]);
			Serial.print("\n");
							
		}

	}	
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.