Hey!
I’ve got a Bluetooth mate silver hooked up to an arduino, with the following code:
/*
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
// 115200 can be too fast at times for NewSoftSerial to relay the data reliably
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop()
{
if(bluetooth.available()) // If the bluetooth sent any characters
{
// Send any characters the bluetooth prints to the serial monitor
Serial.print((char)bluetooth.read());
}
if(Serial.available()) // If stuff was typed in the serial monitor
{
// Send any characters the Serial monitor prints to the bluetooth
bluetooth.print((char)Serial.read());
}
// and loop forever and ever!
}
which, to some degree, has worked fine, I’ve been able to set it as master, change baud rate, change pin and the whole shabang, but I can’t seem to connect to it properly, or connect it to other bluetooth modules. That is, it shows up on my computer, and it claims it’s connected, but I’m not able to upload any new script to the Arduino via the connection.
Connecting it to other modules also proves difficult; The inquiry returns all the devices in the area, but it won’t connect for some reason.
I’ve never really worked with bluetooth, which makes troubleshooting fairly hard, but I’ve tried setting both modules to the same baud rate, tried both with and without a pin code, but it seems to react the same way no matter what. I did manage to connect it to the Adafruit EZ-Link board. That is, the bluetooth mate’s connect LED lit up, but there was no real connection recognised by the EZ-Link. I’ve also tried the HC-06 modules, but nothing seems to take. Any ideas or tips?