Intro
I'm only playing hockey once per week this month, so no hockey tonight. This means I have some time to get started on a second mystery project.
The idea of these mystery projects is to add some interactivity to the project blog by sequentially providing some visual clues so viewers can try to deduce what the project is all about based on the images. Eventually I will publish the complete project documentation, so everyone can see how good their guesses were.
The first clue this time is simply an image of a bare PCB which will eventually be incorporated into the project:
There is something strange about this PCB....
PCB

Enclosure
Clue #2 - a picture, and yes it does have a puck....

Here is a look inside one of them....but why do I need two of them?

The Reveal
Here is a video that pretty much explains everything including the secret sauce:
The Problem
I have a whole menagerie of Bluetooth projects that use HC-05 Bluetooth modules for communications. The problem is that all of the HC-05 modules have the same name, so when trying to connect to a specific one, it gets very confusing. It is possible to change the default name, but it only needs to be done once and it does take an extra signal to put the device into command mode. I don't like the idea of writing and running a special program for every Bluetooth project, so it has been a long standing requirement to develop a little programming system that could setup these Bluetooth modules with an appropriate name. These modules come in several form factors, but I only use 2: one is a 5V module with a 6 pin header, the other is a castellated surface-mount module with 32 "pins".
The Bluetooth Menagerie
The name of this project and Bluetooth module is Henrietta. There is an element 14 interview recorded in Germany about it.
The Crown Tools is a helmet mounted sensor system to monitor violent impacts.
The Heart Reactor is a heart rate monitor based on an Iron Man Arc Reactor theme.
The GPS Clock is a spin-off from the Henrietta Project - consolidating all functionality onto a printed circuit board.
The Car Cape is an OBD2 vehicle trip monitor and vehicle trip simulator
The Clear Walk project used remote mirror deflection
. The Long Range Sensor Array is part of the Star Trek project
The Snoop Cat project monitored cat locations
The Solar Super Cap Weather Station
Sammy Semaphore was controlled via Bluetooth
So you can see why all these Bluetooth systems need to have different names.
Project Description
The project objective is simple - develop a couple of instruments that can program HC-05 Bluetooth modules to give them unique names.
I toyed with the idea of making them stand-alone, but ended up opting to run them from a VB6 program on a PC - why not leverage the keyboard and display available on a PC?
The MCU chosen is an Arduino Pro Micro because it is small and there are both 3.3 V and 5 V versions available - I actually had both in stock.
The functions of the MCU are simple, be able to place the HC-05 in either data or command mode and pass through AT commands and responses.
Schematic

Software
Arduino code:
/*
* Changing HC05 module's default device name using AT Commands
* The arduino puts the HC05 into AT command mode then passes AT commands from the USB port on to the HC05
* by Doug Wong
*
* Pinout:
* Key --> pin 21
* VCC --> Vin
* TXD --> pin 1
* RXD --> pin 0
* GND --> GND
* Reset --> pin 10
*
* AT Command : AT+NAME=<new device name>
*
*/
void setup()
{
pinMode(21, OUTPUT); //key
pinMode(10, OUTPUT); //RST
digitalWrite(10, LOW); //reset HC-05
digitalWrite(21, HIGH); //start command mode
delay(50);
digitalWrite(10, HIGH); //enable HC-05
Serial.begin(9600);
delay(5000);
Serial.println("BLUETOOTH Module Setup");
Serial.println("HC-05");
Serial.println("Use AT commands:");
Serial.println("Enter AT commands:");
Serial1.begin(38400); // HC-05 default speed in AT command mode
Serial1.println("AT");
}
void loop()
{
// Read from HC05 and send to Arduino
if (Serial1.available())
Serial.write(Serial1.read());
// Read from serial monitor and send to HC05
if (Serial.available())
Serial1.write(Serial.read());
}
Here is the VB6 code - not documented and it doesn't include the GUI stuff...
Public InFlag As String
Private Sub Clear_Click()
Text2.Text = ""
End Sub
Private Sub Closed_Click()
HC05comm.PortOpen = False
End Sub
Private Sub ClearR_Click()
SerialIn.Text = ""
End Sub
Private Sub ExitMenu_Click()
Call DatMode_Click
If Popen.Value = True Then
HC05comm.PortOpen = False
End If
End
End Sub
Private Sub GetStatus_Click()
If Popen.Value = True Then
HC05comm.Output = Chr(1)
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub HC05comm_OnComm()
Timer1.Enabled = True
End Sub
Private Sub Popen_Click()
Text1.Text = ""
HC05comm.CommPort = Val(USBport.Text)
HC05comm.PortOpen = True
End Sub
Private Sub Pclosed_Click()
HC05comm.PortOpen = False
End Sub
Private Sub SetPWD_Click()
If Popen.Value = True Then
Text1.Text = ""
HC05comm.Output = "AT+PSWD=" & PWDset.Text & vbCrLf
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub SetName_Click()
If Popen.Value = True Then
Text1.Text = ""
HC05comm.Output = "AT+NAME=" & NameSet.Text & vbCrLf
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub GetPWD_Click()
If Popen.Value = True Then
Text1.Text = ""
InFlag = "PWD"
PWDtxt.Text = ""
Text2.Text = "AT+PSWD?" & vbCrLf
HC05comm.Output = Text2.Text
Timer1.Enabled = True
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub GetName_Click()
If Popen.Value = True Then
Text1.Text = ""
InFlag = "Name"
NameTxt.Text = ""
Text2.Text = "AT+NAME?" & vbCrLf
HC05comm.Output = Text2.Text
Timer1.Enabled = True
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub Form_Load()
With HC05comm
.Handshaking = comNone
.SThreshold = 0 'No events after send completions.
.RThreshold = 1 'Event on every character
' .PortOpen = True
End With
InFlag = "Data"
End Sub
Private Sub CMDmode_Click() 'Command mode
If Popen.Value = True Then
HC05comm.Output = Chr(60)
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub DatMode_Click() 'Data mode
If Popen.Value = True Then
HC05comm.Output = Chr(62)
Else
Text1.Text = "Port not open"
End If
End Sub
Private Sub Send_Click()
Text1.Text = ""
If Popen.Value = True Then
If Len(SendText.Text) > 0 Then
HC05comm.Output = SendText.Text
HC05comm.Output = Chr$(13)
HC05comm.Output = Chr$(10)
Text2.Text = Text2.Text & SendText.Text & Chr$(13) & Chr$(10)
SendText.Text = vbNullString
Timer1.Enabled = True
End If
Else
Text1.Text = "Port not open"
End If
SendText.SetFocus
End Sub
Private Sub Timer1_Timer()
Dim strInput As String
Timer1.Enabled = False
strInput = HC05comm.Input
Text1.Text = strInput
If strInput <> "" Then
If InFlag = "Data" Then SerialIn.Text = Text1.Text
If InFlag = "Name" Then NameTxt.Text = Text1.Text
If InFlag = "PWD" Then PWDtxt.Text = Text1.Text
End If
Text1.Text = ""
InFlag = "Data"
End Sub
Private Sub USBport_Change()
Comm.PortOpen = False
Comm.CommPort = USBport.Text
Comm.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Comm.PortOpen = False
End Sub
Discussion
This project has been on my bucket list for a decade so it is very satisfying to finally bring it to life. Although I have been doing some BLE projects, I still prefer the simplicity of classic Bluetooth and I expect to continue to use this technology.
Top Comments