while (BT.available())

Good moning

I have two different bluetooth modules, with the same code, one of them cannot read anything that I write, and BT.available always returns 0.

Can anybody help me?

Thanks

icuevas:
Can anybody help me?

Sure. Start here

We can just take guesses at the code and at the hardware and at the wiring and at the Arduino. Sure.

@icuevas: I have now deleted two near-identical copies of this topic.

Do NOT make it three.

Post your responses here.

As I have seen that you did’nt understant me, here you have the code:

#include <SoftwareSerial.h>

/* This is a simple test for two way traffic via bluetooth
but you can try it first using the USB cable to the serial
monitor without the bluetooth module connected.

Note that some bluetooth modules come set to a different baud rate.
This means you need to alter the command
Serial.begin(9600) accordingly
Same goes for the setting in the bottom right corner on the
serial monitor */

SoftwareSerial BT(10, 11); // Pin 10 → RX, Pin 11 → TX
String readString;
char c;
void setup()
{
pinMode(0, INPUT_PULLUP);// only needed for JY-MCUY v1.06?
BT.begin(9600);
Serial.begin(9600);
BT.println(“OK then, you first, say something…”);
BT.println(“Go on, type something in the space above”);
BT.println(" and hit Send or Enter,");
BT.println(“then I will repeat it!”);
BT.println("");
}

void loop() {
BT.println(BT.available());
delay(5);
BT.println(“OOOOOK then, you first, say something…”);

while (BT.available())
{
// Serial.println(“OK then, you first, say something…”);
BT.println(“OOOOOK2222 then, you first, say something…”);
delay(5);
c = BT.read();
readString += c;
}// end while
if (readString.length()>0)
{
BT.write(c);
readString="";
} // end if
}

It is clear that you haven't understood me.
Start here

I'm not on the right section? I think it is a programming problem.

 BT.println(BT.available());

Why the Hell are you telling the BT device (hint: whatever it is) how many characters it has sent you?

icuevas:
I'm not on the right section? I think it is a programming problem.

Maybe it is. Maybe it is a networking question.
Have you thought about telling us more about your hardware?

icuevas:
Good moning

I have two different bluetooth modules, with the same code, one of them cannot read anything that I write, and BT.available always returns 0.

Can anybody help me?

Thanks

so the other one works as expected with the code you posted ? if so do they use the same BAUD rate ?

Thank you to answer. It is the same if I try sending one character or more. It always writes 0.

About the hardware...I use an Arduino UNO. I connect the RXD from the module Bluetooth to the pin 11
I connect the TXD from the module Bluetooth to the pin 10. The GND from the module Bluetooth to the pin GND on the Arduino and GND to 5 V. The Bluetooth is an HC06.

Yes, I think they use the same BAUD rate, if the code puts "BT.begin(9600)", they are using the same, isn't it?

the module Bluetooth

Which Bluetooth module?

HC-06 (ZS-040)

Thanks

so you have 2 the same units and neither of them work ? if (BT,available()==0) that means nothing has been received by the arduino. so maybe the BT-unit never send anything (maybe because it didn’t receive anything)
for starters your BAUD rate is wrong

BT.begin(9600);

it should be 34800, that is pushing it using SoftSerial, but it should still work, you may need to switch to altSoftSerial but even then your device will not respond most probably because you never send it anything it could make any sense out of. Have a look at this tutorial about hc 05/06 at-commands, if you keep having difficulties you could simplify matters by making your uno act as a USB-TTL converter by uploading an empty sketch (or blink basically any sketch that does not use or address the Serial port will be fine, i have a blink with oscilating speed for the purpose so i can see that it is not actively using the port) and enter AT-commands as i the tutorial.

Thank you

I have two different units bluetooth, the one that (I think) that wors is a HC06 keyestudio.

I will try the tutorial you say it and I will tell you if I have some problem.