I was able to get the Arduino to talk to the RN-42! What was really needed was to reduce the baud rate on the module from 115200 to 9600 and short the RTS&CTS pins. To do this I had to do the following:
- Connect the module to a female RS232 and connect the cable to a computer.
- Open Putty (or any form of Hyperterminal).
- Select the port that the cable is connected to and type 115200 for the speed.
- At this point the user should be able to type in the commands to access the command mode by entering "$$$", and after changing the baud rate all that is needed to exit is "---".
By doing this I was able to properly communicate with the Arduino and develop this sample code:
/* Created 03/01/2013
Jordan Shelter
Bluetooth Adapter Test
Background:
This is sketch is based on the software serial example.
Hardware:
- Roving Networks RN42-SM
- Arduino Nano 3.0
The circuit:
* RX(18) is digital pin 10
* TX(19) is digital pin 11
* RTS & CTS shorted on RN42
Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
Not all pins on the Leonardo support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // 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 Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() // run over and over
{
mySerial.write("Fred was here");
mySerial.write(13);
mySerial.write(10);
delay(1000);
while (mySerial.available()!=0)
{
Serial.write(mySerial.read());
delay(100);
}
}