0

I'm trying to connect an Arduino (with a 4.0 bluetooth module) and a Raspberry pi 4 (with bluetooth module included). I just want the Rasp to receive a string and never to send, so thats the arduino sketch:

#include <SoftwareSerial.h>
SoftwareSerial bluetooth(2, 3);

void setup() {
  bluetooth.begin(9600);
}

void loop() {
  delay(500);
  bluetooth.println("string");
}

Now, if I try connecting my smartphone with a bluetooth terminal it works fine but when i try doing the same on the Raspberry it doesn't receive any byte. Here's what i tried:

import serial
bluetoothSerial = serial.Serial("/dev/rfcomm0", baudrate=9600)
print(bluetoothSerial.readline())
bluetoothSerial.close()

Despite the two devices are paired and connected, after some seconds of receiving nothing it gives me an error saying that "The Host is down".

These are the screenshots of bluetoothctl screenshot1

enter image description here

Filippo
  • 274
  • 1
  • 4
  • 13
  • Thanks, and what's the port I have to connect? @ukBaz – Filippo Oct 21 '20 at 13:22
  • I checked those example but there's a problem, as I said in the post I need the raspberry to receive a string while he connects to the arduino. So arduino have to be the server and at the same time send the string message @ukBaz – Filippo Oct 21 '20 at 16:32
  • 1
    The device you are trying to connect to isn't using Bluetooth Classic and the Serial Port Profile (SPP). It is using BLE with a custom GATT service (`ffe0`) and characteristic (`ffe1`). I am sure there is something on this. Let me take a look. – ukBaz Oct 22 '20 at 15:38
  • 2
    You need to create a BLE GATT client (Central role in BLE speak) and I have some examples of doing that: https://stackoverflow.com/a/63751113/7721752 https://raspberrypi.stackexchange.com/a/114175/121848 Using a [generic BLE exploration tool](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-mobile) is often helpful to understand the data structure. If you get stuck, open a new question and I'll try to help – ukBaz Oct 23 '20 at 06:18

0 Answers0