Jan 15, 2012

Arduino Bluetooth Link


In a previous Arduino project, I used the BlueSmirf Bluetooth Breakout Board to communicate with my Android phone. There was absolutely no special code on the Arduino to handle Bluetooth since, by default, the BlueSmirf is set as Slave and will accept any connection call. The phone app was doing all the work.

The next logical step was to use the BlueSmirf interface by programming the Arduino. Using a second Bluetooth board, I decided to create a link between two autonomous Arduinos. To make things interesting, I've set a couple of rules for the project. I wanted to heave the same code on both Arduinos and have the whole connection process be automatic. I also wanted the Master device to scan for other devices, retrieve the MAC address, connect and send data.  Here's the video of the final result:



My biggest issue started with the Sparkfun proto shield for Arduino. It has a built-in socket for their Bluesmirf device. Nice marketing move! This socket is hardwired to use the Arduino pins 0 and 1 for communications. It all looks good until you need to use it in the real world. Here are the pros and cons:

Pros:

  • No wiring needed to connect the Bluesmirf board.
  • No extra library needed to do serial communications.

Cons:

  • You must remove the Bluesmirf breakout board every time you need to plug the Arduino board in the computer. Why? Because of the hardwired Bluesmirf socket the Arduino board communications are mixed with the Bluesmirf interface.
  • Another consequence of the previous problem: You can't used the USB serial output to the computer to send debug info. That is really annoying when debugging your project.
  • The power is always ON for the Bluesmirf.

I'll fix this by using different pins for the Bluetooth communication using the NewSoftSerial library. I will also modify the Sparkfun Bluesmirf socket to use any communication pins and to have control on the power usage.

For more details continue reading after the break. (Warning! Geeky stuff about code and electronics)




Tips about BlueSmirf interface
  1. Read the User Manual
  2. Serial speed: By default, BlueSmirf is set to 115200 so you need to call Serial.begin(115200); before sending the first command.
  3. The “$$$” command is the only one that is not followed by a carriage return. Why? To complicate things of course. Use print() for the “$$$” command and println() for all other commands.
  4. Read and validate all the responses that are sent back.
  5. Wait 100ms delay after each command you send and before trying to read the response. This will give Bluesmirf the time to process the command.
  6. Don't forget to exit the command mode (using “---”). Some commands are not effective until you have exited the command mode (e.g. MS command).

A simple test
A quick way to get two Arduino+Bluesmirf connected is by hard-coding the Slave's MAC address into the Master connection command. With this there's no need for code in the loop() function. In the following example, the MAC address of the Slave Bluesmirf is 000666123ABC. The example also assumes that the RX and TX are connected to pins 0 and 1. Here's the code for both Master ans Slave:


To test, start the Slave 5 seconds before the Master. The 'Connect' lights on both Bluesmirfs will turn green when the connection is open.

Instructable
After many questions about this project, I finally decided to make an Instructables about it.


88 comments:

  1. I hope I understand this corectly, and it would help me greatly if I am, so tell me if I'm right.

    by running the master and slave code on two separate BlueSmirf Gold modules I can then just replace a wired serial connection with those modules without editing the rest of my code?

    Sincerely,
    Anton Stamhuis.
    (Anton[at]fullformfreedom[dot]cc

    ReplyDelete
    Replies
    1. I just went ahead and tested it, and it seems I was right. :)

      one thing though, the "MS" that you have in your code there should be "SM"

      greetings,
      Anton Stamhuis

      Delete
    2. Thanks for catching this mistake! I'm glad this could help.

      Delete
    3. no problem, and yeah, I mostly just didn't know where to start. but I got it figured out now, so thank you for that. ^^

      one more thing I ran into, I was getting a few errors after I copied the code from your blog, figured out it was a problem with the quotation marks. just had to take them out and replace them.

      Tomorrow I shall do some wiring and get my project back up and running. :3

      thanks again.

      ~anton

      Delete
  2. Cool. I'll follow that on Twitter. If you have any other problems, I can probably help since I have 2-3 projects using Bluetooth.

    I'm not sure about the quotation marks. They might have been modified during the copy-paste.

    This is an ultra simplified version of the code I'm running. If you need more help I can send you my whole project code to make things easier.

    ReplyDelete
  3. Very cool! But what exactly do those commands mean? Serial.print(“$$$”) // Command Mode?
    Serial.println(“SM,1”); // Maybe setting it to receive?
    Serial.println(“C,000666123ABC”); //Connect to that Address?
    Serial.println(“---”); //Just for kicks?

    Thanks For the help!

    ReplyDelete
  4. For those specific commands:
    $$$ : is to set the device in command mode
    SM, : is to set the the device mode
    C,[address] : is to connect to a specific address
    --- : is to exit the command mode

    I explain some in the post but, for the best reference, I have a link to the User Manual where all the commands are defined.

    ReplyDelete
  5. could u show us how to make that?

    ReplyDelete
    Replies
    1. I have made an Instrucable about it. http://www.instructables.com/id/BlueTooth-Link-with-auto-detect-connect/

      Delete
  6. After a short battle with the Blogger "WYSIWYG" editor I finally have fixed my bad quotes characters in the print statements.

    ReplyDelete
  7. Is it possible to connect more than one bluetooth device to the arduino and log data? Lets say I had 4 arduinos and 3 of them want to connect to the 4th arduino, will there be a problem?

    ReplyDelete
    Replies
    1. Yes you can connect more than one Bluetooth device on a single Arduino by using ‘SoftwareSerial Library’ and opening a different serial connection for each device. The down side of this approach is that your 4th Arduino would need 3 bluetooth devices ($$$).
      On the other hand, it looks like a single Bluetooth device could manage multiple connections but I haven’t tried that yet.

      Delete
    2. Thank you, I appreciate your quick response. I will let you know how it goes.

      Delete
    3. Dear Phillipe, thanks for your useful response which solved my question as well. Is there any other solution rather than what you said?

      Delete
    4. I'm happy to be helping. Some bluetooth device can support a multiple connection called piconet where 1 master can connect to up to 7 slave devices. I have not try this yet.

      Delete
  8. About multiple connections: So far I could only find one Bluetooth SMD Module that can support multiple connection (Piconet <7>). It's the Rayson BTM-182. I'll try to get one and start working on a Bluetooth swarm network.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. @Dwin I had to remove the comment since it contained a link to a .rar file. This is unsafe so please use standard URL links pointing to safe HTML content.

      Delete
    2. I'm sorry about it sir my bad.
      I just like to ask if this product can be use as an alternative to Blue Smirf that you use for interfacing your Arduino RObots. We will interface it to mindwave mobile controller of neurosky

      btw sir here is the link of the product :
      http://www.e-gizmo.com/KIT/BLUETOOTH%20SHIELD.html

      Delete
    3. With a quick read through the manuals (link at the end) it is clear that all the necessary functions are present to make a similar-type of link.
      I say 'similar' because if you use some 'Slave Only' modules (EGBT-04S), you won't be able to run the same code on those. So, I would suggest using only the Master-Slave modules (EGBT-045MS) which will resemble the BlueSmirf behavior.

      Link to the manual (link is in on the left): http://www.e-gizmo.com/KIT/egbt-04.htm

      Delete
    4. Thank you for your quick reply sir!
      your blog is really a great help :)
      Godbless!

      Delete
  10. Hi Phillipe,

    I owuld like to create multiple game devices with 1 joystick + 4 buttons + 1 rumble.

    In first, can I establish a communication in both sides : gamepad <-> PC with 2 BT devices ?

    Moreover, have you test the "Rayson BTM-182" to use only one BT device and listen all gamepad devices ?

    Thx, Gilles

    ReplyDelete
    Replies
    1. Sadly I haven't tested it yet but I'm planning to get one soon. It supports up to 7 connections (with piconet) and I'd like to build an easy to use networking API for it.

      Are you having trouble using this device?

      Delete
    2. I'm still waiting for it. I should receive it in one or two weeks :/
      (it seams that it's no more produced) ... do you know another kind of this device ; that could connect with multiple slaves ?

      Delete
    3. There's the "BT44-191S Bluetooth Class 2" that you can find at zbaus.com. You can find more by google'ing "bluetooth module supporting piconet". Be careful because there's a lot of Chinese knockoffs on the market.

      Delete
  11. Hi Phillipe,

    I'm starting a new project and I want to connect two arduinos via bluetooth to control some relays(the relays are located at the slave).
    The bt modules I buy are: http://i.ebayimg.com/t/Wireless-Serial-4-Pin-Bluetooth-RF-Transceiver-Module-with-Backplane-RS232-New-/00/s/ODAwWDgwMA==/$%28KGrHqF,!oMFC3OZgs2LBQzq4jts7Q~~60_12.JPG
    The connections I made are ok, Vcc->arduino3.3V GND->arduinoGND TXD->RXD RXD->TXD
    Do I need switches to define master and slave or the software does it?

    Thank you in advance
    Steve

    ReplyDelete
    Replies
    1. This module can be interfaced using AT commands. If by default they are in Slave mode (like bluesmirf) then you will have to set one to be the Master, using AT commands (AT+ROLE=1).
      Google this "jy mcu bt board commands" and/or this "bluetooth at commands" and you'll find many documentation and examples of how to use basic AT commands for this device.
      Let me know how it turns out.

      Delete
  12. Thank you for your quick answer.
    I check it on google but I can't understand if I need a serial connection between bt module and my pc to define master and slave or I can do this with arduino and his software?
    Sorry for my ignorance this is the first time I get involved with bt and arduino.
    Steve

    ReplyDelete
    Replies
    1. Connect the Arduino pin0 (Rx) to BTmodule Tx and Arduino pin1 (Tx) to BTmodule Rx. Connect power and ground wires to the BTmodule. Then try something like this in your Arduino sketch:

      //Set the serial with the right baud rate for JY-MCU
      Serial.begin(38400);

      //Test the communications
      Serial.println("AT");
      //Here you can add a loop/function to read the output that should be "OK"

      //Set as master
      Serial.println("AT+ROLE=1");

      Delete
    2. Follow up: This my last answer help? Keep me updated, I'd like to know how it turned out.

      Delete
    3. Hello again Phillipe,

      I took 'SoftwareSerialExample' from arduino 1.0.1 examples and changed a little.I don't know if the code is right..

      #include
      SoftwareSerial mySerial(2, 3);
      void setup(){Serial.begin(38400);Serial.println("Goodnight moon!");mySerial.println("Hello, world?");}
      void loop(){Serial.println("AT+ROLE=1");}

      The compiler says,done uploading but I have an error:
      avrdude: stk500_getsync(): not in sync: resp=0x00

      Steve

      Delete
    4. It looks like you can't upload to your Arduino. Do you have wire(s) connected to pin0 and/or pin1? If so you must disconnect them while your are uploading a sketch. Then, in the code, make sure that you are sending the AT commands to the right serial interface. In your example you are using(mixing) 2 interfaces.

      Delete
    5. I disconnected the TX and RX wires and everything seems to be OK! I made some corrections to the code.

      #include
      SoftwareSerial mySerial(2, 3);
      void setup(){Serial.begin(38400);Serial.println("Goodnight moon!");Serial.println("Hello, world?");}
      void loop(){Serial.println("AT+ROLE=1");}

      I run 'putty' and at the serial section I choose my com port and 38400 speed.Then 'open' and on console screen AT+ROLE=1 was running again and again.
      Am I ok?

      Thanks you again!

      Delete
    6. Are you trying to communicate with the BT device and sending debug info on 2 separate serial interfaces? If so, you have to tweak your code. Currently mySerial(pins 2&3) is not used while arduino serial default (pins 0&1) is use to do both. Maybe we could continue this conversation on Google+ (email, chat or hangout) it would go faster.

      Delete
  13. Hello Phillipe,

    I have two RN42XV Bluetooth modules each on my two Arduino Uno boards. I'm trying to connect the two together, so on the serial monitor I enter into command mode, "$$$", and then "c,<>" to connection with each other. It says that it is "TRYING" but then just freezes, but the LEDs on the Bluetooth modules indicate they are connected. However it doesn't say that the connection is successful. Any ideas?

    Earl

    ReplyDelete
    Replies
    1. Try "SM,1" before calling "c,<>". Don't forget to close the command mode with "---" after the "c,<>".

      Delete
  14. HI Phillipe
    I copy your code and compiled it successfully to my Arduino devises ,sadly I never got connection between the two BT
    I am using standard Bluetooth BC417 module and two separate Arduino devises (Arduino Nano & Arduino Uno).
    Do you have any idea why ?
    Thanks,
    Yaniv

    ReplyDelete
    Replies
    1. The code in this post in intended to work with the BlueSmirf device. The device you mention seems to us the AT commands. Other comments in this page are talking about the AT commands.

      Delete
    2. O.K Thanks
      I will try looking at the AT commends how to do this

      Delete
    3. HI
      Well I have investigated this thing for the last few hours.
      I have tried to enter the AT command and I got "O.K" at the siral port that means that I can send AT command
      But when I have tried to send " BluetoothSerial.write("AT+ROLE=1");"
      I got nothing.
      I think that my devise can't be Master, could it be ?
      I am working with Linovor HC-06
      DO you now if St Sak succeed to connect the tow Arduino's over BT

      This is my code :
      #include

      /* DIO used to communicate with the Bluetooth module's TXD pin */
      #define BT_SERIAL_TX_DIO 10
      /* DIO used to communicate with the Bluetooth module's RXD pin */
      #define BT_SERIAL_RX_DIO 11

      /* Initialise the software serial port */
      SoftwareSerial BluetoothSerial(BT_SERIAL_TX_DIO, BT_SERIAL_RX_DIO);

      void setup()
      {
      /* Set the baud rate for the hardware serial port */
      Serial.begin(9600);
      /* Set the baud rate for the software serial port */
      BluetoothSerial.begin(9600);
      BluetoothSerial.write("AT+VERSION");

      BluetoothSerial.write("AT+ROLE=1");
      }

      /* Main loop that will pass any data to and from the Bluetooth mode to the
      host PC */
      void loop()
      {
      /* If data is available from the Bluetooth module then pass it on to the
      hardware serial port. */
      if (BluetoothSerial.available())
      Serial.write(BluetoothSerial.read());

      /* If data is available from the hardware serial port then pass it on
      to the Bluetooth module. */
      if (Serial.available()){
      BluetoothSerial.write(Serial.read());
      }
      }

      Thanks,
      I am truly grateful yaniv,

      Delete
    4. I wish I had a pair of AT devices to test this. I don't know if @St Sak got his project to work. I haven't heard anything since my last comment in January. You should check the specs of your device to know if it can be set to Master Mode. Some device are Salve only while other device can be either Master or Slave.

      Delete
    5. O.K thanks the BT can be slave only :)
      I need to order HC-05

      Delete
  15. Hi Phillipe
    I am working on a project where I am building two portable gaming consoles with their separate lcds, switches..... and i wanted them to communicate over bluetooth:
    Like your project the two arduinos(in my case Due) will read the same code from the sd card and all i want to communicate from 1(kinda slave ) console to oder(master) console...
    Could you help me with the code for this to work plzzzzz.....

    ReplyDelete
    Replies
    1. If you will be using BlueSmirf BT devices and only those two 'console' will connect to each other then you can hardcode the connection using the code from this post. Of course you will have to use your slave device MAC instead of 000666123ABC. Once the connection is done you can use the BtInit, BtReceive and BtSend functions that are included in my Instructables to transmit data between the two console.

      Delete
    2. My device is not a BlueSmirfBT device but it also uses the RN 42 module....Should that be fine????????N Thnxxx for your help

      Delete
    3. It should work. Try sending "$$$" to it and see if it sends "CMD" back.

      Delete
    4. Perfect! You're all set to go then. Keep us posted on your progress

      Delete
    5. Hello Phillipe,
      Sorry to trouble you this way but I am new to arduino and I am finding it hard to find how exactly to do the connection between the two arduinos..... Can you explain me in steps from the starting and send me a code of two arduinos communicating like 1 sending some character and other on receiving should respond by glowing a led or something...Plzzzzz

      Delete
    6. I tried to do few things like changing baud rate and name of device and device mode but now i am stuck in the part of sending stuff from 1 arduino to other......Means like if the two arduinos are now connected now what commands to use to send data from one to another....

      Delete
    7. For code sample please use the link to the Instructables I've made (the link is on the very last line of this post). As for the communication after the link is establish, it works exactly like a normal serial port. You can use the basic Arduino serial functions to Serial.read() and Serial.println(). The sample code in the Instructable does all that since the Master sends (println) stuff the the slave who's listening (read).

      Delete
    8. Thanx Phillipe,
      I think this should get me going....I am really thankful for your help...

      Delete
    9. I have tried with codes with similar bluetooth modules on an Arduino and 1 Mega but for some reason it did not work out.....I am adding both the codes.....Can you plzzz help with the problem the code might be having......Also I have changed the baud rate to 9600 for the devices so in code also I am using 9600.....

      For master
      void setup()
      {
      Serial.begin(9600);
      Serial.print("$$$");
      delay(100);
      Serial.println("SM,1"); delay(1000);
      while(!Serial.println("C,000666495767"));
      delay(1000);
      Serial.println("---");
      pinMode(13,OUTPUT);

      }

      void loop() {
      if(Serial.print('H'))
      digitalWrite(13,HIGH);
      delay(5000);
      if(Serial.print('L'))
      digitalWrite(13,LOW);
      delay(5000);

      // put your main code here, to run repeatedly:

      }



      For Slave
      void setup()
      {
      Serial.begin(9600);
      Serial.print("$$$");
      delay(1000);
      Serial.println("SM,0");
      delay(1000);
      Serial.println("---");
      pinMode(13,OUTPUT);

      }

      void loop() {
      while(Serial.available()==0);
      char ch=Serial.read();
      if(ch=='H')
      digitalWrite(13,HIGH);
      if(ch=='L')
      digitalWrite(13,LOW);

      // put your main code here, to run repeatedly:

      }

      Delete
    10. I ran your exact code here. It fails with the 9600 baud but works right away with 115200. Note that I'm using 2 BlueSmirf silver. You should check the specs of your devices and make sure that they can work at 9600 baud (my guess is that they can't).
      One other tweak is to add a pause of a few seconds at the end of the setup functions to let some time for the connection to be made.
      you are sooooo close to your goal. Don't give up.

      Delete
  16. Hello Phillipe,

    I just want to say thank you for posting such useful tutorial on the bluetooth linkage between arduinos. It was very helpful for our "smart shoes" project for an embedded design courses at our university.

    Thank you!

    ReplyDelete
    Replies
    1. Glad it could help. Do you have a link to your project?

      Delete
  17. would anyone happen to know how to communicate bluetooth through matlab? more specifically coding? We are using a bluetooth mate silver(found from sparkfun). My group is trying to connect wirelessly to matlab but yet still can not.

    ReplyDelete
  18. Hi Phillipe,

    May I know how many connections can RN42XV support? Thank you!

    ReplyDelete
    Replies
    1. I have not experimented with RN42XV but some bluetooth devices are able to support a piconet of one master and up to 7 slaves. Like I mentioned before, I have not tried that yet but I wish I could.

      Delete
  19. The RN42XV can communicate with an android phone? Basically Im asking whether it is possible to connect a single bluetooth module to e.g. 3 phones (NOT the other way around). Hope you can help. Im using the RN-41-sm bluetooth module but can only connect with one phone; I need to connect with more

    ReplyDelete
    Replies
    1. I have connected RN42 modules with my Android phones in many projects but only one at a time. I never tried with 2 or more phones. I'll see if I can try to make this work.

      Delete
  20. Keep me posted. I need to know if this is even possible with bluetooth:) And if so, if i can send data simultaneously (or within a second after each other)
    Appreciate your time!

    ReplyDelete
  21. Tried anything yet? Additionally how fast can a multipoint bluetooth module switch between its connected devices. 1 seconds, 15 seconds or a matter of milliseconds?
    Im really interested to know

    ReplyDelete
  22. I'm trying to make two RN42-I/RM bluetooth talk. They are mounted in bluetooth modules from parallax inc. and then connected to arduino mini pro boards. I uploaded the code you have here but it is still not working. Do you know why?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. If you send "$$$" to the module do you get an "AOK" back?

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I got it to work! Now I'm trying to learn how to send a character from the Master to the Slave and I created a loop that if the slave reads the character H then an LED I connected to pin 8 should light up but it's not working. Do you have any similar code?

      I added this to my master code:
      void loop ()
      {
      Serial.print('H');
      }

      and then I added this to my Slave

      pinMode(8,OUTPUT);


      void loop ()
      {
      while(Serial.available()==0);
      char ch=Serial.read();
      if(ch=='H'){
      digitalWrite(8,HIGH);}
      if(ch=='L'){
      digitalWrite(8,LOW);}
      }

      THank you!!

      Delete
    5. Hello Marietta...Looks like you need to add a Serial.print('L');
      } in the Master Code

      Delete
    6. Marietta,

      If you have connected your LED anode (long lead) to pin 8, it should turn on when you send 'H'. If you have connected the cathode (short lead) it will turn on whit the 'L'.

      Delete
  23. Phillipe thank you very much for sharing your knowledge. I think that where some people are failing as I am is that we are just "taking for granted" that this code will in fact work for various BlueTooth modules. I am using an HC-05 which utilizes the AT command set, and please correct me if I am wrong but the code that you wrote as is will not function for an HC-05. properly unless you replace all of the BlueSmirf commands with the AT equivalent. Thank you very much.

    ReplyDelete
    Replies
    1. As mentioned in the BlueSmirf documentation "Roving Networks Bluetooth devices are programmed with a simple ASCI command language which is
      similar to the industry standard Hayes AT protocol." so the code that I'm sharing will only work on RN devices. Sadly I don't have bluetooth modules that uses AT commands so that I can code and test an 'AT' version of my project.

      I'll add this comment in the main post to help clarify things.

      Delete
  24. Thanks Phillipe..I'm am definitely a novice but that which you have completed has definitely sparked my curiosity. So I have a "few" HC-05/HC-06's laying around and I'm willing to send you a pair to "tool" around with. I've recently ordered a few HC-11's which are basically 1000 meter repeaters that connect to the HC series. I'm thinking that range extension should open doors for other applications.

    ReplyDelete
    Replies
    1. I really like the idea of a repeater. Can they handle multiple messages simultaneously? I'll take you up on that offer for the 2 HC modules. You can contact me through g+ or at phillipe (a) cantin dot com.

      Delete
    2. Not sure why I can't send email to that address...If you send me your address to kneeyhow @ Yahoo.com I'll get the boards out in the morning.

      Delete
  25. Here is one of the companies that I deal with...See anything interesting? You should be able to translate the page with Google Chrome.. http://item.taobao.com/item.htm?spm=a1z10.5.w4002-2724859378.15.psWx5z&id=20265137304

    ReplyDelete
    Replies
    1. I'll see if I can find them in the Canadian (or US) sites I normally buy from. I try to buy local as much as possible.

      Delete
  26. I'll get the HC-05's to you by next week...I have some HC-11 samples that I should be receiving in the next two weeks of which I can share one or two...

    ReplyDelete
  27. Hee Philippe, I'm back again.
    I need to get some insight on how fast piconet mode actually works.
    Perhaps you can help.

    ReplyDelete
    Replies
    1. I never tried Piconet and don't have bt modules that supports it. Which modules are you using?

      Delete
  28. Hi, i have read your article with a lot of intereset.
    I have a module with an IMU and this module streams data from the IMU by a bluetooth (RN-42) slave module. Questions...

    Which is the best suitable module can i buy to make this RN-42 talks with an arduino board?

    ReplyDelete
    Replies
    1. Personally, I would use the RN-42 BlueSMiRF Silver.

      Delete
  29. sir is it possible to transmit data with the input of sensor in the master bluetooth ? and receive by the slave bluetooth then has the output of LED screen ?

    ReplyDelete
    Replies
    1. Short answer is 'yes'. You could start with my project code and modify it to do exactly what you want. A crude way to do it would be to continuously send the sensor value.

      Delete
  30. Hello sir, may I ask if the modulation of EGBT-045MS is the same as of the bluesmirf? Because I am also making a project using neurosky and I don't have Bluesmirf but I have EGBT-045MS

    ReplyDelete
  31. Because the EGBT-045MS is using the AT commands, you should look up my other post were I'm using an AT-type module: (HC-05 Bluetooth link of 2 Arduino) http://phillipecantin.blogspot.ca/2014/01/hc-05-bluetooth-link-of-2-arduino.html

    ReplyDelete
  32. Hello sr,
    This is my situation. I am having a problem connecting two bluesmirf. I have an arduino UNO with one of them and a Teensy 3.1 with the other. I try with the code that you use for the configuration of them, but them never connect between each other. Also, I test each one of them, using the bluetooth of a laptop and it works fine. but when i try to connect with the other bluesmirf it doesnt work, the master can find the slave, but when i try to connect them, the master doesnt connect with the slave because the green led never blinks.

    This is code to setup both of them:
    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

    I configure the master and the slave using the serial port in arduino for both of them. I use teraterm to configure the bluesmirf. Firstly, i configure one in slave mode using SM,0 and no more. And for the master i'm using SM,1 then it search the other address and store it using SR. Finally i put "C" to make the connection.

    Could you please help me to solve my situation, i'm stuck!!!

    ReplyDelete
    Replies
    1. Do you have a github (github.com) repo where I can see your code? That would be the best way for me to help you.

      Delete