I have two Bluetooth modules - one is the" JY-MCU HC06" (1) and the other is a "Hossen HC06" (2). Both modules transmit information perfectly to my Android device, but I am having trouble getting (2) to receive information without the use of SoftwareSerial. My sketch is as follows, on the Arduino UNO:
I'm just printing out the bytes of the message for both SoftwareSerial and Serial. With module 1, I can receive on both SoftwareSerial and Serial perfectly.
With module 2, I can only receive with SoftwareSerial. For some reason I get nothing in regular Serial. Any tips or suggestions? Thanks in advance!
(Other notes: I've set the baud rates for both modules to 9600 via the command "AT+BAUD4". If I connect module 1's tx pin to Serial and SoftwareSerial rx, I get the messages fine. If I connect module 2's tx pin to Serial and SoftwareSerial rx, nothing shows up -- not even for SoftwareSerial, which works by itself)
Unfortunately I'm at work so I won't be able to post an actual wiring diagram until later, but here is a written description (all wires are going from the module to the Arduino board):
Both Modules:
VCC --> 3.3V
GND --> GND
TXD --> Pin 0 RX (for Serial, for SoftwareSerial Pin 10)
RXD --> Pin 1 TX (for Serial, for SoftwareSerial Pin 4)
With module 2, I can only receive with SoftwareSerial. For some reason I get nothing in regular Serial.
With the posted sketch you're not printing out on both channels but only on the HardwareSerial interface, so the SoftwareSerial setup won't work at all. Either there's something wrong with the wiring description or the sketch is not the one you tested with.
And that sketch does blink if the modules TX pin is connected to pin 10 on the Arduino but it doesn't blink if it's connected to pin 0? If that's the case I would connect my scope and see how the signals look like.
How sharp is the signal, how steep the edges, what's the signal level, does it have spikes and the like. Is the timing correct or are there stretches that shouldn't be, etc. The hardware serial tries to adapt if the signal doesn't have the correct speed (within some limits) while the SoftwareSerial just reads in defined time periods.
Are the characters read by SoftwareSerial correct (the ones sent)? Or do you just look if something is transmitted?
The characeters read by SoftwareSerial are correct (I have checked them).
I don't see how these things you are telling me to look for on the oscilloscope would matter. Why would the steepness of the edges, or 'sharpness' of the signal matter if the correct information is being interpreted by the SoftwareSerial connection? Also, in terms of timing, in the case you are talking about wouldn't some of the information still be being received by the hardware serial, just not the correct information?
Thanks for the help so far by the way. Also, do you have the documentation you read for the differences in hardware and software serial?
Also, in terms of timing, in the case you are talking about wouldn't some of the information still be being received by the hardware serial, just not the correct information?
That would be my expectation too but I often see the reason for such a behavior in the scope output although I don't know what to look for before I do it.
Also, do you have the documentation you read for the differences in hardware and software serial?
Yes, you do also: it's the source code, which is part of the IDE (HardwareSerial.cpp and SoftwareSerial.cpp). I use no other documentation because that's what counts in the end, the code that is executed. For the hardware serial interface you might also need the datasheet of the ATmega328p processor.