Connecting Teensy 4.0 to HC-05 module

cheeft

Member
I am building electric drumsticks. Each stick contains a piezo impact sensor, Teensy 4.0, 3.6V NiMH battery and an HC-05 bluetooth module. These modules should send data processed by the Teensy 4.0 to a master HC-05 module connected to a Teensy 4.1. This Teensy 4.1 will handle audio processing data and convert the signal into sound output through the 3.5mm jack on the audio shield (I am aware I will likely need two separate master HC-05 modules to handle data from each stick).

I have been trying to connect my Teensy 4.0 to the first HC-05 slave module, however despite having slow blinking once every 2 seconds the serial monitor does not print responses when AT commands are entered.

My current pin setup is as follows:

HC-05 --> Teensy 4.0

GND --> GND
VCC --> 5V
RX --> TX
TX --> RX
EN --> 3.3V

Does anyone know how I can solve this? I am open to different methods entirely.
 
Its hard to tell without seeing your code, best thing to do is try a simple sketch with just bluetooth attached and test. One gotcha in the past is baudrate. The baudrate of the HC module should match what you have set for the serial port you have the HC-05 attached to.
 
Thanks! I eventually got it working using this code here.

Now I need to try and pair the two modules and allow for data communication, I will let you know how this goes.

#include <SoftwareSerial.h>

SoftwareSerial BT(0, 1); // RX (pin 0) | TX (pin 1)

void setup() {
Serial.begin(9600);
Serial.println("Enter AT commands:");
BT.begin(38400);
}

void loop() {
if (BT.available()) {
char c = BT.read();
Serial.write(c); // Display the response from HC-05
}

if (Serial.available()) {
char c = Serial.read();
BT.write(c); // Send AT commands from serial monitor to HC-05
}
}
 
Its hard to tell without seeing your code, best thing to do is try a simple sketch with just bluetooth attached and test. One gotcha in the past is baudrate. The baudrate of the HC module should match what you have set for the serial port you have the HC-05 attached to.
The modules have been paired, however the master microcontroller (Teensy 4.1) needs to be able to receive the analogue data from both drumsticks, each with their own teensy 4.0 and HC-05 module. Is it possible to create a communication network of three hc-05 modules? If not, is it possible for the master Teensy 4.1 to receive data through two separate master HC-05 modules (each paired to one of the drumsticks)?

I hope this post makes sense, I would be happy to explain my setup in further detail if necessary.
 
Is it possible to create a communication network of three hc-05 modules?

Sure. Teensy 4.0 has 7 serial ports. 5 of those are one the easy-to-access pins. Just connect the other modules to any of the other serial ports and then replicate your code for the other 2.

Ok, maybe it won't be quite the simple. You'll need to decide what you want to do with this:

Code:
if (Serial.available()) {
  char c = Serial.read();
  BT.write(c); // Send AT commands from serial monitor to HC-05
}

Maybe you would send the character to all 3 of them? Or maybe only 1, and you have some other way to select which of the 3 gets this incoming data?
 
Sounds like a nice project!

A few remarks/questions:

Why use one Teensy 4.0 for each drumstick as a trigger? Isn't that overkill? Wouldn't be an Arduino Nano or so sufficient?

What delay from the bluetooth transmission are you expecting? Is that sufficient for your purpose? Have you checked what these modules are capable of? Or if possibly a BLE capable module is necessary? And if that is fast enough?

Searching around it seems that some people were able to connect one HC-05 master to two slaves.

Have you looked into nrf24l01 modules? Possibly it has some advantages to use such systems. "Pairing" is easier and more reliable and I would expect a significantly lower latency.
 
Sounds like a nice project!

A few remarks/questions:

Why use one Teensy 4.0 for each drumstick as a trigger? Isn't that overkill? Wouldn't be an Arduino Nano or so sufficient?

What delay from the bluetooth transmission are you expecting? Is that sufficient for your purpose? Have you checked what these modules are capable of? Or if possibly a BLE capable module is necessary? And if that is fast enough?

Searching around it seems that some people were able to connect one HC-05 master to two slaves.

Have you looked into nrf24l01 modules? Possibly it has some advantages to use such systems. "Pairing" is easier and more reliable and I would expect a significantly lower latency.
Thank you very much!

Essentially, over the course of this build I have accumulated a number of different teensy modules and this seems to be the best way of using them. I have done some searching around too, however most people I have seen haven't been able to create this sort of a network... would you be able to link to a case where the HC-05 has been paired to two slaves?

In terms of latency, that is definitely a real concern. I have managed to pair two modules so far, and allow the press of a button to illuminate an LED on the master module with relatively low latency, however if the button is left un-pressed for an extended period of time this latency increases dramatically to around 10 seconds. I will certainly look into the nrf24l01 modules.
 
A google search for "hc 05 bluetooth more than one connection" gave me this:
post #5

...allow the press of a button to illuminate an LED on the master module with relatively low latency...
Is that more like 5, 10 or 100ms latency? Depending on the purpose of a project, even 10ms can be too much for an experienced drummer.
 
Amazing, thank you! It is close to a 10ms delay, however this is not targeted at experienced drummers. The purpose of this build is to test the functionality of a product which would be aimed at non-musicians who want to experience the joy of experimentation and creativity.

The nrf24l01 looks perfect for this build, I will purchase a few now.
 
The nrf24l01 looks perfect for this build, I will purchase a few now.
Please be aware that there are a lot of fake NRF24L01 modules out there. I have been troubled by cheap inferior modules so I ended up buying modules of the brand RobotDyn. Google for "NRF24L01 fake" and you won't be happy to read...

Paul
 
Back
Top