Bluetooth for Android and Arduino HC-05 Module, Java implementation

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

ความคิดเห็น • 145

  • @DIYDaveOK
    @DIYDaveOK 3 ปีที่แล้ว +9

    I realize this is nearly three years old, but I wanted to THANK YOU for this example. I need to put together a quick-and-dirty bluetooth client without all the sexy discovery and UI support - just send data to a remote device. This is *exactly* the kind of demo I needed. Perfect.

  • @Dtomper
    @Dtomper 2 ปีที่แล้ว +3

    In 28 minutes you answered all of my questions about Bluetooth communication in Android Studio. Thank you from the bottom of my heart!

  • @treqwedan7696
    @treqwedan7696 5 ปีที่แล้ว +6

    Really good, sir! Finally someone on this internet that specifies that the HC-05 module is the SERVER . You established a really quick connection with the phone, i'ved enjoyed it.

  • @rajawikiaa
    @rajawikiaa 3 ปีที่แล้ว +3

    A year ago, I was so lost that I was wondering if this guy was speaking English or not. Now I understand every step he made. Great explanation with a perfect pace. I liked when he faced some issues and tried to solve it. Keep it up brother. Little progress is what matters the most.

  • @CCmoney2313
    @CCmoney2313 2 ปีที่แล้ว

    best tutorial hands down. Had to use HC05 with android studio and this was the only video that helped me

  • @ondrejvainer1510
    @ondrejvainer1510 3 ปีที่แล้ว +1

    A million thanks

  • @edwardcox7169
    @edwardcox7169 4 ปีที่แล้ว +4

    hallelujah! a video that's easy to understand! Thanks. Maybe a followup video on keeping socket open to listen for more messages?

  • @TutorialeGratuite
    @TutorialeGratuite 3 ปีที่แล้ว +1

    Very good video. Thank you for the information. I managed to connect and send data to Arduino via Bluetooth. Your video helped a lot.

  • @Themogawave
    @Themogawave 4 ปีที่แล้ว +3

    dude you dont know how much you helped me out here ive been looking for days for something like this. Really Really helpful and good tutorial mate everythings works fine, subscribed and looking forward to your other videos :)

  • @xavimourelo
    @xavimourelo 2 ปีที่แล้ว +1

    Thank you very much, it was the video i needed, and the only one that explains clearly what needs to be done

  • @LuisGL90
    @LuisGL90 4 ปีที่แล้ว +3

    Thanks for this video, you helped me so much! I was looking for several tutorials and this one looks very interesting. It is really clear and explains a simple way to connect to the HC-05 module via bluetooth.

  • @ProTimax
    @ProTimax 4 ปีที่แล้ว +2

    Thanks man, that's exactly what i was looking for.

  • @adityamattoo5922
    @adityamattoo5922 3 ปีที่แล้ว +1

    The ble module does not pair (since its not Bluetooth classic i assume), how do i send info since it is not bonded.

  • @abdul-gafoorqureshi3371
    @abdul-gafoorqureshi3371 4 ปีที่แล้ว +1

    Good explanation. Step by step guidance. Thanks. I appreciate.

  • @pgorellana
    @pgorellana 3 ปีที่แล้ว +1

    It is great You make to look it so easy. Good job

  • @marcelovera6022
    @marcelovera6022 2 ปีที่แล้ว +1

    Muchas gracias! Muy clara tu explicación saludos desde Chile!

  • @TennerCheung12345
    @TennerCheung12345 5 ปีที่แล้ว +1

    thanks man it worked with my SPP-C module

  • @fancycat3360
    @fancycat3360 2 ปีที่แล้ว

    Hallelujah! Great job man!

  • @javlontursunov6527
    @javlontursunov6527 ปีที่แล้ว

    Now after android 6 (API 23), we need to add permission check, how can we do that?

  • @nileah14k
    @nileah14k 4 ปีที่แล้ว +2

    This video is very helpful, thank you alot for making this video

  • @sebatsituab3955
    @sebatsituab3955 5 ปีที่แล้ว +1

    Can I get help ASAP: Im on a project using arduino uno and android as face recognition door lock wherein the face recognition app in the android smartphone will send an output stream to the arduino via hc-05 bluetooth module to operate or "open" the door lock using servo motor. my problem is how can I apply bluetooth capabilities to a face recognition app I found to be able to send data to the arduino?
    (note that once a user is recognized, the app will automatically send data to the arduino while there will be a separate button for "locking" the servo motor.)

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว +1

      That sounds like an interesting project. To improve your chances of getting help, I would suggest that you share more details about your idea and your work thus far. Perhaps somebody already has some experience with that sort of problem. Thanks and good luck!

  • @kaladin_4
    @kaladin_4 4 ปีที่แล้ว +1

    Really good video. Helped me out a lot.

  • @DharmanshuSharma
    @DharmanshuSharma 3 ปีที่แล้ว +1

    really informative and it works too👍👍👍

  • @Aramich101
    @Aramich101 4 ปีที่แล้ว +1

    how could we send data other than a char? i want to read sensor data to my app (double)

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      Good question! Communication takes place in BYTES. You can CAST those bytes to any data type: char, int, etc. Thanks!

    • @Aramich101
      @Aramich101 4 ปีที่แล้ว +1

      @@branislavstanojkovic5211 thanks i got it to work! how would you suggest going about constantly getting data from the module? In the video you used a for loop but what if we want to loop indefinitely? do{ .. }while(true); causes problems with my UI

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      @@Aramich101 I have another video posted to my TH-cam channel, the subject is serial communication with Arduino. In that video I use a serial port LISTENER, take a look, maybe that approach would work well for you. Thanks.

    • @Aramich101
      @Aramich101 4 ปีที่แล้ว +1

      @@branislavstanojkovic5211 I ended up using multi threading to fix this! It works perfectly now. Thanks again !

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      @@Aramich101 Great! Thanks for sharing.

  • @sadysepulveda2254
    @sadysepulveda2254 3 ปีที่แล้ว

    mil gracias por este video, me aclaro muchas dudas eres el mejor! saludos desde Colombia

  • @RAHULRAWAT-th8xu
    @RAHULRAWAT-th8xu 4 ปีที่แล้ว +1

    How to make .Jar application to use java enabled phone as Bluetooth speaker

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      Interesting idea, Rahul! Perhaps you can use the I2S protocol to stream audio via Bluetooth?

  • @smritisinha630
    @smritisinha630 3 ปีที่แล้ว

    in starting that Serial Bluetooth code is implemented in which platform? anybdy knows/

  • @subhambikashbehera6793
    @subhambikashbehera6793 4 ปีที่แล้ว +1

    Nyc commenting on 2021
    Keep doing

  • @TrungNguyen-mc5sl
    @TrungNguyen-mc5sl 3 ปีที่แล้ว

    Very good and funny videos bring a great sense of entertainment!

  • @sameerk12982
    @sameerk12982 5 ปีที่แล้ว

    Thanks a lot Sir for this helpful and simple tutorial.....it helped a lot.....I have created an app to turn on and off led on arduino with help of your tutorial. highly appreciated.

  • @codingwithsam4992
    @codingwithsam4992 2 ปีที่แล้ว

    Thank you. I recommend everyone to watch at 1.5x😅

  • @freecsarsalaan1799
    @freecsarsalaan1799 3 ปีที่แล้ว

    Hey Branislav my cc2650 requires pin to connect can you suggest what additional things will be required to pair it

  • @mikeyan9239
    @mikeyan9239 3 ปีที่แล้ว

    I was able to establish a socket, but it says "read failed, socket might closed or timeout, read ret: -1" when I try to do socket.connect(). Its the same even when I put the code in a do-while loop. any suggestions?

  • @sagarjadhav9945
    @sagarjadhav9945 2 ปีที่แล้ว

    how can i pass the byte code by clicking on a button? because if i used onClicklistner it will return void type and the message cant be passed, so please help

  • @mathewsjoby6455
    @mathewsjoby6455 3 ปีที่แล้ว

    I am getting an error when i am taking the address from the recyclerView's position. It is not getting converted to a string.

  • @AfnanKhakwani
    @AfnanKhakwani 4 ปีที่แล้ว +1

    Very helpful, much appreciated

  • @oladunk9986
    @oladunk9986 4 ปีที่แล้ว +1

    Is it possible to get a complete copy of this tutorial in a zip file ? With Manifest and the rest of the needed files?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว +1

      Hi Ola, thanks for that suggestion. I no longer have this code in my computer, but if anybody does, please share it. Thanks.

  • @TheVersheva
    @TheVersheva 3 ปีที่แล้ว +1

    How would I send an int from my android phone to arduino?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  3 ปีที่แล้ว +1

      Good question! Try sending a BYTE, then CASTING it to an integer. That's how I would try to do it.
      If anybody knows a good way to do this, please share.
      Thanks!

    • @TheVersheva
      @TheVersheva 3 ปีที่แล้ว

      @@branislavstanojkovic5211 Would the process you described in your video (connecting, creating input/output streams, etc.) be different since the phone becomes the server and the android becomes the client?

    • @TheVersheva
      @TheVersheva 3 ปีที่แล้ว

      Does the phone become the server in my scenario? Sorry, I'm new to working with Bluetooth

  • @djonganelsonlontrowski1949
    @djonganelsonlontrowski1949 4 ปีที่แล้ว +1

    After connect and renew connect this error occurred: java.io.IOException: read failed, socket might closed or timeout, read ret: -1

    • @djonganelsonlontrowski1949
      @djonganelsonlontrowski1949 4 ปีที่แล้ว

      Example: Connect first (All fine), after socket.close() was successfull and try connect again this method returns this error SAME with socket already closed.

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      @@djonganelsonlontrowski1949 Thank you for reporting this anomaly

    • @djonganelsonlontrowski1949
      @djonganelsonlontrowski1949 4 ปีที่แล้ว +1

      ​@@branislavstanojkovic5211 I discover how to resolve, some devices not can open/close sockets fast, then, for this slowest devices, is needeed add a Thread.sleep with some milliseconds and everything have been closed with successfull.

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      @@djonganelsonlontrowski1949 Excellent tip, thank you.

    • @anujajanawade9927
      @anujajanawade9927 3 ปีที่แล้ว

      Same issue here..has anyone resolved it?

  • @kubx007TV
    @kubx007TV 5 ปีที่แล้ว +2

    I did everything like you and I got error: java.io.IOException: read failed, socket might closed or timeout, read ret: -1
    What's wrong?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว

      Please share if you manage to figure out what the reason for the error message was. Thanks.

    • @Raarnoldy
      @Raarnoldy 4 ปีที่แล้ว

      I am having the same issue

    • @MyVoid312
      @MyVoid312 4 ปีที่แล้ว

      You figured out?

    • @kubx007TV
      @kubx007TV 4 ปีที่แล้ว +1

      simulator doesn't have bt, you have to run it on your own phone

    • @MyVoid312
      @MyVoid312 4 ปีที่แล้ว

      @@kubx007TV O I see i have a different problem :/ thanks though

  • @blendeadan8779
    @blendeadan8779 4 ปีที่แล้ว +2

    hi, it s very interesting, if i want to create a button and send idk, for example ''b'' when i press it, how do i do that?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      That would be a very cool project, please post your work here if you manage to do it. Thanks!

  • @mohammadsabbagh9596
    @mohammadsabbagh9596 3 ปีที่แล้ว

    it worked with me , thak you very much teacher

  • @sandunrasanga2164
    @sandunrasanga2164 3 ปีที่แล้ว

    Thank you. Very helpful ... 👍👍👍

  • @NEO-xj2sf
    @NEO-xj2sf 3 ปีที่แล้ว

    Can you please tell me how to send the bytes in the form of string values instead of bytes

    • @shreyatiwari755
      @shreyatiwari755 3 ปีที่แล้ว

      Have you got the solution

    • @mathewsjoby6455
      @mathewsjoby6455 3 ปีที่แล้ว

      @@shreyatiwari755 yes I did. A decade ago.

  • @joanfg920
    @joanfg920 5 ปีที่แล้ว +1

    Very useful! Thank you very much!

  • @lukecross5439
    @lukecross5439 4 ปีที่แล้ว +1

    Do you where find the UUID of HC05?

  • @Hari-ko5ry
    @Hari-ko5ry 3 ปีที่แล้ว +1

    Can u give source code of it (link) git repo

  • @m.rivaldialiseptian7777
    @m.rivaldialiseptian7777 4 ปีที่แล้ว +1

    sir, help me, how to make hc 05 sending data sensor to aplication

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      Thank you, Sir, for watching my video. In the Arduino sketch, instead of cycling through character values 65-90, send to the serial port your sensor data. Good luck!

  • @miguelnajera3979
    @miguelnajera3979 4 ปีที่แล้ว +1

    Hey man, is it possible to convert that char or inputstream data into a String to print in a toast message. Can you please give a hand with an example. Thank you.

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว +1

      Hey Miguel, thanks for watching my video! Try to CONCATENATE the inputstream data into a string. To see an example, please take a look at my other video on serial communication in Java at around 7:40, here is the link: th-cam.com/video/Q8beQ6xW0s0/w-d-xo.html
      Good luck!

  • @theguy2887
    @theguy2887 4 ปีที่แล้ว +1

    It works for HC-6 module ?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  3 ปีที่แล้ว +2

      Good question! I don't have an HC-06, so I wouldn't know. If you find out, please share.

  • @chandrakanthotkar7160
    @chandrakanthotkar7160 3 ปีที่แล้ว +1

    thanks bro you helped me lot

  • @kekekeernest8920
    @kekekeernest8920 3 ปีที่แล้ว

    Please, don't u have the kotlin version

  • @mannhansen9337
    @mannhansen9337 3 ปีที่แล้ว

    Is it possible to get a copy of this complete project as a zip file ? It would make it easier for starters like me and others with Android Studio.

  • @canererhadim3772
    @canererhadim3772 4 ปีที่แล้ว +1

    You are Best

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      Ahahaha ok. No, you guys are the best when you leave me comments like this one. Thank you.

  •  3 ปีที่แล้ว +1

    Muchas gracias, me sirvio mucho!

  • @bromasoficial8855
    @bromasoficial8855 ปีที่แล้ว

    When I run, I’ve some errors : Exception java io : failed to read, The socket might…time out…

  • @francispeterjuridico8319
    @francispeterjuridico8319 4 ปีที่แล้ว +1

    how to stop the hc05 from sending data?

  • @Abbici
    @Abbici 5 ปีที่แล้ว +1

    Did you try to write "<" and ">" (or "<" ">") instead ""?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว +1

      Thank you for the good suggestion Gianfranco! It didn't occur to me to try that before. I still can't get the regular angled brackets to show in the description, so I'm using the big angled brackets (<) instead. If anybody has a way of printing the regular less-than sign in the description, please share it. Thanks!

    • @Abbici
      @Abbici 5 ปีที่แล้ว +1

      @@branislavstanojkovic5211 Welcome. I didn't help you... YOU HELPED ME A LOT WITH THIS ANDROID AND ARDUINO EXPLANATION!!!

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว +1

      @@Abbici Wow! Thanks! I'm happy to hear that my video was helpful to you.

  • @BishirTijjani
    @BishirTijjani 2 ปีที่แล้ว +1

    the hc dash o5 got me🤣

  • @canererhadim3772
    @canererhadim3772 4 ปีที่แล้ว +1

    Thansk for your usefull share..

  • @prestonchaussee805
    @prestonchaussee805 3 ปีที่แล้ว

    this mike was the first mike ever created by a guy who doesnt know the word mic

  • @mataskeblis7845
    @mataskeblis7845 6 ปีที่แล้ว

    Dear Branislav,
    Can you help me with sending int/float/string data from arduino to android? For examples steps data to android through HC-05 module?

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  6 ปีที่แล้ว +2

      Hi Matas, thank you for your good question! Unfortunately, it's been a while since I made this video, so I no longer remember much of what I did here. But, I'll try to point you in the right direction.
      Consider this: Data is being passed in the "byte" format. If you CAST these bytes to ASCII characters (the "char" format, see an example in line number 59 of the code in the video), you can easily CONCATENATE these characters into strings. Similarly, you should be able to CAST data from "int", "float", or any other format into "bytes" for sending, and vice-versa, from "bytes" to "int", "float", or any other appropriate format after receiving.
      Try googling a few examples of "java type casting and conversion". That might help.
      Thanks and good luck!

  • @sksahil4374
    @sksahil4374 4 หลายเดือนก่อน

    Nice work

  • @indian_techieee
    @indian_techieee 4 หลายเดือนก่อน

    Top Class

  • @toanpham2977
    @toanpham2977 5 ปีที่แล้ว +1

    thank you!

  • @lukecross5439
    @lukecross5439 4 ปีที่แล้ว +2

    this method block the UI, we must be use Thread

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว +1

      This is a simple example, I did not use multithreading. You are certainly welcome to add that feature to the code on your own. Thank you!

    • @Snoopymeow
      @Snoopymeow 4 ปีที่แล้ว

      @@branislavstanojkovic5211 how to use on new activity, i cant send in new activity although i have address of HC06, can u give me some key or page that guide me hơ to do that

    • @gabrielz2241
      @gabrielz2241 2 ปีที่แล้ว

      Have you found the solution using Threads?

  • @excalibur8147
    @excalibur8147 2 ปีที่แล้ว

    Thank you so much for this video, it is working and when I send, for example, "6" from android, arduino gets "6" in serial port!
    But I cant make anything work with that "6" that arduino got
    I have tested sending "6" from the app named Serial Bluetooth Terminal, which I got from App Store, and when I send "6" from It to arduino serial, arduino actually shows "6" the same way as with your code, but this time my arduino code actually does something. What can be the reason for this?
    I mean, its like with your code Arduino can get data from serial but doesn't recognise it

  • @Snoopymeow
    @Snoopymeow 4 ปีที่แล้ว +1

    nice

  • @vijithviswambharan775
    @vijithviswambharan775 2 ปีที่แล้ว

    Thankyou:-)

  • @canererhadim3772
    @canererhadim3772 4 ปีที่แล้ว +1

    Can you write data on texbox please.. That will finish my project... I will earn money :)

  • @faizantanveer40
    @faizantanveer40 5 ปีที่แล้ว +1

    SIR CAN YOU GIVE ME MAIL I WILL DISCUSS YOU SOMETHING ABOUT OR PROJECT TO RELATED BLE HC 05

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว +1

      Thank you for your interest, Faizan. Please post your issue here, where everybody can participate in the discussion, as the whole purpose of this video is to help share the knowledge publicly. That would be the best way to get assistance, I think.

  • @manellansari7533
    @manellansari7533 3 ปีที่แล้ว

    xml code !

  • @CodeXBro
    @CodeXBro 5 ปีที่แล้ว +1

    Come on man try to use bigger font size.

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  5 ปีที่แล้ว +3

      Next time I will, sorry. I will also post the code. Didn't have much experience when I made this video.

  • @MyVoid312
    @MyVoid312 4 ปีที่แล้ว

    This doesnt work , my bluetooth or whatever wasnt able to form a connection..... this didnt really work

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      Sorry to hear that. Please share the details, what equipment you are using, and what the error message is. Thanks.

    • @MyVoid312
      @MyVoid312 4 ปีที่แล้ว +1

      @@branislavstanojkovic5211 Some how it works now i have no clue what the hell happened LOOL it sends the alphabet , now i'm trying to understand how to send to the arduino what i wanted
      edit: now it doesn't work for some reason this is so wierd it was able to establish a connection only one time

    • @branislavstanojkovic5211
      @branislavstanojkovic5211  4 ปีที่แล้ว

      @@MyVoid312 Great! Thanks for the feedback.