- You need to use AT instruction to set up some parameters via the serial port. So you can refer to the following module handbook:
||For communication connection
||For serial port communication debugging
||For circuit connection
||For power supply
- We must set one module as the master machine and another as the slave machine. The master machine will search the requirement of the slave machine and then match them. When we start to build the hardware and connect Microduino-BT and Microduino-USBTTL, we need to connect four wires:
- Slave Machine Parameter Configuration：
- Build the circuit according to the schematic and supply the power through USB cable;
- Open Arduino editor, choose the right COM port, open the serial port debugging, or you can use other Com debug assistant.
- First, choose the serial port baud rate as 9600 , set the mode as “No line terminator”. Click “send” or “enter” after inputting “AT” in the serial port data sending box, you’ll receive “OK” at the data receiving end, meaning your BT module can be set via AT instruction.
Notice: If there is no return value, you need to change the baud rate to 115200. It is probably the unmatched baud rate that leads to failed communication. Baud rate setup can refer to the module handbook above.
- Check and set a BT module under slave mode(The default is the slave mode):
- Click “send” or “enter” after inputting “AT+ROLE” in the serial port sending box, you can set it under the slave mode if it returns as “OK+Get0” and under the host mode if it returns as “OK+Get1”. So, you need to set the slave mode via “AT+ROLE0” instruction.
- Check the work type of the slave machine--“Power to work instantly”.
- Click “send” or “enter” after inputting “AT+IMME?” in the serial port data sending box, you can know that “Power to work instantly” if it returns as “OK=Get1”. Otherwise, you need to set it as “Power to work instantly” mode via “AT+IMME?” instruction. After finishing configuring the slave machine parameter, you just need to get it powered.
- Master Machine Parameter Configuration：
- Check and set another BT module to be under the master machine mode:
- Click “send” or “enter” after inputting “AT+ROLE?” in the serial port data sending box. If it returns to be “OK+Get0”, then it is under the slave mode. You need to set it under the host mode through “AT+ROLE1” instruction. Generally, by this time you can get your Bluetooth connected. The host machine will search the slave devices and connect them automatically.
- If it fails to connect, please check whether the work type of the host machine is “Power to wait ” (Default).
- Click “send” or “enter” after inputting “AT+IMME?” in the serial port data sending box. If it returns to be “OK+ Get1, then it is under the mode of “Power to work instantly”. So, you need to set it under the mode of “Power to wait” through “AT+IMME0” instruction.
- If it still can’t connect under the mode of “Power to wait”, it is probably the host machine has connected other Bluetooth devices.(Since it will try to connect the preserved slave devices instantly, this may lead to disconnection with the existing devices.) So, you can use “AT+CLEAR” to clear the originally stored connection information. In this way, it can enter the search state and search once again for device and then connect.
- If it still can not be connected, you can try to connect devices in the fixed Bluetooth MAC address
- Connect Microduino-USBTTL with the slave machine, configure the host machine, check MAC address of the slave machine and save the address.
- Click “send” or “enter” after inputting “AT+ADDR?” in the serial port data sending box. If it returns to be address “OK+ADDR:MAC（XXX）”, please don’t forget the address since the host machine needs to make connection through the address. After configuring the slave parameter, the only thing you need is to get it charged.
- Connect Microduino-USBTTL and the host machine, configure the host machine, set the work type of the host--”Power to work instantly”.
- Just input “AT+CONXXX” in the serial port data sending box. “XXX” is the MAC address you keep in mind. Then, click “send” or “enter”. If it returns to be “OK”, it means a successful connection and you can see two Bluetooth indicators don’t blink. It it can’t connect to the fixed devices, it’ll enter the state of search and at this time, you can try “AT+RESET” to restart the module and reconnect.
- After it is connected, if you cut off the device, you can’t reconnect it once again. You need to restart the serial monitor, set the work type of the host machine--”Power to wait”. Thus, you can get it connected every time it gets powered off.