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

  Рет қаралды 39,655

Apptaura

Apptaura

Күн бұрын

Пікірлер: 98
@kleanlins
@kleanlins 6 жыл бұрын
I'm sorry, but how did you get that UUID?
@ASDoublecAp
@ASDoublecAp 4 жыл бұрын
Bro, I just wanted to say THANKS. You’re a genius and you saved my project. THANKS again :’)
@AndreasHel197
@AndreasHel197 5 жыл бұрын
how can i read data from the device?
@pauloborralho152
@pauloborralho152 5 жыл бұрын
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...
@sudhir1274
@sudhir1274 5 жыл бұрын
Clear and concise tutorial. Very useful.
@florianmoser7459
@florianmoser7459 4 жыл бұрын
Great tutorial! But please use a series resistor for the led.
@rmirabelle
@rmirabelle 4 жыл бұрын
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]
@Tutos-ME
@Tutos-ME 5 жыл бұрын
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 жыл бұрын
@@poobels you could also change Arduino file to expect A and B
@carlosproduction4183
@carlosproduction4183 5 жыл бұрын
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 жыл бұрын
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
@Morphinwithyou
@Morphinwithyou 3 жыл бұрын
Dude you're awesome. Thanks!
@marcocastaneda2385
@marcocastaneda2385 5 жыл бұрын
Where do I get the UUID?
@dork3nergy
@dork3nergy 5 жыл бұрын
Great tutorial. Works like a charm. Thanks!
@antonyhelsby9374
@antonyhelsby9374 6 жыл бұрын
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...
@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.
@insu1213
@insu1213 3 жыл бұрын
WoW Such an amazing tutorial Thank you so much!
@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
@eingskywalker9116
@eingskywalker9116 6 жыл бұрын
I have done exactly as you have shown here, app is working but it doesn't showing paired devices in listview
@JR_7272
@JR_7272 3 жыл бұрын
Async and a couple other things are out of date. does anyone know of an updated one?
@animongahajime9302
@animongahajime9302 4 жыл бұрын
Excellent Tutorial, but can you please help with update? AsyncTask is deprecated now and i dont know what to do :(
@ole1907
@ole1907 3 жыл бұрын
File -> Project Structure -> Modules -> Compile Sdk Version -> 28, Then is works
@syedaffanhameed14
@syedaffanhameed14 2 жыл бұрын
Hi!, how can we read the RSSI value of that bluetooth signal? can anyone please answer it?
@rafo5547
@rafo5547 3 жыл бұрын
AMAZING tutorial thanks
@matiassenger2349
@matiassenger2349 4 жыл бұрын
Nice tutorial! Thanks
@ordinarygamer5917
@ordinarygamer5917 4 жыл бұрын
How can i use toast inside postexecute in your program? 🙏
@diegoflores4587
@diegoflores4587 6 жыл бұрын
its so awesome you are the only person how do this witout appinventor ty so much
@danny117hd
@danny117hd 3 жыл бұрын
Consider using the screen magnifier.
@cabrillafiestera
@cabrillafiestera 4 жыл бұрын
Thank you so much from Spain¡
@ksaweryc
@ksaweryc 4 жыл бұрын
Is there any possibility to display names of bluetooth devices instead of their MAC Addresses? Thanks in advance! :) (Btw great video!!!)
@ksaweryc
@ksaweryc 4 жыл бұрын
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)
@AceDBahrah
@AceDBahrah 4 жыл бұрын
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
@best_songs_ever3889
@best_songs_ever3889 4 жыл бұрын
it uses bluetooth or BLE?
@jonahosterried7832
@jonahosterried7832 5 жыл бұрын
What does he exactly send to the Bluetooth module?
@rc5016
@rc5016 6 жыл бұрын
Great tutorial!! It works !!
@rikef.7349
@rikef.7349 6 жыл бұрын
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!
@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 ? :)
@IsraelLopezMascorro
@IsraelLopezMascorro 6 жыл бұрын
Great job! I am getting this error "isSocketAllowdBySecurityPolicy start :device null" Some idea? thanks
@MatejZimic
@MatejZimic 5 жыл бұрын
Hello, Where can I find Arduino code? Thank You
@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
@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 жыл бұрын
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 :/
@Medina656
@Medina656 5 жыл бұрын
Thanks, it works!!!
@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 жыл бұрын
one alternative is Coroutines
@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 жыл бұрын
@@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 жыл бұрын
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
@valentindoche4405
@valentindoche4405 5 жыл бұрын
Good Tutorial
@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
@Leo-wz8pu
@Leo-wz8pu 3 жыл бұрын
HII .. I'm not sure, but I see too much code
@jorgebh10
@jorgebh10 7 жыл бұрын
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 3 жыл бұрын
@@MrShivamgautam1 In my case even 1 and 0 doesn't work :(
@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
@pavolmeravy961
@pavolmeravy961 Жыл бұрын
Too bad it didn't have a sequel. Getting data into Android.
@elektronika922
@elektronika922 6 жыл бұрын
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?
@TorIvanBoine
@TorIvanBoine 5 жыл бұрын
If it only would work.
@felangga
@felangga 3 жыл бұрын
SOS for the morse code
Kotlin 101: How to communicate to a Bluetooth device Part 1
43:50
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Kotlin 101: How to communicate via Serial Connection Part 2
32:45
I Made a Tool to Debloat Windows in 2 Clicks
15:01
TotallyNotK0
Рет қаралды 1,1 МЛН
How do Graphics Cards Work?  Exploring GPU Architecture
28:30
Branch Education
Рет қаралды 3,1 МЛН
Bluetooth Arduino RECEIVE data + Chart
9:26
Electronoobs
Рет қаралды 312 М.
Kotlin 101: How to communicate via Serial Connection Part 1
8:55
Building Android Apps to Control Bluetooth LE Devices
38:51
CrossComm, Inc.
Рет қаралды 36 М.