In a last couple of months(since I've been working on this project) I'm running into a strange issue with one HC05. The BT module is connected to an Arduino Nano via it's hardware serial port (pins 0 & 1) at a baud rate of 9600bps.
The Nano is fully capable of sending data out through the BT module, but when it comes to receiving... Nothing, not a singe bit. The strange part is that the RX led on the Nano flashes each time I try to send data TO the Nano, meaning that the BT module is connected properly, but the Nano doesn't seem to register the data coming in.
The serial over the USB cable works as intended( In & Out)
Any help would be greatly appreciated,
Thanks in advance Rista.
P.S. the RX and TX pins are filpped on the diagram.
I remember being able to connect BT modules like this in the past, also the module works fine when connected to Software Serial(pins 2 & 3), this leads me to believe that the module itself is not defective.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
I think I've got a solution and it's got to do with a fact there is a pull-up resistor/LED on the RX(0) pin on the Nano pulling up the voltage too high and the HC05 having an internal resistance on it's TX pin.
I will measure this tomorrow to see if my suspicion is confirmed.
You've got it. I like your theory about the leds on tx/rx inputs. I think the circuit is dependent upon the specific usb/ttl converter used on the Nano. Do you know which converter you have? The schematic you linked is for the CH340.
As I've theorised in the previous post the LED was pulling the RX line high, but that was not the only culprit of the story.
On the first image below you can see the RX voltage when data is sent over USB(CH340).
On the second image below you can see the RX voltage when data is sent over HC05.
There is a stark difference, following the fact that by the datasheet atmega328p needs at least 1.5V for a logic level to be considered low.
Image after that shows:
The simpified schematic of the problem(SCH1),
The way internal resistance of HC05 was measured (SCH2)
The implemented solution(SCH3)
The measured internal Resistance is 184Ω with a 1K load, but is getting worse as load increases.
The implemented solution is adding a 330Ω pull-down resistor to the RX pin(TX pin of HC05), the issue with this is that the resistor value needs to be very precise and may vary from case to case because it's pulling the logical HIGH also lower than initially which can interfere with code upload(this did happen to me), removing of the RX LED and/or it's resistor did improve the situation but is not required(not easy if you are a beginner - requires desoldering tiny SMD components).
Other solution could be increasing the CH340 RX Resistor value and removing the RX LED but that may very well interfere with code upload.
Last and easiest, if you have free space add a fast buffer circuit(Non-inverting schmitt trigger, simple buffer IC...) to increase signal strength, but you may need to add a series resistor to not interfere with code upload (again...).
All and all this was quite a task which took entirely too long too figure out.
I'm gonna leave this post open for any questions and sincerely hope this post saves somebody a headache.