BLUETOOTH

 This page is part of my Model Remodel series of articles.

DISCLAIMER: If you choose to attempt any of these modifications, you assume all risks thereof. I just wanted to share my experiences here. Neither Fanhome, nor myself, are responsible for any damages that may occur.


While designing my Model Remodel version of my 1:900 scale U.S.S. Enterprise NCC-1701-D, I originally controlled it via an IR (Infrared) remote control. However, this still left me without the ability to separate the Saucer and Battle sections as they needed to be wired together. I looked into alternatives and decided I would try and see if I could get a basic Bluetooth (BT) connection setup between the two sections. This led me down a long and crazy road of configurations and endless possibilities. Here is how we got there…


The Bluetooth Transceivers

While there are Arduinos with Bluetooth built-in, the most common external devices are the HC-05 and HM-10 transceivers. I used the inexpensive encased versions from DSD Tech of the HC-05 (x2) and HM-10 (x1) in my build:

The main operational difference between these two devices is while the HC-05 uses standard Bluetooth v2.0, the HM-10 supports Bluetooth v4.0 Low Energy (BLE). As I wanted to control my model with my mobile phone, we need the HM-10 capabilities required by newer phones/tablets. However, the communication between the Battle Section/Saucer is simple and close range, so we can use the HC-05 for this.


Connecting these BT Devices to Arduino

In order to program our BT devices, we have to get them connected to an Arduino. In these examples, it is showing a Nano but any Arduino should work the same way.

NOTE: The way these are connected for programming is the exact same way they are wired up inside the model. Therefore, even if they are already installed, they can still be setup using the connected Arduino. However, you may have to adjust the pin numbers used for RX/TX in the sketches below.

The HC-05s

The HC-05 modules have 6 pins, but we only need to connect the middle four pins. Here are the pins and a basic initial connection diagram:

In this example, the following connections are made:

  • BT VCC (power in) connects to +3.3 to 6VDC. I typically just connect this to the 5V pin of the Arduino.
  • BT GND (ground) connects to common ground. I typically just connect this to a GND pin of the Arduino.
  • BT TX (transmit) connects to a digital pin of the Arduino. In the diagram, it is connected to pin D2 (Digital 2).
  • BT RX (receive) connects to a second digital pin of the Arduino. In the diagram above, it is connected to pin D3 (Digital 3) via a voltage divider. A voltage divider is needed because the BT device expects 3.3V here and the Arduino outputs 5V. We can do this by using 1KΩ and 2KΩ resistors as shown.

The HM-10

The HM-10 only has 4 pins and we will connect these in the exact same way as the HC-05. This diagram shows a basic initial connection diagram – this is exactly how I like to connect my BT devices (directly to the Arduino as I said above):


Configuration

Both of these devices come with a default configuration that will need to be updated in order to use them properly. In order to configure these, we need to put them into ‘AT programming mode’. AT is a type of serial command standard harking back the the early days of digital telephonic communication – it is short for ‘ATtention’. If you are old enough to remember dial-up modems, you might remember this!

HC-05 Settings

To put the HC-05 into AT mode, hold the small EN button while it is powered up. If the LED on the module blinks once every 2s, we are good. Then, simply upload this sketch to your Arduino (this sketch assumes you used the Arduino’s digital pins D2 and D3 shown above). Here, we will use the SoftwareSerial.h library to control the BT module via a virtual serial connection using those pins:

Once programming has completed, leave the Arduino connected to your computer. Then, open your Serial Monitor window within your Arudino IDE (I use the online Cloud Editor) and update the following settings – your settings location might be slightly different:

  • Newline setting should be set to ‘Both NL and CR
  • Communication Rate should be set to ‘9600 baud’

Type the command AT into the Serial Monitor and hit Enter. The BT module should respond with ‘OK’:

We need to configure two HC-05 modules, one with the ‘primary’ role and one with the ‘secondary’ role. The primary module will live in the Saucer Section of our model and the secondary module will reside in our Battle Section. I began with the secondary HC-05 as it has a simpler setup – I recommend putting a label on these modules so you know which one is which.

TIP: Remember to push the EN button on power up to put these modules in AT mode!

Secondary HC-05 (Battle Section)

By default, a HC-05 module defaults to the secondary role which means it will passively listen for new connections. We want this functionality in our Battle Section because the Saucer Section can be disconnected during a separation event and I wanted the primary module in the Saucer to actively re-initiate the BT connection once power is restored. To confirm this role setting, we can send the AT+ROLE? query command to our connected secondary module in the Serial Monitor. The BT module should respond with ‘+ROLE:0’ and ‘OK’:

We will also need the unique MAC address of this module, so send the AT+ADDR? command and write down this response value (in the example below, this HC-05 has a MAC address of 14:3:508a2. This is all we need to do to configure the secondary module:

Primary HC-05 (Saucer Section)

Moving on to the second HC-05 module, we need to configure it a bit differently. To do this, we first need to update the ROLE setting. Simply send the command AT+ROLE=1 via the Serial Monitor to change this setting. This setting will tell the module to actively look for a new connection. If it succeeds, the module will answer with ‘OK’:

We can verify this change by sending the AT+ROLE? query command:

Next, we need to change the ‘connection mode’ of this primary HC-05 to only connect to a specific remote MAC address. We do this by sending it the AT+CMODE=0 command:

We can verify this change by sending the AT+CMODE? query command:

Then, we tell this HC-05 which specific remote MAC address to connect to. Using the address of the secondary module we wrote down earlier, we can send the command AT+BIND=xxxx,xxxx,xxxx (replacing the Xs with the MAC) to this primary module.

NOTE: With this command, we need to replace the commas with colons – use the MAC address of your device as this just is my example:

That completes the configuration of our two HC-05 modules. If we now power up both modules (without activating AT mode), they should automatically pair with each other. We can check this by looking for the tiny red LED on each device. They should blink once every 2 seconds indicating that they have successfully connected to each other. A quick blinking LED on the device means it is not paired with any other device – I recommend rechecking the configuration steps I have provided above.

HM-10 Settings

Since a HM-10 is already set to listen for new connections by default, all we really need to do is give it a proper name so we can identify the right device to connect to with our remote control application. I wrote up a simple sketch we can use that will automatically configure our connected HM-10 to have the name ‘ENTERPRISE-D’. Simply wire up your HM-10 as shown above and upload the sketch – that’s it:

If we open the Serial Monitor while this Arduino is still connected, we can see the sketch setting the device name over and over again. You may have to set the line ending option to ‘Newline’ here. Once you see this, we have finished programming the HM-10!


Installation

These Bluetooth modules can now be installed and wired into the model. See these pages for more information:


Next Up

The Mobile App – Creating an LCARS interface to control our model