-
Notifications
You must be signed in to change notification settings - Fork 23
Bluetooth Setup Guide
Sam Olds edited this page Nov 4, 2015
·
2 revisions
Following this guide will get a BlueSMiRF Silver or BlueSMiRF Gold configured and working with the Ardusat Hardware.
-
Upload the following passthrough sketch to an Arduino
/* 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 /* have to do this all manually :( can't make it reliably work bluetooth.println("ST,0"); // No Configuration timer bluetooth.println("S~,0"); // Set to SPP bluetooth.println("SN,Ardusat"); // Sets name bluetooth.println("S-,Ardusat"); // Sets friendly name bluetooth.println("SA,2"); // Set no pincode bluetooth.println("SU,96"); // Change baudrate to 9600 bluetooth.println("---"); // Turn off command mode */ bluetooth.begin(9600); // Start bluetooth serial at 9600 } void loop() { if(bluetooth.available()) { Serial.print((char)bluetooth.read()); } if(Serial.available()) { bluetooth.print((char)Serial.read()); } }
-
Connect the TX and RX pins of the bluetooth module to the Arduino, as well as ground and power by following this guide.
-
Issue the following series of AT Commands through the serial monitor:
Command Description $$$
(without a newline) Enter command mode SF,1
Factory Reset R,1
Reboot Wait for module to reset. Close Serial monitor and reopen it.
Command Description $$$
(without a newline) Enter command mode ST,0
No Configuration timer S~,0
Set to SPP SN,Ardusat
Sets name S-,Ardusat
Sets friendly name SA,2
Set no pincode SU,96
Change baudrate to 9600 ---
Leave command mode
- The BlueSMiRF seems to work more consistently when using 5v instead of just 3.3v.
- Sometimes, if it starts acting quirky, just turning it off and back on again fixes any problems.
- It is unlikely you will have this problem, but you must allow the bluetooth module to restart between uploading sketches to the Arduino multiple times with different baud rates. If you change the baud rate and upload the sketch, then change the baud rate again and upload the new sketch, only the first baud rate will take affect. You must turn the bluetooth module off in between changing the baud rate more than once.