Kotlin 101: How to communicate to a Bluetooth device Part 2

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ • 98

  • @kleanlins
    @kleanlins 6 років тому +9

    I'm sorry, but how did you get that UUID?

  • @ASDoublecAp
    @ASDoublecAp 4 роки тому +2

    Bro, I just wanted to say THANKS.
    You’re a genius and you saved my project.
    THANKS again :’)

  • @AndreasHel197
    @AndreasHel197 5 років тому +10

    how can i read data from the device?

  • @pauloborralho152
    @pauloborralho152 5 років тому +1

    perfect, it works great! Thank you for your effort and your patience to do this. I know nothing about kotlin or android studio and I think this is the best way to learn. Old cell phones can be recycled and usefull again with apps. I (as other people here) will try to send serial data from a HC06 to the cell phone and process/save it.
    I also liked your calm style, and your explaining everything. Great Job

  • @josecastellanos4836
    @josecastellanos4836 3 роки тому

    Bestest example about this interaction, Thanks for your help...

  • @florianmoser7459
    @florianmoser7459 4 роки тому +2

    Great tutorial!
    But please use a series resistor for the led.

  • @sudhir1274
    @sudhir1274 4 роки тому

    Clear and concise tutorial. Very useful.

  • @marcocastaneda2385
    @marcocastaneda2385 5 років тому +2

    Where do I get the UUID?

  • @Tutos-ME
    @Tutos-ME 5 років тому +1

    It doesn´t work, could you help me? Everything´s working fine, when I clic a button in the app the arduino 'TX' led turns on, but LED connected to Pin 13 does not. Maybe is 'cause in the app you have sendCommand("a") & sendCommand("b") A&B toByteArray , and arduino expects a '1' or '0'. How can I fix this? Thanks

    • @poobels
      @poobels 4 роки тому

      Same Problem here.
      Have you been able to fix it?
      Nevermind.
      You were right.
      I just changed "a" and "b" to "1" and "0" in ControlActivity.kt and it worked.
      Ty

    • @Tutos-ME
      @Tutos-ME 4 роки тому +1

      @@poobels you could also change Arduino file to expect A and B

  • @carlosproduction4183
    @carlosproduction4183 5 років тому +3

    Hi, thank you again !
    I have "Unresolved SelectDeviceActivity" !
    Do you have an idea ?

    • @KiroLive
      @KiroLive 5 років тому

      I have the same issue, did you fix it?

    • @carlosproduction4183
      @carlosproduction4183 5 років тому

      @@KiroLive No, I didn't !
      I try to mail the video creator but they seems to be dead (or, at least, out of the game) !

    • @sepldepl4540
      @sepldepl4540 5 років тому +4

      I think he renamed the MainActivity to SelectDeviceActivity or somethig so u just need to switch SelectDeviceActivity to MainActivity (tahts what i did)

    • @ballaownz
      @ballaownz 4 роки тому

      Same here, any ideas?

    • @the-fantabulous-g
      @the-fantabulous-g 3 роки тому

      @@ballaownz It's what sepldepl said; we change the line where we define class for MainActivity.kt (or SelectDeviceActivity.kt, if you renamed the file but not the classname) from:
      class MainActivity : AppCompatActivity() {
      to:
      class SelectDeviceActivity : AppCompatActivity() {
      This solved my issue here

  • @iamrobert505
    @iamrobert505 3 роки тому

    Where did you get the UUID from? does it work with any device? you didn't explain that part

  • @antonyhelsby9374
    @antonyhelsby9374 6 років тому +1

    I copied your code exactly and when I run the app with the bluetooth module running on the arduino, it says no paired devices found. I checked on my phones usual bluetooth in settings and it can pick up several paired devices, but they're not visible from this app that we made...

  • @rmirabelle
    @rmirabelle 4 роки тому +2

    You already pass Context as c in the default constructor. Just declare it as a val [val c:Context] instead of as a parameter [c:Context] and you can avoid the leaky copy of Context that you create and use [c] where needed instead of [context]

  • @JR_7272
    @JR_7272 3 роки тому

    Async and a couple other things are out of date. does anyone know of an updated one?

  • @ordinarygamer5917
    @ordinarygamer5917 4 роки тому

    How can i use toast inside postexecute in your program? 🙏

  • @syedaffanhameed14
    @syedaffanhameed14 2 роки тому

    Hi!, how can we read the RSSI value of that bluetooth signal? can anyone please answer it?

  • @marcelocampossilva7024
    @marcelocampossilva7024 3 роки тому

    This is an excellent tutorial!! I am looking for read data from the Bluetooth and make some routines to search the devices, so , I don't need to pair before. Would you have plans to release some tutorial to perform these as well? Thanks again for sharing your knowledge! I really appreciate it.

  • @eingskywalker9116
    @eingskywalker9116 6 років тому

    I have done exactly as you have shown here, app is working but it doesn't showing paired devices in listview

  • @dork3nergy
    @dork3nergy 5 років тому

    Great tutorial. Works like a charm. Thanks!

  • @insu1213
    @insu1213 3 роки тому

    WoW Such an amazing tutorial Thank you so much!

  • @animongahajime9302
    @animongahajime9302 4 роки тому +2

    Excellent Tutorial, but can you please help with update? AsyncTask is deprecated now and i dont know what to do :(

    • @ole1907
      @ole1907 3 роки тому +2

      File -> Project Structure -> Modules -> Compile Sdk Version -> 28, Then is works

  • @mathewthomas3014
    @mathewthomas3014 4 роки тому

    thank you so much man...... you literally saved my life

  • @omakaroto
    @omakaroto 3 роки тому

    please make a similar tutorial but for BLE communication with an arduino, and how to store our datas

  • @Morphinwithyou
    @Morphinwithyou 3 роки тому

    Dude you're awesome. Thanks!

  • @diegoflores4587
    @diegoflores4587 6 років тому +3

    its so awesome you are the only person how do this witout appinventor ty so much

  • @best_songs_ever3889
    @best_songs_ever3889 4 роки тому

    it uses bluetooth or BLE?

  • @MatejZimic
    @MatejZimic 5 років тому

    Hello, Where can I find Arduino code? Thank You

  • @IsraelLopezMascorro
    @IsraelLopezMascorro 6 років тому

    Great job! I am getting this error "isSocketAllowdBySecurityPolicy start :device null" Some idea? thanks

  • @SangPham-dq8br
    @SangPham-dq8br 5 років тому

    I have an error: Inactivity, disconnecting from the service.
    I don't know how to fix it. Can you help me? Thanks

  • @jonahosterried7832
    @jonahosterried7832 5 років тому

    What does he exactly send to the Bluetooth module?

  • @AceDBahrah
    @AceDBahrah 4 роки тому +1

    this is really good tutorial! everything works fine, but can it receive something from arduino??

    • @canererhadim3772
      @canererhadim3772 4 роки тому

      Good question

    • @bseyhaOLI
      @bseyhaOLI 4 роки тому

      ​@@canererhadim3772 Ben de aynı şeyi araştırıyorum ? Bu sorunu çözebildin mi

  • @cabrillafiestera
    @cabrillafiestera 4 роки тому

    Thank you so much from Spain¡

  • @kleanlins
    @kleanlins 6 років тому

    How can I read data from m_bluetoothSocket instead of write? I just want to show my arduino's data inside the app.

    • @kleanlins
      @kleanlins 6 років тому +1

      Anyway. I've discovered. Just use Reader.
      val reader = Reader(m_bluetoothSocket!!.inputStream)
      reader.nextLine() (depends on your data stream)

    • @adiilhammaulana
      @adiilhammaulana 6 років тому

      @@kleanlins hi, can u share your code ? i am new in kotlin - aimonboard@gmail.com - thanks

    • @AndreasHel197
      @AndreasHel197 5 років тому

      could any of you share your code? cant seem to figure out how to read data from the device connected.

    • @theoberessi6794
      @theoberessi6794 2 роки тому

      Hi, can you share your code please ? I can't figure it out :/

  • @rc5016
    @rc5016 6 років тому

    Great tutorial!! It works !!

  • @matiassenger2349
    @matiassenger2349 4 роки тому

    Nice tutorial! Thanks

  • @Geology0526
    @Geology0526 6 років тому

    Interesting video but how can we receive datas from an arduino to the application ? (And how can we display it ?)

    • @apptaura8131
      @apptaura8131  6 років тому

      Hi Devpax, thanks for the comment. We have a tutorial about reading data from an Arduino via Bluetooth coming very soon.

    • @onlytacobell
      @onlytacobell 6 років тому

      I can't wait for this. These tutorials are helpful, but I haven't figured out how to read my Arduino code on my own.

    • @fiqrizurani4549
      @fiqrizurani4549 5 років тому

      @@apptaura8131 do you have upload the tutorial?

    • @bseyhaOLI
      @bseyhaOLI 4 роки тому

      @@apptaura8131 Where is it ? :)

  • @rafo5547
    @rafo5547 3 роки тому

    AMAZING tutorial thanks

  • @beardedkumquat654
    @beardedkumquat654 4 роки тому

    ASyncTask has since been deprecated. Does anybody know an alternative?

    • @hannes.b
      @hannes.b 4 роки тому

      Hey, I have the same problem. Have you found an answer yet :)

    • @pablotomey9976
      @pablotomey9976 4 роки тому +1

      one alternative is Coroutines

  • @danny117hd
    @danny117hd 3 роки тому

    Consider using the screen magnifier.

  • @rikef.7349
    @rikef.7349 6 років тому +1

    This is a great tutorial, I really like it. I tried the app and everything works, but I couldn't connect to the bluetooth device. The logcat says: couldn't connect
    Do you know this problem and may know how I can fix it?

  • @JamCluster
    @JamCluster 3 роки тому

    I am trying this tutorial several days ago but using a raspberry PI but does not work, anyway, many thanks for the usefull information!

  • @richardthibault7473
    @richardthibault7473 6 років тому

    Is this a new App or an addition to Part 1

    • @apptaura8131
      @apptaura8131  6 років тому

      Hi Richard, thanks for the comment. This video is a continuation from part one, both videos make one app

  • @valentindoche4405
    @valentindoche4405 5 років тому +1

    Good Tutorial

  • @snowiethetoolguy
    @snowiethetoolguy 5 років тому

    Great tutorial!!! . Can or have you done one on getting data from an Arduino back to Android device. ie sensor data etc??

    • @snowiethetoolguy
      @snowiethetoolguy 5 років тому

      Managed to get some code written up in Kotlin.... Thanks for your effort in making these videos. As a noob i reference them often

    • @alaanasef5162
      @alaanasef5162 5 років тому +1

      @@snowiethetoolguy i am trying to read data from arduino can you refer me to that code, thanks in advance

    • @snowiethetoolguy
      @snowiethetoolguy 5 років тому

      @@alaanasef5162 contact me at scroatsac@gmail.com .I'll forward you what i have..

    • @theoberessi6794
      @theoberessi6794 2 роки тому +1

      Hi ! Can you tell us how you did it please ? i've written this code but in a loop but it the progress dialogue of the doInBackground function won't disapear :
      fun checkReceive(){
      if (m_bluetoothSocket != null) {
      var input = m_bluetoothSocket!!.inputStream
      var buffer: ByteArray = ByteArray(1024)
      var bytes: Int
      try {
      bytes = input.read(buffer)
      var incomingMessage = String(buffer, 0, bytes);
      Toast.makeText(this, incomingMessage, Toast.LENGTH_SHORT).show()
      } catch (e: IOException){
      e.printStackTrace()
      }
      }
      }

    • @snowiethetoolguy
      @snowiethetoolguy 2 роки тому

      @@theoberessi6794 I've setup a background thread the looks for data received in the BT buffer and acts on that.. whats your email I'll send you some code snippets

  • @ksaweryc
    @ksaweryc 4 роки тому +1

    Is there any possibility to display names of bluetooth devices instead of their MAC Addresses? Thanks in advance! :) (Btw great video!!!)

    • @ksaweryc
      @ksaweryc 4 роки тому +2

      OK guys I've figured it by myself :)
      Instead of ArrayList we can simpy use ArrayList and then we can add elements to our list by using "device.name".
      Code:
      val names : ArrayList = ArrayList()
      if (m_pairedDevices.isNotEmpty()) {
      for (device : BluetoothDevice in m_pairedDevices) {
      names.add(device.name)
      //Log.i("device", ""+device)
      }
      } else {
      toast("No paired BT devices found...")
      }
      val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, names)
      If I'm wrong in this point please tell me - I'm not so experienced with android studio and Kotlin :)

    • @theoberessi6794
      @theoberessi6794 2 роки тому

      @@ksaweryc I tried to replaced it like you did but the app crashed when i tried to connect to a device. It's because we use the object BluetoothDevice in the other activity, so instead i jest added your code with the alreading existing code :
      val list : ArrayList = ArrayList()
      val names : ArrayList = ArrayList()
      if(m_pairedDevices.isNotEmpty()){
      for(device: BluetoothDevice in m_pairedDevices){
      list.add(device)
      names.add(device.name)
      Log.i("device", ""+device)
      }
      } else {
      Toast.makeText(this, "No paired bluetooth devices found", Toast.LENGTH_SHORT).show()
      }
      val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, names)

  • @Medina656
    @Medina656 5 років тому

    Thanks, it works!!!

  • @Leo-wz8pu
    @Leo-wz8pu 2 роки тому

    HII .. I'm not sure, but I see too much code

  • @diegoflores4587
    @diegoflores4587 6 років тому

    why you make private the fun?

    • @apptaura8131
      @apptaura8131  6 років тому

      Hi Diego, thanks for the comment. The reason for making the functions private is because I didn't want other Classes/Activities from calling them. If there is a specific function that you want to know about please let us know.

    • @diegoflores4587
      @diegoflores4587 6 років тому

      ok ty

  • @jorgebh10
    @jorgebh10 6 років тому

    Thank you so much!

  • @MrShivamgautam1
    @MrShivamgautam1 6 років тому

    Where is the Arduino code?

    • @apptaura8131
      @apptaura8131  6 років тому

      Hi Shivam. We have added a link to where we got the Arduino code in the description.

    • @MrShivamgautam1
      @MrShivamgautam1 6 років тому

      Apps In The Sky thanks for the code! Though I have tried this code but it does not work if I change 1 and 0 with 'a' and 'b' in Arduino. So I made the app send 1 or 0 instead and it worked. Great tutorial man!👍

    • @bevx2080
      @bevx2080 2 роки тому

      @@MrShivamgautam1 In my case even 1 and 0 doesn't work :(

  • @elektronika922
    @elektronika922 6 років тому +1

    OMG, we need 2 hours to create one simple BT app to start the LED! How meny we need to create calculator app? 22 days?

  • @pavolmeravy961
    @pavolmeravy961 Рік тому

    Too bad it didn't have a sequel. Getting data into Android.

  • @TorIvanBoine
    @TorIvanBoine 5 років тому

    If it only would work.

  • @felangga
    @felangga 3 роки тому

    SOS for the morse code