Bluetooth serial communication with Mac, JY-MCU Bluetooth and Arduino

After a long while without posting I finally got some time to work in a project which I will later post here (A bluetooth controlled car), but first I had to test the bluetooth module and I’ll use arduino for it, let’s get start with it.

first upload the following test code to your arduino.-

char val; // variable to receive data from the serial port
int ledpin = 8; // LED connected to pin 48 (on-board LED)

void setup() {

  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(9600);       // start serial communication at 9600bps

void loop() {

  if( Serial.available() )       // if data is available to read
    val =;         // read it and store it in 'val'
  if( val == 'H' )               // if 'H' was received
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else { 
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  delay(100);                    // wait 100ms for next reading

Now power up your bluetooth module with 3.3V works just fine, ground it first and then connect to 3.3V, once that’s ready connect the Tx (transmitter) of the module to the Rx (Receiver) of the arduino and the Rx of the module to the Tx of arduino and attach an LED to port 8 of your arduino with and 220Ω resistor. (More details on wiring.-

Once you got that working let’s configure our mac’s.-

1.- Go to system preferences and click on the bluetooth symbol.


now you should see something like this.-


click on the plus sign to add a device and you should see something like this.-


click on your device in my case that’s the only bluetooth device available, odds are you’ll see something like this.-


don’t worry just click Passcode Options and select use a specific passcode in my case the passcode is 1234 so I just change it and clicked ok.


Now you should see something like this.-


great it’s almost done let’s get back to the system preferences menu and select the bluetooth option again, select our device, click the gear icon and select “Edit Serial Ports…” like the following image.-


let’s keep things simple for the test so configure as following (with the name you wish).-


look at the path it generate and now let’s open terminal and write.-

ls /dev/tty.*

A list of all of the devices will be displayed you should be able to see the same path we saw at the config window. Write at the terminal the following.-

screen /dev/tty.(here goes the device you want to acces)

in my case is

screen /dev/tty.HC

an empty window appears now type H and the LED we attached to port 8 of arduino now turns on type another character and it should turn off.

That’s all for today I’ll be posting as I advance in the project. Best Regards.

This entry was posted in Technology. Bookmark the permalink.

7 Responses to Bluetooth serial communication with Mac, JY-MCU Bluetooth and Arduino

  1. Anand Pattabiraman says:

    Got this error: Failed to open an RFCOMM serial channel.
    Check if authentication needs to be enabled in your device.

    I don’t know what the issue is, but I followed your instructions directly. Thanks.

  2. Chen says:

    This was so, so helpful. Thank you!!

  3. Pingback: Cheap Bluetooth Serial Port | ——-

  4. Pingback: コンピューターとしゃべる (Bluetooth) | IT Kids Laboratory

  5. rich ng says:

    Hey, please help me, I follow this guide, I was able to connect to the Mac, well, for 30 seconds with a HC-05 and about 1 minute with a HC-06, then it gets disconnected. I tried it on a Mac mini, Macbook Air with the latest Yosemite.) and also tried it on a older iMac with Lion on a Bluetooth dongle. They all have the same problem. I Googled, people say it is a Mac issue. Does the Bluetooth needs to be reconfigured in some way? and how?

  6. edneyess says:

    what OSX are you using? How can i access this functionality on Mavericks distribution?

  7. Dave says:

    This worked for me. BT did say “Disconnected” on my HC-05 after a minute or so, but once I ran the screen command and typed some characters, it was connected again and I received my response from my computer. The BlueTooth screen is different now in El Capitain, but I did a ls -al | grep /dev/tty and looked for anything with an “HC” in it and found /dev/tty.HC-05-DevB. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s