Bluetooth-Communication between Raspberry Pi and Arduino Mega

Hello,

currently I am dealing with the following problem. During a previous teamwork an Arduino-based wireless gaming adapter (WGA) was developed for the Rapsberry Pi. In addition to the WGA also a playable demonstrator on the Raspberry Pi and two joysticks were build.

To establish a bluetooth communication at the Arduino side the module EGBT-045MS (also known as HC-05) was used. Which could easy connect to my mobile phone in an individual test.

The Raspberry Pi Model B was used with a commercially available bluetooth USB flash drive.

My questions are how do I install the bluetooth USB flash drive and how do I connect it with the Arudino Mega?
What is important in the transmission and how do I define a communication protocol?
Does somebody know some similar projects where such a connection has been implemented?

Down below you find the already developed BT Transmission and the whole program. It’s not working and I can’t find the problem.

Thanks in advance!

Best regards
MangaBaer

BT_Transmission.h (744 Bytes)

Firmware_WGA.ino (6.22 KB)

I found some major mistakes in your code. You massively hurt the first rule in interrupt programming: keep the interrupt service routine as short (time-wise) as possible. And never do something that generates interrupts inside of ISRs.
Using interrupts to check dip switches is simply a waste of resources and may lead to other errors.
You didn’t post the complete code so I had to guess to much to give you additional hints.

Regarding the Pi part: Most BT USB dongles are automatically detected by the Linux kernel. If your’s doesn’t it’s better you get a supported one. The bluez suite of utilities will help you recognize and pair bluetooth devices.

The HC-05 module is capable of the serial profile of Bluetooth. I would guess that a game controller should support the HID profile at least, otherwise you have to program all games you want to control yourself.