Author Options:

How to program the XS3868 bluetooth audio module through arduino? Answered

Hello, I have a few of these xs3868 bluetooth audio modules that I used in some speaker systems I built for myself, but now one of my friends wants me to build him a custom speaker with a custom bluetooth device name and passcode. So I thought, ok, I read a little about programming with the AT commands but never tried it before, so I hooked up a board to 3.3 and gnd of the arduino like I usually do to check before soldering everything, my phone connected with no problem. So next I turned off my phone's bluetooth so it wouldn't mess with the chip while programming it and connected the rx and tx pins of the board to tx and rx respectively. I also made the following adjustments in the arduino serial interface that I remember reading somewhere: No Line Ending, and 9600 baud rate. Plugged in in to the tx and rx of the arduino board with at mega chip removed and had no luck getting any response from the chip, I switched baud rate to all of the different baud rates available with no success, the only effect the chip has on the serial interface is that when the power cord slipped and I plugged in back in with rx, tx and the usb cable still connected it output a few seemingly random characters while (I'm assuming) the chip was booting up, at 115200 baud rate the characters were a "u" with two dots over it and a combination lowercase "b" and "p" (for some reason I can't copy/paste it). It only outputs these characters when one of the power wires is reconnected after being disconnected (I have a bunch of these so if I fry one it's no big deal). I tried connecting my phone again after a while and it worked, checked the wires with my multimeter and both are connected and neither is shorted to any other pins and switching rx/tx does nothing to fix the problem either. I have a usb to serial coming in the mail soon hopefully but my friend was hoping this could be finished sooner than it would arrive so any help would be greatly appreciated.

Edit: Is it possible that the module could have a rs232 interface, rather than a ttl interface? I've heard that arduino only uses ttl and that I'd need another adapter to get to rs232 since my computer doesn't have that kind of serial interface.



1 year ago

Hi I want pairing tow xs3686 module together?Please help me

you would probably have to have an arduino library installed

and it would probably have to have an arduino controller to store the code

and other stuff like that

i have a problem! my phone connects to the BT but disconnects after 4-5 seconds. any idea?


2 years ago

Hi buddy ... ;)

do you know how to send a character by xs3868 ?
I have found a command (AT#ST) that can send char...

I have installed an bluetooth terminal in my phone and wrote this code :
AT#STdata ( "data" is the string that I wanna send )
but there was nothing in my phone ...
what is wrong with it ???????????


2 years ago

Dear LazyH,

I am sure you have already solved this problem. However, I will publish my modest results here, because I myself spent quite a lot of time trying to work this small piece of hardware, I mean, xs3868 module based on the OVC3860 chip, and I could never find any sensible description.

I sent the AT commands from my Win 7 PC through the serial port using the USB-UART bridge based on the CP2102 chip. It is now really cheap. See, for example, "NEW CP2102 USB 2.0 to UART TTL 5PIN Module Serial Converter for Arduino YP",


I used Python, specifically IPython environment which is as convenient as Matlab, if you know it. Just key in a command and instantly get the response from the device. I used the PySerial Python module.

Here is a Python script where I gathered the AT commands I sent to xs3868 today.


# Sending AT commands via the serial port to the Blurtooth transceiver

# module xs3868 based on the OVC3860 chip.


import serial

ser = serial.Serial(port='COM5', baudrate=115200, timeout=.01)

print 'ser.isOpen() = ', ser.isOpen()

# Enter pairing

ser.write("AT#CA\r\n"); print '"AT#CA" -> ', ser.read(128)

# Cancel pairing

ser.write("AT#CB\r\n"); print '"AT#CB" -> ', ser.read(128)

# Query status

ser.write("AT#CY\r\n"); print '"AT#CY" -> ', ser.read(128)

# Reset

ser.write("AT#CZ\r\n"); print '"AT#CZ" -> ', ser.read(128)

# Query status

ser.write("AT#CY\r\n"); print '"AT#CY" -> ', ser.read(128)

# Play/Pause

ser.write("AT#MA\r\n"); print '"AT#MA" -> ', ser.read(128)

# Stop

ser.write("AT#MC\r\n"); print '"AT#MC" -> ', ser.read(128)

# Connect to av source

ser.write("AT#MI\r\n"); print '"AT#MI" -> ', ser.read(128)

# Disconnect from av source

ser.write("AT#MJ\r\n"); print '"AT#MJ" -> ', ser.read(128)

# Query avrcp status

ser.write("AT#MO\r\n"); print '"AT#MO" -> ', ser.read(128)

# Start FF

ser.write("AT#MR\r\n"); print '"AT#MR" -> ', ser.read(128)

# Start Rewind

ser.write("AT#MS\r\n"); print '"AT#MS" -> ', ser.read(128)

# Stop FF/Rewind

ser.write("AT#MT\r\n"); print '"AT#MT" -> ', ser.read(128)

# Query A2DP Status

ser.write("AT#MV\r\n"); print '"AT#MV" -> ', ser.read(128)

# Decrease Volume

ser.write("AT#VD\r\n"); print '"AT#VD" -> ', ser.read(128)

# Increase Volume

ser.write("AT#VU\r\n"); print '"AT#VU" -> ', ser.read(128)

# Read a byte from memory

ser.write("AT#MX08001AC4\r\n"); print '"AT#MX08001AC4" -> ', ser.read(128)

# Print 64 bytes of memory starting from 0x08000000

for a in xrange(64):

addr = 0x08000000 + a


r = ser.read(128)

i = r.find('MEM:') # Index of first letter of "MEM:" in r

r = r[i+4:] # Cut away up to end of 'MEM:'

i = r.find('\r') # Index of first letter "\r" in r

# In hexadecimal, 2 digits with leading zero:

print '%08x: %02x ' % (addr, int(r[:i], base=16))



If you have any questions, please do not hesitate to ask me.

Here is the Python script output:


"AT#CA" ->


"AT#CB" ->



"AT#CY" ->



"AT#CZ" ->



"AT#CY" ->



"AT#MA" ->



"AT#MC" ->


"AT#MI" ->


"AT#MJ" ->


"AT#MO" ->



"AT#MR" ->


"AT#MS" ->


"AT#MT" ->


"AT#MV" ->



"AT#VD" ->



"AT#VU" ->






08000000: 18

08000001: 18

08000002: 18

08000003: 18

08000004: 18

08000005: 18

08000006: 18

08000007: 18

08000008: 18

08000009: 18

0800000a: 18

0800000b: 18

0800000c: 18

0800000d: 18

0800000e: 18

0800000f: 18

08000010: f0

08000011: f0

08000012: f0

08000013: f0

08000014: f0

08000015: f0

08000016: f0

08000017: f0

08000018: f0

08000019: f0

0800001a: f0

0800001b: f0

0800001c: f0

0800001d: f0

0800001e: f0

0800001f: f0

08000020: 9f

08000021: 9f

08000022: 9f

08000023: 9f

08000024: 9f

08000025: 9f

08000026: 9f

08000027: 9f

08000028: 9f

08000029: 9f

0800002a: 9f

0800002b: 9f

0800002c: 9f

0800002d: 9f

0800002e: 9f

0800002f: 9f

08000030: e5

08000031: e5

08000032: e5

08000033: e5

08000034: e5

08000035: e5

08000036: e5

08000037: e5

08000038: e5

08000039: e5

0800003a: e5

0800003b: e5

0800003c: e5

0800003d: e5

0800003e: e5

0800003f: e5


2 years ago

Hey I am also a little curious whether you where able to change the password as well as the name?

I tried the commands AT#MM and AT#MN -- no, they do nor work:

import serial

ser.write("AT#MM\r\n"); print '"AT#MM" -> ', ser.read(128)

"AT#MM" ->


ser.write("AT#MN\r\n"); print '"AT#MN" -> ', ser.read(128)

"AT#MN" ->


I read somewhere it is possible but only until the device is hooked up to thr battery or power supply. After it has been disconnected and connected again these changed are lost. The commands are:


AT#MM /* Get the BT device name */

AT#MN /* Get the BT device pin code */


AT#MMXX /* Set the BT device name */

AT#MNYY /* Set the BT device pin code */


This is the source Chinese pdf:


Try connecting Tx-Tx and Rx-Rx. BTW use a level shifter. There is some problem with Tx Rx pins on Arduino Uno. I did the same on my ESP8266 and Tx-Tx connection works. But when I was using hardware serial with atmega328 plugged in with HC05 module, Tx-Rx connection worked. Just put a voltage divider on Rx pin of arduino Uno connect Tx-Tx Rx-Rx and see if it works

neither orientation seemed to work. What kind of effect does the voltage divider have on the signal? I don't have much experience with this kind of thing so I'm curious about how you would do this, is it a component you place in the path of the signal between RX pin on arduino and the corresponding pin on the Bluetooth module or is there a setting on the board for that. Sorry, you can probably tell how little I know about this kind of thing.

Try this,Upload a blank sketch to arduino and then connect a 1k in series with 2k resistor from arduino rx pin to ground. then connect the 1k 2k junction to rx of the module, connect tx to tx directly. Now open serial monitor, choose settings BOTH NL & CR and try different baud rates, send AT and it should return OK

Ok, between kids and work, i finally got the time to throw together a voltage divider, I'll post some pics later once I find my camera. I'll post an instructable once i finish setting it all up with a few simple sketches too for anyone interested. Thanks for all your help.

if it needs 3.3v input then that would explain why the board started burning after a while trying to send it commands at 5 volts. Sorry it took a while to get back to you, I get internet from my phone and my phone was broken for a while.

Oh, so that's what level shifting is, I get it now, since 3.3v is ~=5v(2/3) you put the signal output 2/3 up from what the signal path sees as 3 equal value resistors. I get it now, thanks. Now to give it a try, that video posted a couple comments up said something similar, with the same circuit.

this video has the correct connections, in time 1:47

using the serial in different pins TX / RX Arduino (10 and 11 example)

commands at: http://labdegaragem.com/forum/topics/hc-06-comando...

I connected to the same video, loaded the software and sent commands smoothly. I could not receive data. Probably do voltage divider as similar HC05

boards are different (v1.2 X v2.0)



Nice post. Do you have some news or updates ?

I 'm trying to do exactly the same.

It was for a friend birthday and i started to build diffrents king of speaker's.

The bithday was in November and he is still waiting for it ;-)

I couldn't change the name on the BT controleur.

I tried with an HC-05 & 06 i could change the name but couldn't use it as a Bluetooth audio receiver.

I also bought a BT usb audio receiver stick with rt/tx but couldn't talk to it.

I don't have a lot of knowledge and experience at this anyway and got an Arduino Uno fiew month ago.

Did you find any solutions or alternatives ?

Did you aske the resseller if they know how to do that ?


unfortunately the extra hardware I'm waiting for that would allow me to use rs232 to program it got lost in the mail and I have no other ways to set this up right now. I'll post an update as soon as it gets here and I can try it out, just hope it won't be too much longer.

In my mind its better to be a little late than do something half @$$, I hope your friend enjoys them when you finish those speakers. I'd love to hear more about your speakers, are they going to be a smaller portable set or larger Bluetooth controlled system? I'm mostly going to use the hivi b1s 1 inch speaker for mine, lithium batteries to power the amp and Bluetooth and a little charging module to power the whole thing from USB.

Hard to say. The datasheet is in Mandarin. Its HIGHLY unlikely to be anything but 3v3 logic - NOT TTL, which is 5V. You'll need to create RS232 for your USB interface, unless you are using one of FTDI's interface cables, with 3v3 logic out.

Ok, would a max3232 work for that? I figured I'd order one when I got my serial adapter. Would it also work through the arduino ide still? That's the only way I know to program a serial device.

All you need is a terminal emulator, the one in the Arduino will work, but there are many others.