RN42
We’ll use the RN42 Bluetooth module here, the code needed to implement it is described below :

Load this piece of code into the Teensy in order to be able to communicate with the RN42 by using a serial communication (through the UART3):


		const int baudrate = 57600;

		void setup()
		{
			Serial.begin(baudrate);
			Serial3.begin(baudrate);
		}

		void loop()
		{
			if (Serial.available() > 0)
				Serial3.write(Serial.read());
			if (Serial3.available() > 0)
				Serial.write(Serial.read());
		}

Then open a serial monitor. You can use the one provided by the Arduino IDE or another one (CuteCom is a good choice). The serial device associated with the Teensy depends on the OS: COM* on Windows, /dev/tty* on Linux.

First, input $$$ with no new line or carriage return to enter command mode. The module should print CMD in the serial monitor. After this setup, every command should be issued with a new line.

To display the current settings, use the D command. the most obvious setting you might want to change is the name. To do so, send the command SN,MyName. The RN42 should reply with AOK if everything went well. If you ever do anything wrong and want to revert the changes, you can reset everything with the command SF,1.

For a comprehensive list of the available commands and some explaination, have a look at this documentation.

Back Next

RN42 Bluetooth Module
Tagged on:     

2 thoughts on “RN42 Bluetooth Module

Leave a Reply