Introduction: Send AT Commands to BLE 4.0 Module From Android Phone
Today, I am going to show you how to send AT commands to Bluetooth Low Energy as called BLE 4.0 (There are BLE v4.1 and BLE v4.2) module by using your Android device which supports On-The-Go as called OTG option for example to detect a usb mouse indicator on your mobile phone by otg usb cable. This is the first time usage of Bluetooth Low Energy (BLE) module. This instructable is different because I am not using Arduino or Raspberry Pi board to send AT commands to BLE device, I am using my Android mobile phone to show you how powerful our Android devices are :) (For HC05-HC07, read this)
NOTE: Charge your phone's battery as %100 then begin!
The need list:
1. Android device with version bigger than v4.3with OTG support (Check your phone supports OTG or not)
2. OTG cable (Micro male usb pin input to usb type A female usb pin out)
3. Mini usb cable (Mini male usb pin input to usb type A male usb pin out)
4. FTDI FT232RL USB to TTL converter with conductive jumper plastic included
5. BLE 4.0 module (My module = SSID is BT05, LEVEL:3.3V, Power: 3.6V-6V, ZS-040, details are in next step)
Step 1: Make a Connection
Follow the diagram and make the connections between each part.
NOTE: When you run BLE module from your phone, your phone's battery is going to go down a little bit more quick that's because of external BLE module and FTDI module you attach and want to run both. So, charge up your phone before do this instructable.
NOTE: Your FTDI TTL converter should use 5V jumper. Check your converter's logic converter level. It may 3.3V or 5V and there has to be GND between. Use 5V and GND to make short-circuit by a cable or jumper. Our bluetooth module supports 5V so we use 5V and GND pins together in same.
NOTE: If you are near with your computer you can use Tera Term program to send AT commands via usb cable to your bluetooth module over the cable. Your computer will recognize and opens a COM port and on Tera Term program, select serial port and write related COM port name and connect. (Check the picture about that)
NOTE: Baud rate is 9600
Step 2: Download the App
The app name is: Free USB Serial Term
Google Play link is: https://play.google.com/store/apps/details?id=com....
Details: Click on the link above, sign in with your account, ass your mobile device to Google Play your account, download this application to your mobile phone. For more details, check the app page and learn what it supports as a hardware.
File is: 406 kilobytes
Step 3: While App Is Running
While app is running on your mobile phone:
1. Click on CR and LF things on the down-right side to enable both.
2. Click on right-top side's wrench icon to go settings >> select 9600 as baud rate >> save and return to main page
3. Type AT command to BLE module then select OK after that. It should be response as OK.
On this step, let's learn our module's firmware version:
My firmware version is:
+VERSION=Firmware V3.0.6,Bluetooth V4.0 LE
Step 4: All Other AT Commands for Us
Now, test the AT commands as you like one-by-one:
AT = OK
AT+RESET = OK
AT+VERSION = +VERSION=Firmware V3.0.6,Bluetooth V4.0 LE
AT+ADDR = +ADDR=00:15:83:00:85:A9 (This is my device's mac address)
AT+NAME = +NAME=BT05 (To change device name input AT+NAMEali, now the name is set as ali, thenAT+RESET to enable new name, you can leave blank and use 13 character)
AT+ROLE = +ROLE=0 (Slave is 0 changes blink frequency rarely, Master is 1 changes blink frequency speedy, Slave-loop is 2 which loops from master to master)
AT+BAUD = +BAUD=4 (To change Baud Rate use AT+BAUDn n=1 for 1200, n=2 for 2400, n=3 for 4800, n=4 for 9600 (default), n=5 for 19200, n=6 for 38400, n=7 for 57600, n=8 for 115200, to enable, reset the module with AT+RESET)
AT+PIN = +PIN=000000 (To change pin AT+PIN123456 to enable AT+RESET)
AT+ORGL = Roll back to original settings
AT+RMAAD = If paired, release..
AT+PAIR=(12:34:56:78:90:10),60 = Try to pair this address (12:34:56:78:90:10) for 60 as a time unit.
NOTE: Other models of Bluetooth modules and other AT command details are here
That's all !
Step 5: BONUS: Reading This Instructable
NOTE: This instructable's step is aimed for visually impaired people to hear the sentences to learn what's going on here. Watch the video, it explains all steps.