10 Replies Latest reply on Jan 7, 2014 10:46 PM by fordj419

    using bluetooth with arduino

    fordj419

      Hi i want to use a bluetooth module with an iphone and i want something to happen once iphone loses connection i currently have the bluetooth silver mate from sparkfun. How can i make this happen need help plz thank you.

        • Re: using bluetooth with arduino
          gihu

          Hi John,

           

          Probably a more detailed explanation will help.

          i suppose that you use a microcontroller connected on the bluetooth silver mate side, right? If you have good ability with a hand-soldering tool, try to weld a wire-wrap to PIO2 of the RN42, this pin if used for the purpose you need, it is high when connected, and low when disconnected.

          If you want to avoid burning out anything I think that you can use the SPP just to send a character, and wait for an echo, (then you have to implement an app in IOS just for this) if time out is disconnected, if you receive the echo, is connected.

           

          By the way, Have you chacked that this BT silver mate is IOS compatible? The roving network module build-in must be RN42APL, if is just RN42 it will not work well with IOS.

           

          I hope it helps, if not try to give a little more information just to help us to understand wath you need, I have used before RN42 to work with an android phone, and it works really well!!

           

          Regards,

          Miguel

          1 of 1 people found this helpful
            • Re: using bluetooth with arduino
              fordj419

              hi miguel thanks for responding and your answer was really helpful the pin on the bluetooth silver that i have say P106 im guessing it does the same thing with the HIGH/LOW functions.

              I have paired the bluetooth module and iphone successfully but initially the iphone wouldnt find the bluetooth device i had to go into comannd mode using $$$ once connected to arduino using this code here

              /*

                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!

              }

               

              But i have to do that everytime i want to connect. Is there a way to pair automactic once in range ?

                • Re: using bluetooth with arduino
                  gihu

                  Ok,

                   

                  Step by step,

                  1.In the void setup, you are inialitating UART in 115200 of Arduino, to contact the RN42, then you are changing the UART of the RN42 to 9600, and the you change the uart of the Arduino to 9600.

                  You can use Serial. begin(115200), and use every time the serial class, never more the bluetooth class, even this setup will not be needed.

                  2.Please, let me know if I am wrong, but I think serial.read is doing exactly the same  than bluetooth.read; bluetooth.avaliable is exactly the same than serial.avaliable, and so on... If I am rigth, you just need to use one of them.

                  3.For autoconnection and seeing then status of the RN42, you need to acces to pin that they are not in your module. Try to get one like this:

                  https://www.sparkfun.com/products/11601

                  Check before that it is compatible with IOS.

                  Tie PIO6 to 3V to make that every time the module 'sees' your Iphone connects with it.

                  Check the the status of PIO2, to know the status connection.

                  Remember that your mudules seems to have acces to PIO6, but in fact it is PIO4, not PIO6 (that's what sparkfun says)

                   

                  I can check that RN42XV is compatible with IOS or not (I've got one), but not before next week (I am android user...).

                   

                  Hope it helps,

                  Miguel

                    • Re: using bluetooth with arduino
                      fordj419

                      Thank you I will check out that module and try your suggestion I really appreciate your help I want to make something similar to the bluetooth bracelets and watches they have out now so was trying to see how to include the bluetooth in there and was wondering is arduino best for that or should I use some other mcu. Let me know what you think thank

                      ,

                        • Re: using bluetooth with arduino
                          gihu

                          Search and read info about bluetooth profiles, the most used by hobbyist are SPP to have serial communicatios, and HID to act as a mouse oy keyboard. For the purpose you want I think there are HDP and HRP. These are which normally are used in standard products, so if you can work with this profiles you will be able to works with comercial apps like nike+ or endomondo (I think). If not you can build your own app and harware based on SPP, but PIO6 and PIO2 will be very helpfull.

                          If you find helpful my comments I will appreciate if you mark it as useful,

                           

                          Please let me know your achievements on it, it is a very nice project.

                           

                          Regards,

                          Miguel

                          1 of 1 people found this helpful
                            • Re: using bluetooth with arduino
                              fordj419

                              i did some research on the different bluetooth profiles you showed me and didn't know there was so many profiles that can do different things that was really helpful. Where can you find a specific bluetooth module that supports most of those for purchase ?

                              or how can you change the one I have to do those things ?

                                • Re: using bluetooth with arduino
                                  gihu

                                  After some research... I think that RN42 has no HDP capabilities, you can find WT11 or WT12 from bluegiga, or PAN1455 and PAN155 from panasonic, BTM443 from lairdtech. These ones has HDP, search a little bit more, my advice, chose that one which have breakout board and many documentation. For example BTM443 (I used it) has a lot of information on its website, but I could not find breakout board (and burned out three modules...)

                                  PAN1555 has a breakout board:

                                  DKSB1013A Digi-Key Evaluation Boards | 876-1005-ND | DigiKey

                                  And a lot of information for this one:

                                  http://www.stollmann.de/en/modules/bluetooth-products/bluemod-p24p25g2.html

                                   

                                  Read it carefully, at the beggining it complex to understand how it works.

                                   

                                  How do you want to solve the sensing part?

                                   

                                  Regards,

                                  Miguel

                                    • Re: using bluetooth with arduino
                                      fordj419

                                      I Like the BTM443 seems like it will do a lot of the things I need it to do thanks do I need a breakout board for that ?

                                      also with the silver mate from what I'm understanding is your saying to solder a wire to PI06 and that pin will go high when connected and low when it loose connection right? Could I use the arduino to do a digital read from PIO6 to do output from arduino ? And also I wasn't sure how to make the silvermate connect automatic to IOS or is that not possible with the current module I have?

                                        • Re: using bluetooth with arduino
                                          gihu

                                          Hi John,

                                          For the BTM443, it is much easier handle with it, if you have built in a breakout board, or even you can make a pcb to solder the module, so, breakout board strongly recommended.

                                          About PIO6 functionality, this function on PIO6 is by default, and even can be changed (at command), Before connect it to the arduino, just use a tester, to check it is working, Once you know it works, connect it to the arduino, and test it. When you get it working, see more info about auto connection, because it not depends only on RN42 side, it also depends on the Iphone side, the code of your app shuold accept incomming connection, but better you first deal with PIO6, the autoconnection can be done also in the Iphone side.

                                          Regards,

                                          Miguel