1
\$\begingroup\$

I'm trying to get my bluetooth module into command mode. I have pin 0(RX) on the Uno connected to the UART_TX pin on the bluetooth module, and pin 1(TX) on the Uno connected to the UART_RX pin on the bluetooth module.

Heres the sketch thats running on the Uno.

int incomingByte = 0; // for incoming serial data
void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
 Serial.flush();
 //enter command mode
 Serial.println("$$$");
}
void loop() {
 // send data only when you receive data:
 if (Serial.available() > 0) {
 //read the incoming byte:
 incomingByte = Serial.read();
 //say what you got:
 Serial.print("I received: ");
 Serial.println(incomingByte, DEC);
 }
}

This is what I see on the Serial Monitor

$$$

I expected to see

$$$
I received: C
I received: M
I received: D

What am I doing wrong? Or if its not supposed to do what I expected, what am I not understanding correctly?

Leon Heller
39.3k2 gold badges64 silver badges96 bronze badges
asked Apr 9, 2011 at 15:27
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I think the problem you're having is that you can't both talk to a device on the UART and talk to a terminal (your computer) at the same time using the same pins (0 and 1) of the Arduino. If you want to talk to your computer as well as a device you have to use a SoftSerial library (or NewSoftSerial) and wire the device to use different pins rather than the hardware UART...

(削除) That being said, it seems plausible that the bluetooth module is prompting your for a command with the message "CMD". (削除ここまで) (misread question, this was what you expected, not what actually happened)

answered Apr 10, 2011 at 4:33
\$\endgroup\$
1
  • \$\begingroup\$ Ah, I think I remember running across someone mentioning that elsewhere, \$\endgroup\$ Commented Apr 10, 2011 at 15:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.