Hi, I'm not a guru, but I have learned quite a bit about this subject in the last couple of weeks. My particular project involves sending analog audio from a 2 meter ham radio via bluetooth to a bluetooth headset. I want to be able to enable push to talk from the bluetooth headset. I bought two rn52's a couple of years ago and they have sat on my desk until this past thanksgiving. I also intend to use an Arduino Nano for the time being on the source/master unit.(i'll explain in a moment). I am learning about all the bluetooth protocalls, and I have learned that the rn52 comes configured as a A2DP sink, able to pair with your phone rite out of the box, hook up some speakers and play music.
However I wanted to configure one as a master and the other a slave. The rn52 documentation does mention a command to change it to a master, but through searching I found out you have to upload a different firmware from sparkfun rn52scr. That accomplished, I am able to stream audio from master to slave with the A2DP, and AVARP.
Ok that accomplished, I needed to figure out how to use my Arduino to give my rn52 commands via a sketch, and see what it does in real time.
I knew almost nothing about serial communications so this also has been a learning experience. After hours of futile searching and failure to communicate, I read about needing level converters between 5v arduino and 3.3v rn52, so I ordered some. That didn't work (yet lol).I finally read somewhere that I cant talk to my rn52 through the same rx/tx 0-1 pins that the usb is using to upload sketches. I would need to us SoftwareSerial to designate two other digital pins For the Arduino to to talk to the rn52 through. So I have reconfigured my tx/rx pins pins 3,4, gnd, 5v from the Arduino to the High side of the level converter, and low side to the rn52. Dont forget to hook the rx to the tx. I then took my 3.3v FTDI breakout and hooked the rx to the tx on the rn52 so I can monitor output on the rn52. So I have the Arduino hooked to com port 5, to upload sketches, and the FTDI is on com port 4 so I can watch com port 4 on the serial monitor.
After that, the big challenge was to learn enough code syntax to mySerial.write('D') in a sketch, load it into the arduino and see what happens. Bingo it worked. There is a softwareSerial sample sketch, but it is mostly concerned with talking back to your computer, but its a start, at least as far as starting serial communications.
My next challenge: while the rn52 is configured for A2DP audio streaming, it doesn't transmit data, but AVARP is enabled. I think I can use my Arduino to monitor the output from the rn52 serial port, and perhaps hijack one of the AVARP command function not being used play/pause for example, and when the arduino sees it, close the push to talk circuit via a transistor. That way only one microcontroller is required on the master side. So in the void loop, i will monitor the rn52 serial port, when the output ='s a string, then transister pin high, delay 100 ms, check serial output not = to string transistor low, or something like that.
On the headset I can wire the push to talk button to the play/pause button to the corresponding GPIO pin on the rn52.
At any rate that is the goal, and I have read and learned enough to share what I have learned, and maybe help someone else along.
Any advice is welcome, and so are question.
SS_send_commands_to_rn52.ino (3.8 KB)