Vorpal Robotics Wiki
Log in

Difference between revisions of "Vorpal Factory Paired Bluetooth Modules"

From Vorpal Robotics Wiki
Line 71: Line 71:
 
=== TRANSMITTING ARDUINO CODE ===
 
=== TRANSMITTING ARDUINO CODE ===
  
#include <SoftwareSerial.h>
+
#include <SoftwareSerial.h>
  
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
+
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
  
void setup() {   
+
void setup() {   
  Serial.begin(9600);
+
  Serial.begin(9600);
  BlueTooth.begin(38400);
+
  BlueTooth.begin(38400);
}
+
}
  
void loop() {
+
void loop() {
  BlueTooth.println("Hello!");
+
  BlueTooth.println("Hello!");
 
    
 
    
  delay(1000);
+
  delay(1000);
}
+
}
  
  
Line 90: Line 90:
 
=== RECEIVING ARDUINO CODE ===
 
=== RECEIVING ARDUINO CODE ===
  
#include <SoftwareSerial.h>
+
#include <SoftwareSerial.h>
  
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
+
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
  
void setup() {   
+
void setup() {   
  Serial.begin(9600);
+
  Serial.begin(9600);
  BlueTooth.begin(38400);
+
  BlueTooth.begin(38400);
}
+
}
  
void loop() {
+
void loop() {
  if (BlueTooth.available()) {
+
  if (BlueTooth.available()) {
      int c = BlueTooth.read();
+
      int c = BlueTooth.read();
      Serial.write(c);
+
      Serial.write(c);
  }
+
    }
}
+
}

Revision as of 00:46, 30 March 2017

Introduction

The Vorpal Factory Paired Bluetooth Modules product is available from Amazon.com. It provides you with two inexpensive Bluetooth modules that are factory configured so that they auto-pair when power is applied. There is no easier way to get a fast, reliable transparent serial connection for projects involving Arduino, Rasberry Pi, and other microcontroller products.

What's in the package

The package contains:

  • One HC05 Bluetooth module, configured as master. (The HC05 is the module with 6 pins). The module is labeled with a name such as VORPAL1234. This indentifies which slave it is configured to pair with.
  • One HC06 Bluetooth module, which is a Bluetooth slave which auto-pairs with the provided HC05 on boot. The HC06 has 4 pins. It is labeled the same as its matching HC05 master.
  • Four female-female Dupont cables, color coded, 10cm (2.5") long. These can be conveniently used to make connections for power and data to your microcontroller.

How are the modules configured?

NOTE: You don't need to fully understand this section in order to use the modules, this is provided for more advanced users.

The modules are both configured at a speed of 38,400 baud, no parity, 8 bits. The HC06 has a name which is identical to the label you will find on it, for example VORPAL1234. This name will show up if you have a device such as an Android smartphone which can detect Bluetooth devices.

The MAC address of the HC06 is preconfigured in the HC05 such that they auto-pair and connect when power is applied to both modules.

When unpaired, both modules will have a blinking red light. After pairing, the HC06 (4 pins) will have a steady light. Pairing normally only takes 5 to 10 seconds after both modules are powered on.

How fast are they?

The modules are factory configured at 38,400 baud. This means you can transmit approximately 4,000 to 4,500 bytes per second (technically 4800 per second, but there is some overhead in the Bluetooth protocol). This is plenty fast enough for robot control, remote sensor applications, etc. This will not be fast enough for some data intensive applications like camera transmissions, however.

The modules themselves can transmit faster than 38,400, however we have found there can be problems if the speed it too high. 38,400 is a good compromise, allowing enough speed for a very wide range of applications, but with high reliability.

What is the range of the radio signal?

Bluetooth is typically used for short-range applications. These modules are very reliable up to about 30 feet line-of-sight (in other words, nothing blocking the signal). When using these modules in your applications, try to put the modules such that it is not enclosed in metal or too close to large metal objects. Plastic generally doesn't reduce range much. Walls or other obstructions will also reduce the range considerably.

Can I operate multiple pairs in the same general area?

Yes, you can run many pairs of modules in the same room. Bluetooth uses a frequency hopping scheme combined with many different channels to ensure devices do not significantly interfere with each other. We have run 15 in a single room, within 30 feet of each other, with no problems at all. The maximum number is probably much higher than that. That makes these modules perfect for classroom use. You could have 15 or more groups of students using radio controlled projects in the same classroom.

Can I receive and transmit at the same time?

Absolutely! These modules provide a full duplex, transparent serial connection. That means your microcontrollers can be sending and receiving data from each other at the same time.

How do you connect the modules to Arduino or Similar Devices?

NOTE: The package includes Female-Female cables. These will work great if you're connecting either to an Arduino with an IO shield (male pins) or if you're connecting directly to an Arduino Nano, Pro Mini, or similar model which also typically provide male pins. However, if you are connecting directly to an UNO or similar model that provides female sockets, you would need a short Male-Male jumper, or just a piece of typical hookup wire, to make the connection work.

The HC06 has four pins:

  • VCC: You should connect a RED Dupont jumper cable to this and connect it to a regulated +5v power supply that can provide at least 50 to 60 milliamps of power. Do not connect this to unregulated battery power. Connecting this lead to a power supply greater than +6.0 volts will immediately destroy the module.
  • GND: Use a BLACK cable and connect this to the ground side of a power supply.
  • TXD: "Transmit Data". Use a YELLOW cable and connect this to a digital IO pin on your controller. For the Arduino examples used in this wiki page, connect it to digital pin 3, although any digital pin can typically be used.
  • RXD: "Receive Data". Use the GREEN cable and connect this to another digital IO pin. For the Arduino examples used in this wiki page, connect it to digital pin 2. Again, any digital IO pin should work.

The HC05 has six pins, but you're not going to use two of them.

  • EN: (May be different labels on some units). You're not going to use this, leave it disconnected.
  • VCC: You should connect a RED Dupont jumper cable to this and connect it to a regulated +5v power supply that can provide at least 50 to 60 milliamps of power. For example, an Arduino UNO can provide the right power from its +5V pin. Do not connect this to unregulated battery power. Connecting this lead to a power supply greater than +6.0 volts will immediately destroy the module.
  • GND: Use a BLACK cable and connect this to the ground side of a power supply.
  • TXD: "Transmit Data". Use a YELLOW cable and connect this to a digital IO pin on your controller. For the Arduino examples used in this wiki page, connect it to digital pin 3 (of course, not the same Arduino as you used for the HC06, the whole point of this is to let two different Arduinos communicate!). Again, any digital pin can typically be used.
  • RXD: "Receive Data". Use the GREEN cable and connect this to another digital IO pin. For the Arduino examples used in this wiki page, connect it to digital pin 2. Again, any digital IO pin should work.
  • STATE: (May be different label on some units.) Leave this disconnected, you don't need it for basic communications.

Once connected and power is turned on, both modules should light up. The lights will both blink at first. After about 5 to 10 seconds, the light on the HC06 will turn steady red, while the HC05 will continue to blink.

If either module will not light up at all, that's almost always due to power not being applied correctly. Disconnect power immediately and check connections again.

If the module gets hot, that probably means you reversed the VCC and GND pins. Unfortunately, this will destroy the module within a few seconds, so be very careful.

SAMPLE CODE

Here is sample code to send a message from one module to the other. This code assumes you have two Arduino modules, one will transmit and the other receive. (You can of course write code that does both from either module, this code is being kept simple as an example.)

This code uses the SoftwareSerial library, which is a standard part of the Arduino IDE. This allows you to leave the hardware serial IO line free for debugging purposes, or to allow program upload. It is perfectly ok to use digital ports 0 and 1 for the TXD and RXD lines, but that's very inconvenient because you would need to disconnect the Bluetooth module before uploading a new program!

TRANSMITTING ARDUINO CODE

#include <SoftwareSerial.h>
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
void setup() {  
  Serial.begin(9600);
  BlueTooth.begin(38400);
}
void loop() {
  BlueTooth.println("Hello!");
 
  delay(1000);
}


RECEIVING ARDUINO CODE

#include <SoftwareSerial.h>
SoftwareSerial BlueTooth(3,2);  // Tx goes to pin D3, Rx to pin D2
void setup() {  
  Serial.begin(9600);
  BlueTooth.begin(38400);
}
void loop() {
  if (BlueTooth.available()) {
      int c = BlueTooth.read();
      Serial.write(c);
   }
}