Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 8 months ago.
PAIRING TWO RN42
Hi guys,
I have just bought two RN42 chips and I am trying to pair them together using two LPC1768. Here is a list of what I've done; For Master LPC1768 + RN42 Tx pin on RN42 => pin 9 Rx pin on RN42 => pin 10 Common ground For Slave LPC1768 Tx pin on RN42 => pin 9 Rx pin on RN42 => pin 10 Common ground
I have written installed the code below from Rob and Tim's book. so far the only thing i've managed to get out of the chips is the master getting into command mode but it never connected.tried changing the pins around no joy. i've scan for both chips with an Android phone they are being found every time, guess that eliminates the antennas or any such fault. Could you please point out where I am going wrong , thank you in advances.
include the mbed library with this snippet
/* Program Example 12.4: Paired Bluetooth master program */ #include "mbed.h" Serial rn41(p9,p10); BusOut led(LED4,LED3,LED2,LED1); DigitalIn Din(p26); // digital switch input on pin 14 char x; void initialize_connection(void); void initialize_connection() { rn41.putc('$'); // Enter command mode rn41.putc('$'); // rn41.putc('$'); // wait(0.5); rn41.putc('C'); // rn41.putc(','); // Send MAC address rn41.putc('0'); // rn41.putc('C'); // rn41.putc('D'); // rn41.putc('F'); // rn41.putc('A'); // rn41.putc('4'); // rn41.putc('6'); // rn41.putc('9'); // rn41.putc('D'); // rn41.putc('2'); // rn41.putc('C'); // rn41.putc('0'); // wait(0.5); rn41.putc('-'); // Exit command mode rn41.putc('-'); // rn41.putc('-'); // rn41.putc(0x0D); // wait(0.5); } int main() { rn41.baud(115200); initialize_connection(); // wait(30); while (1) { if (Din==1) { // if digital input switched high x=0x0F; // override with 0x0F } else { x++; // else increment and if (x>0x0F) { // output count value x=0; } } rn41.putc(x); // send char data on serial led = x; // set LEDs to count in binary wait(0.5); } //Program Example 12.3: function to initialize paired Bluetooth connection with RN-41 // modules }
include the mbed library with this snippet
/* Program Example 12.2: Bluetooth serial sniffer program */ #include "mbed.h" Serial rn41(p9,p10); BusOut led(LED4,LED3,LED2,LED1); int main() { rn41.baud(115200); // setup baud rate rn41.printf("Serial sniffer: outputs received data to LEDs\n\r"); while (1) { if (rn41.readable()) { // if data available char x=rn41.getc(); // get data led=x; // output LSByte to LEDs } } }
Hi Donald, can you send a picture of your connections? and the responses you are getting?
Greetings
posted by Ney Palma 26 Sep 2014