element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Community Hub
Community Hub
Member Blogs Mystery Project #2 - Bluetooth Module Programmers
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Community Hub requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dougw
  • Date Created: 19 Apr 2025 5:20 PM Date Created
  • Views 1599 views
  • Likes 8 likes
  • Comments 33 comments
  • bluetooth
  • dougw
  • mystery project
Related
Recommended

Mystery Project #2 - Bluetooth Module Programmers

dougw
dougw
19 Apr 2025

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....Sunglasses

PCB

image

Enclosure

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

image

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

image

The Reveal

Here is a video that pretty much explains everything including the secret sauce:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

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

imageThe name of this project and Bluetooth module is Henrietta. There is an element 14 interview recorded in Germany about it.

image The Crown Tools is a helmet mounted sensor system to monitor violent impacts.

image The Heart Reactor is a heart rate monitor based on an Iron Man Arc Reactor theme.

image The GPS Clock is a spin-off from the Henrietta Project - consolidating all functionality onto a printed circuit board.

image The Car Cape is an OBD2 vehicle trip monitor and vehicle trip simulator

image The Clear Walk project used remote mirror deflection

image. The Long Range Sensor Array is part of the Star Trek project

image The Snoop Cat project monitored cat locations

image The Solar Super Cap Weather Station

image 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

image

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.

Other Mystery Projects:

Mystery Project #1

Mystery Project #2

Mystery Project #3

  • Sign in to reply

Top Comments

  • beacon_dave
    beacon_dave 29 days ago +2
    Solder Party does something similar to the test point insert called the 'FlexyPin' https://www.solder.party/docs/flexypin/ https://www.solder.party/docs/flexypin/adapters/
  • beacon_dave
    beacon_dave 1 month ago in reply to dougw +1
    "Multipath routing" supported - one bit over there, another bit somewhere else...
  • DAB
    DAB 29 days ago +1
    Great project Douglas.
  • dang74
    dang74 27 days ago

    I was indeed baffled by the footprint with the pair of holes.  Thanks for taking the time to explain this special feature in the video.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw 29 days ago in reply to beacon_dave

    Yes - the weird SMT footprint was strange.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB 29 days ago

    Great project Douglas.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave 29 days ago in reply to dougw

    Ah - yes, you actually mentioned FlexyPins in the video but I think my brain had registered 'flexible pins' at the time... Slight smile

    I take it that the double via holes per pad were what you were alluding to as 'something strange' earlier in the text ? I see FlexyPins tend to use a via and a slot to allow the full spring action.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw 29 days ago in reply to beacon_dave

    I bought some, but have misplaced them. Confused They are much more expensive....Disappointed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube