Bluetooth serial bridge

wb32htc
Posts: 2
Joined: Sun Sep 29, 2019 1:12 pm

Bluetooth serial bridge

Postby wb32htc » Sun Sep 29, 2019 1:17 pm

Hi

I am trying to use my Heltec Wifi Kit 32 as a Bluetooth to serial bridge, and it works with the following code:

Code: Select all

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


BluetoothSerial SerialBT;
HardwareSerial MySerial(2);



void setup() {
  MySerial.begin(9600, SERIAL_8N1, 16, 17);
  SerialBT.begin("wConsole");
  delay(4000);
}

void loop() {
  if (MySerial.available() > 0) {
    SerialBT.write(MySerial.read());
    
  }
  if (SerialBT.available() > 0) {
    MySerial.write(SerialBT.read());

    
  }
  delay(25);
}
The issue that I face is that unless the far end has sent some data first, this doesn't work. I am connecting to a standard MAX3232 and then that connects into a standard serial port on a router/firewall/whatever. I can take the jumper wires off the ESP32 and straight on to a Raspberry pi and it works by using screen to go out over /dev/ttyAMA0.

Am I missing something in code to make this work?

Thanks

wb32htc
Posts: 2
Joined: Sun Sep 29, 2019 1:12 pm

Re: Bluetooth serial bridge

Postby wb32htc » Mon Oct 21, 2019 10:00 pm

Anyone know how to progress?

rodmcm
Posts: 65
Joined: Sat Sep 02, 2017 3:31 am

Re: Bluetooth serial bridge

Postby rodmcm » Thu Oct 24, 2019 3:41 am

I cant see why it doesnt work

Have you tested BT recieve by using something like this

if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}

sthatcher
Posts: 1
Joined: Thu Oct 24, 2019 4:18 am

Re: Bluetooth serial bridge

Postby sthatcher » Thu Oct 24, 2019 4:45 am

I am looking into the same sort of thing. I need to get a serial data stream from a HC-06 that is sending a GPS data stream. From looking at your test code, there is no call to SerialBT with a connect call. You have to tell the library what bluetooth device you want the ESP32 to connect to. I also believe that the library is missing code that sets up a working SPP connection because it is normally used between an arduino and a smartphone. This usage is the opposite direction when making a connection. I have looked at the ESP-IDF examples and their acceptor is what the ESP32 has to do, but that is not completing the SPP connection but it is closer. This whole thing is an active task for me, so when I come up with a solution (or someone else does...), I will pass it on.

Who is online

Users browsing this forum: No registered users and 72 guests