Question

I want to send some commands to my RN41 Bluetooth Module connecting to Arduino Leonardo over the serial port using serial monitor, as the tutorial shows. But it does not respond. I can connect to the bluetooth modul and the status LED blinks right. I tried to send $$$ to change to command mode, and the blink rate does change to 10/sec, but module responds nothing. And when I send '---', the blink rate back to normal. I think it means the connection is successful but I just cannot see anything at serial monitor.

I set monitor's baud to 9600, as exactly the tutorial shows. (https://learn.sparkfun.com/tutorials/using-the-bluesmirf/example-code-using-command-mode)

Do you guys know what could be wrong? Code attached:

/*
  Example Bluetooth Serial Passthrough Sketch
 by: Jim Lindblom
 SparkFun Electronics
 date: February 26, 2013
 license: Public domain

 This example sketch converts an RN-42 bluetooth module to
 communicate at 9600 bps (from 115200), and passes any serial
 data between Serial Monitor and bluetooth module.
 */
#include <SoftwareSerial.h>  

int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps

  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  bluetooth.print("$");  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");  // Enter command mode
  delay(100);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);  // Start bluetooth serial at 9600
}

void loop()
{
  if(bluetooth.available())  // If the bluetooth sent any characters
  {
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());  
  }
  if(Serial.available())  // If stuff was typed in the serial monitor
  {
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
  }
  // and loop forever and ever!
}
Was it helpful?

Solution 2

Yes, send only 3 characters, "$$$". I was also stuck for a bit. I also found that reading the Mate response "CMD" is necessary, which is not shown in the published sketch.

OTHER TIPS

I was stuck on very simple case: To enter command mode you have to send $$$ without any CR/LF. after you entered command mode you have to send commands, and every command has to be followed by CR LF. if not - module will not response. Hope that helps.

I've got some brandnew RN41VX modules. I connect them by a XBEE Explorer USB module (almost same as RN41 EVAL Kit) to computer. Using a terminal with 115 kbaud I send $$$ (without any trailing chars as 0x0d) to get into command mode. The LED switches to 10Hz blinhking - all fine. But no respone appears in terminal.

Solution: I had to switch on RTS Signal, even if manual tells "Flow Control: none"

kind regards Volker

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top