5 Replies Latest reply on Feb 1, 2015 11:00 AM by radiofrequency

    Interfacing Galileo with bluetooth module : HC-05

    nagarajatmsrit

      I am new to Galileo. Please keep this in mind.

      I am trying to interface Galileo with bluetooth module HC-05.

      HC-05 is a fairly common bluetooth module used with arduino.

       

      All arduino code seems to be useing "SoftwareSerial", but it seems like Galileo does not support it.

      How do I go about interfacing HC-05 with Galileo?

      Any pointers would be appreciated.

      (Please note: I am not seeing HC-05 module being listed in either my mobile or computer when I scan for available bluetooth devices)

      Thanks!

        • 1. Re: Interfacing Galileo with bluetooth module : HC-05
          flummer

          Hi nagarajatmsrit,

           

          Usually SoftSerial is used on the Arduino, so that you can use the native UART for debug and control signals to the computer. On the Galileo, you don't have that problem, as the connection to the computer has it's own virtual serial port over USB.

           

          In most cases (I don't know your use case exactly so I can't say for sure) you can just use the hardware serial connection on Arduino pin 0 and pin 1.

           

          You just have to do a few minor changes to the code, if you have some example code, you can paste it here and I'll show you what to change, if the above isn't enough to get you started.

           

          Hope it helps!

           

          /Thomas

          • 2. Re: Interfacing Galileo with bluetooth module : HC-05
            nagarajatmsrit

            Flummer,

            Thanks for the reply.

             

            Here is that code that I am trying to use.  (Source: Modify The HC-05 Bluetooth Module Defaults Using AT Commands)

             

            /*

             

            AUTHOR: Hazim Bitar (techbitar)

            DATE: Aug 29, 2013

            LICENSE: Public domain (use at your own risk)

            CONTACT: techbitar at gmail dot com (techbitar.com)

             

                HC-05 GND --- Arduino GND Pin

                HC-05 VCC (5V) --- Arduino 5V

                HC-05 TX --- Arduino Pin 10 (soft RX)

                HC-05 RX --- Arduino Pin11 (soft TX)

                HC-05 Key (PIN 34) --- Arduino Pin 9

            */

             

             

            #include <SoftwareSerial.h>

             

            SoftwareSerial BTSerial(10, 11); // RX | TX

             

            void setup()

            {

              pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode

              digitalWrite(9, HIGH);

              Serial.begin(9600);

              Serial.println("Enter AT commands:");

              BTSerial.begin(38400);  // HC-05 default speed in AT command more

            }

             

            void loop()

            {

             

              // Keep reading from HC-05 and send to Arduino Serial Monitor

              if (BTSerial.available())

                Serial.write(BTSerial.read());

             

              // Keep reading from Arduino Serial Monitor and send to HC-05

              if (Serial.available())

                BTSerial.write(Serial.read());

            }

            • 3. Re: Interfacing Galileo with bluetooth module : HC-05
              flummer

              Hi nagarajatmsrit,

               

              Below is code changed to (hopefully) work with the Galileo. You will need to use pin 0 and pin 1 for the serial connection and NOT pin 10 and 11.

               

              /*
              
              AUTHOR: Hazim Bitar (techbitar)
              DATE: Aug 29, 2013
              LICENSE: Public domain (use at your own risk)
              CONTACT: techbitar at gmail dot com (techbitar.com)
              EDIT FOR GALILEO: flummer (hackmeister.dk)
              
                  HC-05 GND --- Arduino GND Pin
                  HC-05 VCC (5V) --- Arduino 5V
                  HC-05 TX --- Arduino Pin 0 (hw RX)
                  HC-05 RX --- Arduino Pin1 (hw TX)
                  HC-05 Key (PIN 34) --- Arduino Pin 9
              */
               
              void setup()
              {
                pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
                digitalWrite(9, HIGH);
                Serial.begin(9600);
                Serial.println("Enter AT commands:");
                Serial1.begin(38400);  // HC-05 default speed in AT command more
              }
              
              void loop()
              {
              
                // Keep reading from HC-05 and send to Arduino Serial Monitor
                if (Serial1.available())
                  Serial.write(Serial1.read());
              
                // Keep reading from Arduino Serial Monitor and send to HC-05
                if (Serial.available())
                  Serial1.write(Serial.read());
              }
              

               

              I think I have RX and TX correctly in the description, but I might be wrong... if it doesn't work, try switching them before giving up ;-)

               

              Hope it helps!

               

              /Thomas

              1 of 1 people found this helpful
              • 4. Re: Interfacing Galileo with bluetooth module : HC-05
                nagarajatmsrit

                Thank you very much!

                It worked as expected.

                On a side note, there was an issue with the HC-05 PCB where diode polarities had been reversed!

                • 5. Re: Interfacing Galileo with bluetooth module : HC-05
                  radiofrequency

                  I just tried it out, doesn't seem to work with my bluetooth shield