RN4870 Click Board
RN4870 Click Board
The RN4870 Click Board™ carries the RN4870 Bluetooth® 4.2 low energy module from Microchip.
The click is designed to run on a 3.3V power supply. It uses ASCII Command Interface over UART for communication with target microcontroller, with additional functionality provided by the following pins on the mikroBUS™ line: PWM, INT, RST, CS.
Software Support
Code examples for the RN4870 Click Board™, written for MikroElektronika hardware and compilers are available on Libstock.
Code Snippet
The following code snippet shows send function for the RN4870 Click Board™. If the message type is correct, it will establish connection with the device specified by the address in the parameter and then send the properly formatted data.
01 #define BTCMD( TXT ) UART2_Write_Text( TXT ) 02 void RN4xxx_send(char *pAddr, T_RN4xxx_message msgData ) 03 { 04 static char msgTxt [255]; 05 06 if (msgData.msgType == 'Q') 07 { 08 /*Connects to a device with specified adress*/ 09 BTCMD("C,1,"); 10 BTCMD (pAddr); 11 BTCMD("r"); 12 Delay_ms(3000); 13 /*Secures the connection, entering data stream mode*/ 14 BTCMD("Br"); 15 Delay_ms(3000); 16 } 17 /*Sentence construction */ 18 msgTxt[0] = '#'; 19 msgTxt[1] = msgData.msgType; 20 msgTxt[2] = ','; 21 msgTxt[3] = msgData.dataType/0x100; 22 msgTxt[4] = msgData.dataType%0x100; 23 msgTxt[5] = ','; 24 msgTxt[6] = msgData.id; 25 msgTxt[7] = ','; 26 msgTxt[8] = ''; 27 strcat (msgTxt, msgData.payload); 28 strcat (msgTxt, "*rn"); 29 30 BTCMD ( msgTxt ); 31 32 if (msgData.msgType == 'Q') 33 { 34 Delay_ms(3000); 35 /*Enters CMD mode*/ 36 BTCMD("$"); 37 Delay_ms(100); 38 BTCMD("$$$"); 39 Delay_ms(1000); 40 /*Kills connection*/ 41 BTCMD("K,1r"); 42 Delay_ms(500); 43 } 44 }
RN4870 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.