Bluetooth XC4382

Hello
I have been trying to fully connect a Bluetooth XC4382 module to an arduino uno.
For the moment i just want to be able to send and receive AT commands via the usb pot to fully initiate the module. The following code is what i have been using and needs refinement to allow for full communication as at the moment as the bluetooth will not provide the basic AT commands
The code is included below

#include <SoftwareSerial.h>
// TXD pin */
#define BT_SERIAL_TX 10
// RXD pin */
#define BT_SERIAL_RX 11
SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX);

void setup() {
Serial.begin(9600);
BluetoothSerial.begin(9600);
delay(1000);

// Should respond with OK
BluetoothSerial.print("AT");
waitForResponse();

// Should respond with its version
BluetoothSerial.print("AT+VERSION");
waitForResponse();

// Set pin to 1234
BluetoothSerial.print("AT+PIN1234");
waitForResponse();

// Set the name to BLU
BluetoothSerial.print("AT+NAMEBLU");
waitForResponse();

BluetoothSerial.print("AT+BAUD4");
waitForResponse();

Serial.println("Finished!");
}

void waitForResponse() {
delay(1000);
while (BluetoothSerial.available()) {
Serial.write(BluetoothSerial.read());
}
Serial.write("\n");
}

void loop() { }
any help would be very appreciated to improve the system and get it fully running

Hi

It would help if you could tell us what the sketch is doing and what you expect it to do. E.G. do you get a response from the AT command.

Also could you post a link to (or a copy of) the datasheet for your XC4382?

A quick google finds me this:-

https://www.jaycar.com.au/medias/sys_master/images/9116161474590/XC4382-manualMain.pdf

from Jaycar in Australia. However there are significant differences between the commands listed and the ones you are using e.g. You are trying an "AT+VERSION" command which is not listed in the Jaycar datasheet.

Clarification on these things will help us to help you.

Ian

In an attempt i was trying to use the AT commands and it was just displaying nothing but by the data sheet there which you found seems to be the right one, the one i was going off was for the wrong model..

I will have an attempt at putting the right inputs for the code in and see how it goes

All in all i just want to be able to speak back and fourth with AT commands to the Bluetooth module that i bought

Relatively new to all of the coding, thank you for the help

Euan71002:
In an attempt i was trying to use the AT commands and it was just displaying nothing but by the data sheet there which you found seems to be the right one, the one i was going off was for the wrong model..

I will have an attempt at putting the right inputs for the code in and see how it goes

All in all i just want to be able to speak back and fourth with AT commands to the Bluetooth module that i bought

Relatively new to all of the coding, thank you for the help

Ok.

If you are getting nothing from the basic "AT" command check that your wiring is correct. The TX pin on the Arduino must go to the RX pin on the XC4382 and the RX pin must go to theXC4382's TX pin. I.E. you connect the transmitter at one end to the receiver at the other in both directions.

Secondly if you change the serial speed of the bluetooth module with the "AT+BAUD=" command you must immediately change the BluetoothSerial baud rate to match. Otherwise the module will be sending at 115200 baud and the Arduino will be listening at 9600 baud and will either receive either garbage or nothing.

Hope this helps

Ian

Re XC4382 BLE Bluetooth Module, I am able to get all AT commands working and responding correctly as per the data sheet except for AT+DISC?, and the other Master (ROLE=1) commands.
All AT commands work except for the master commands.
I am definitely in MASTER mode.
The XC4382 does not respond with OK+DISCS ( scan started ).
I am not in an active Bluetooth connection, so that is not the problem.
I think the XC4382 is faulty and I should return to the store to exchange.
Is someone able to advise please ?

Did you manage to get the XC4382 communicating? Im in a similar position . Trying to send AT via serial monitor but no response at all.

I tried as per pdf using the default File/New sketch compiled and sent to the Arduino and IDE serial monitor screen. No responses to sending AT command from the monitor - tried both TX Rx pin combinations provided in the PDF - the Led is lit solid, I see some Tx activity on the Uno, but no Rx

From the "manual" :
https://www.jaycar.com.au/medias/sys_master/images/9294142013470/XC4382-manualMain.pdf

To connect the XC4382 BLE Bluetooth Module to communicate directly with a computer (eg for AT
command configuration and debugging), use the following connections:

Uno/Mega/Nano with no sketch loaded (ie as transparent serial bridge):

Uno/Mega/Nano -> XC4382
D0 (RX) ->RXD
D1 (TX) ->TXD
VCC ->5V
GND ->GND

Arduino Serial Monitor, the default settings are 9600 Baud, no line ending.

Update: I had the cabling OK for Port 1 and 2 TX to TX and RX to RX. What I didn't know was that these should to NOT be connected when the empty (File/new) sketch is loaded. Once loaded connect the send and receive cables and open the serial monitor. The at commands on this module are case insensitive. It didnt care what the end character was either, so I used CR/LF @ 9600 so its easier to read.

The module doesn't care if RX is 5v, so no need for voltage divider.

I also found out this model wont pair with a phone as its using BLE on normal BlueTooth.. The pairing (connection) is done at the application level. I used a BLE Bluetooth Terminal app and managed to send a 0 and 1 to control a Led as per the various Bluetooth control sketches around (e.g Ralph Bacon Demo https://www.dropbox.com/sh/8tf9fjb2tugkkr8/AAD0jaeRQlWhQtfv764pTEf5a?dl=0 ).

Martyn Currey has an excellent write-up
http://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/

I have been using the MIT AppInventor 2 to build an Android app as per Ralph Bacon's uTube - it now has a BlueTooth LE Extension that works well with the module - the default BlueTooth controls dont as they are for legacy BlueTooth,