Pages

Saturday, June 10, 2023

Jdy-31 SPP bt module

 This is about JDY-31, an SPP bluetooth module. 

This is cheap bluetooth module compared to   HC-06 which is claimed to be pin-compatible.

My Experience

I bought this because this is cheap. And serve its purpose. Just to replace USB-to-TTL module, then I can connect my device using bluetooth instead of wired one. This especially important to isolate the device (providing electrical isolation).

Unfortunately, I spent 3 days to configure this module until I found the way.

Why

I need to configure this device because it baudrates doesn't match the device. The module's baud is default 9600 bps. So I need to change it. Besides, it would be cool to change the broadcast name.

The result

I am successfully configures the module. here what is need to be considered:

  1. The default pairing pin is 1234, in case you doesn't found the manual. Yes, this module is sold without packaging.
  2. Check the voltage. In case you forgot, UART begins with high logic, start bit is low. So RX of BT is connected with TX of device, and logic is high.
  3. This module is slave device. Means it cannot initiate connection. 
  4. The configuration uses AT command. So you need to connect with other device to configure. I use USB-to-TTL module to configure using PC.
  5. AT command is case sensitive.
  6. AT command must ends with CRLF or 0x0D0A.
  7. JDY-31 only respond to right command. So entering AT will not respond. Comparing other modules which may responds OK.
  8. The command needs to sent using burst mode. Means the AT prefix until CRLF must not have significant delay. I don't know the exact amount. 
    1. Realtime mode: the character is sent as you type. Typing 'A' will be sent immediately. Many terminal application use this mode.
    2. Burst mode: Sent only done when user press send button. Terraterm use 'broadcast' for this mode.
  9. The AT command only works if not connected. Unfortunately, no pin for indicating the connected state. Only LED which is blinked. When connected, obviously the command will be sent plainly to the connected master.
  10. No difference between unpaired or paired.
So that is the conclusion.

Commands I use
Here some command I use:
  • AT+VERSION
    • connected: will send AT+VERSION to master device.
    • unconnected: will respond +VERSION=JDY-31-V1.35,Bluetooth V3.0
  • AT+BAUD. Setting baud rate to 115200 bps: AT+BAUD8
    • connected: will send entire command to master device.
    • unconnected: will respond +OK
    • query command AT+BAUD, reponse +BAUD=8
    • the default is BAUD4 for 9600 bps.
    • Note: the actual baud is not changed until the device is restarted. You can confirm this by sending AT+VERSION. If the modules respond, means the baud is not changed. Try to change the terminal baud rate setting. And see if it respond. Then unpower the module and re power it. Try sending AT command again. This also means the setting is kept even the module is unpowered. No need initialization.
  • AT+DISC: disconnect the bluetooth's serial connection. This only AT command valid when connected.
    • connected: respond +DISC=SUCCESS and broke transmit connection. Actually it kept connected, only cannot transmit, only receive.
    • unconnected or broke transmit: no response.
    • To normalize this state, use soft reset AT+RESET. Or hardware reset by unpower-repowering module. Module will respond +OK for soft reset. The connected device will respond with connection lost.

No comments: