React-Native with Expo and Bluetooth Low Energy for Beginners

  Переглядів 36,001

Dan's React Native Lab

Dan's React Native Lab

День тому

Finally! A tutorial on how to use Expo with Bluetooth Low Energy 🔥
Follow me on Twitter 🐦 / wa2goose
Subscribe to my Insta 📷 my handle is: dan.rnlab
Sample Project: github.com/friyiajr/BLESample...
Device:
* Android 13 Pixel 7
Also Tested On:
* Android 11 Moto G Play
* iOS 16 iPhone XR
=====================
Introduction 00:00
EAS Build Setup 01:56
Request Permissions 05:50
Device Scanning 10:37
Connect Device 12:23
Data Streaming 14:15
Disconnecting 17:32
Finished Product 18:44

КОМЕНТАРІ: 225
@DanRNLab
@DanRNLab 8 місяців тому
Looking to go deeper into IoT? Check out my video on connecting an Arduino Uno r4 to a web server Connecting Arduino to the Internet - Fullstack Internet of Things ( IoT ) with Expo ukposts.info/have/v-deo/hHWWfpB6hollmH0.html
@alexyip4469
@alexyip4469 2 місяці тому
thanks you so much. I has found this cource for bluetooth low energy for a long time. It realy useful for me!
@diosupremo4928
@diosupremo4928 Рік тому
I watched your previous video, then I discover expo, I thought okay, maybe it's not supported, and now i find you again with a great video. Thank you very much! It helped me a lot with my final project at University
@DanRNLab
@DanRNLab Рік тому
Happy to help 🙂
@supundasanthakuruppu3496
@supundasanthakuruppu3496 3 місяці тому
This was a life saver! Thank you.
@literallyshane4306
@literallyshane4306 27 днів тому
Perfect! Thanks for this video, this is exactly the use case I'd be interested in.
@DanRNLab
@DanRNLab 27 днів тому
Happy to help! 😃
@GarTheStar
@GarTheStar 8 місяців тому
Wonderful video. Ive been waiting for bluetooth with expo for some years now.
@DanRNLab
@DanRNLab 8 місяців тому
Happy you enjoyed it 🙂. Best of luck with your project!
@thuns6824
@thuns6824 8 місяців тому
In the requestPermissions method you return true in the else clause. Will it not be impossible to tell if an ios device has BLE permissions enabled or not then? I have used the onStateChange method from ble-plx library to check this but is there any better way?
@LincolnLIVE7
@LincolnLIVE7 7 місяців тому
H, Dan I tired to connect and stream data from "O2Ring " which monitor heartrate,spo2,rtwave and pulse. but i am not able to get data. can you please help me out
@swaris1326
@swaris1326 4 місяці тому
You are insane! Thank you very much.
@DanRNLab
@DanRNLab 4 місяці тому
Happy to help!
@zeeshangulzar8809
@zeeshangulzar8809 Місяць тому
hi I have a question for you. When we close the app do we need to un-monitor the characteristic as well? if not, what will happen from hardware side. Will it keep sending the values on notification channel even the app is off?
@nintendoplay360
@nintendoplay360 5 місяців тому
Hey Dan thanks for this brotha. Just subscribed. If I am using an eeg headset how would I go about creating 5 different wave type values? I have done this in MAX and am trying to transfer it to this and make it an app. I really need some help at this point. ~ dnt
@hds6857
@hds6857 4 місяці тому
I am facing with a problem but idk how to resolve It. I have a service callback in my esp32 onConnect and onDisconnect and It works when I connect it and if I disconnect the Bluetooth from my phone but if I send the order from the library react-native-ble-plx It disconnects from the phone but onDisconnect from my esp32 does not trigger to advertice so if I Bluetooth scan again my esp32 does not show until I reboot. Great video.
@erdhyernando
@erdhyernando 2 місяці тому
i'm a beginner to react and app dev but got a project to create a simple controller app to connect to raspberry pi through ssh, do you have a video or recommendation on how i can do it?
@dingomodugno8517
@dingomodugno8517 10 місяців тому
I keep getting build errors when running command "npx expo run:android". "BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 64". I have double and triple checked that everything is installed and all the environment variables are set properly. Does anyone have any ideas or have seen this? Any help would be greatly appreciated.
@jamesgartrell4462
@jamesgartrell4462 Рік тому
Hi Dan, Thank you for the amazing tutorial. It is truly nice to have someone finally walk through how to make this work without ejecting from expo. I noticed there is no license specified in your Github project repository. Given that this is a tutorial, do we have permission to use your code as a foundation for our own projects?
@DanRNLab
@DanRNLab Рік тому
Hey, no problem use it for whatever you want whether it’s a startup, personal project etc. Keep in mind though there is no warranty on this code and that I don’t guarantee it will work for medical applications or otherwise. It was meant to be a demo for a tutorial and nothing more.
@jamesgartrell4462
@jamesgartrell4462 Рік тому
@@DanRNLab Thank you so much, and again, outstanding work on the tutorial!
@kasraafshari4293
@kasraafshari4293 10 місяців тому
awesome
@kaustubsingh2933
@kaustubsingh2933 9 місяців тому
Hey Dan great video btw but I wanted to know that in order to build do we need Android studio like for sdk stuff configured on our system or just it expo will build it online?
@DanRNLab
@DanRNLab 9 місяців тому
If you want to run your builds locally you need the full setup. If not you can just use EAS
@kaustubsingh2933
@kaustubsingh2933 9 місяців тому
@@DanRNLab thank you
@giulliabraga9709
@giulliabraga9709 4 місяці тому
Hi Dan, thanks for the tutorial first of all! I found it only yesterday and it's already helped a lot, but I've been stuck just trying to build the application which seems impossible to me. Did you use an Android Studio emulator for this? I have been unable to get my emulator to work.
@DanRNLab
@DanRNLab 4 місяці тому
Hey, unfortunately simulators do not support Bluetooth at all. You need to use a physical Android or iPhone device.
@robertogonzalezz_
@robertogonzalezz_ Рік тому
Hi Dan, thanks for these videos, you help a lot! I need to use this in a project but I need to communicate with the device (asking things - using write()). In your case, for example, it would ask you what battery level your Heart Rate Device has, or make it beep to find the device. I have looked at the documentation a bit but BLE is something very new for me, if you could confirm that it really is possible, you would help me a lot! Or even if you could make a quick video on how to do this. Greetings, I appreciate you man!
@DanRNLab
@DanRNLab Рік тому
ukposts.info/have/v-deo/opV5ZoekkW6Fkmg.html In this video I do writes. It uses CLI and not Expo but the steps are very similar and should mostly translate. You just need a different library for Base64 I think
@robertogonzalezz_
@robertogonzalezz_ Рік тому
@@DanRNLab I just used the same and works 😉
@robertogonzalezz_
@robertogonzalezz_ Рік тому
Hi again! I hope you're well. I've been working a few weeks with the managed BLE + Expo project and need to automatically connect to the device when I open the app again, or even keep BLE connected and paired with the device. Do you have any idea how this could be possible with this tech stack that you use in the video? I really appreciate your help, greetings!
@DanRNLab
@DanRNLab Рік тому
Hey you can probably just store the device I’d in local storage and use it to reconnect every time the user reopens the app
@lyke3
@lyke3 7 днів тому
Hello, thanks for this video ! I have a question, when i run the command npx expo run:android, i get this error: Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED What went wrong: Execution failed for task ':react-native-ble-plx:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':react-native-ble-plx:androidJdkImage'. > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for JdkImageTransform: C:\Users\K\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar. > Error while executing process C:\Program Files\Java\jdk-21\bin\jlink.exe with arguments {--module-path C:\Users\K\.gradle\caches\transforms-3\6683fa48bcb440c054791c94c0688110\transformed\output\temp\jmod --add-modules java.base --output C:\Users\K\.gradle\caches\transforms-3\6683fa48bcb440c054791c94c0688110\transformed\output\jdkImage --disable-plugin system-modules} Can you help me
@robertogonzalezz_
@robertogonzalezz_ Рік тому
Hi Dan, I have a question. Why you pass allDevices and connectToPeripheral function from useBLE() custom hook throught function components parameters (DeviceConnectionModal) instead of calling useBLE() in this function component? Can I call this custom hook anywhere? I have this dubt because I have this use case and I want to use useBLE() in another function component and I'm getting null or undefined in everything data and functions. Thanks in advance!
@DanRNLab
@DanRNLab Рік тому
You can restructure it to work differently. Since allDevices happened to be in the state anyway I passed it in like that. You don’t need to do it that way.
@ZainKhalid-gz3vn
@ZainKhalid-gz3vn Місяць тому
Hey, Thanks for sharing. I have a question. Once a device is subscribed with a service characteristics then after some time it is getting auto disconnect. Any clue why this is happening? The error object is { "errorCode": 201, "attErrorCode": null, "iosErrorCode": 6, "androidErrorCode": null, "reason": "The connection has timed out unexpectedly.", "deviceID": "6C2E6353-13CC-BD15-A46C-471BAA05F2DA", "serviceUUID": null, "characteristicUUID": null, "descriptorUUID": null, "internalMessage": null }
@Mint577014
@Mint577014 Рік тому
Hi Dan, thank you for the video. I have some issues when I follow your old video. I use getServicesAndCharacteristics and monitorCharacteristicForService function and I use isDeviceConnected Function to make sure the Indicator device is connected. I want to get the weight value from the indicator device but the value return null. How can I do in this case? Thanks !!
@DanRNLab
@DanRNLab Рік тому
Hey, unfortunately BLE devices all behave really differently. I think it’s best to consult your manual or Firmware engineer. In the past I’ve been in weird situations where some BLE devices require you to turn on Service streaming and things like that. Others require an extra step where you “unlock” the device through a challenge response protocol. That might be what’s happening in your case. The only real way to know is to get that information from the manufacturer.
@robertogonzalezz_
@robertogonzalezz_ 11 місяців тому
Hello Dan, I propose that you make an update by adding a local push notification when the hert rate rise above a certain value, for example 120bpm. The cool thing is that it could be done while the app is in the background, you could teach a lot about this topic that there is much more ignorance on the part of the community, at least I speak for myself. I wait your answer!
@DanRNLab
@DanRNLab 11 місяців тому
I may do that for some other type of BLE application. It would be too dangerously close to do it with the Heart Rate Monitor since it’s getting close to a medical device at this point 😅. But with the iOS BLE Server simulator I created something with Real-time data should eventually be possible 🤔
@mikasidwell9885
@mikasidwell9885 Рік тому
Hi Dan. I love your videos! Please keep'em rolling. Everyone asked you for a demonstration in Expo, and so you did. You previously used react-native vanilla in some of your videos. Which would you recommend using? Are there exceptions like for freelance one is better than the other, but then if used professionally the other is recommended, and for hobbyists, etc...?
@DanRNLab
@DanRNLab Рік тому
A couple years ago I would have said Vanilla RN is better but in the last year Expo has majorly upped their game. I would recommend using Expo for new projects. With EAS Build it’s way way way more flexible then it used to be. They also manage a lot of the annoying stuff with deployment for you. I think Expo might be the new default for React-Native in the near future
@msg144
@msg144 Рік тому
Hey Dan, Great Job!!! I've extended my app to use your custom useBle hook across multiple components on multiple screens, and I have maybe a tricky question for you (or maybe it's more fundamental React): I was building my first app with ble pxe library when I saw your useMemo approach (I was stuck on maintaining one instance of bleManager - THANK YOU), and it worked... until I added multiple components (particularly on different screens) calling APIs from the custom useBle hook... what seems to be happening is that each component (on its initial render) calls one of the APIs from the useBle custom hook, which seems to refresh/rerun/reinitialize the useBle custom hook (at least the initial time for each screen), which seems to (a) clear or (b) create an additional instance of bleManager (I"m not sure which one, but I'm thinking it reruns your useMemo, hence dropping the initial bleManager and replacing it with a new bleManger, possibly without properly closing the initial one, and losing the connection). As a specific example: I scan and auto-connect fine on the first screen (just like you did; everything including measurements work)... but I have a second screen (with a different component) that let's the user disconnect from that initially connected device, rescan and connect to another device manually... when I move to that second screen (note I'm already connected to a device), the app seems to recreate bleManager (or possibly create a second one; again, I'm not positive here), which causes the app to lose the connection to the device I was connected to (I have confirmed it loses connection as any action before I open the second screen works fine, and any action after I open the second screen gives me the error that the device is not connected). I wrote a workaround (basically uses isDeviceConnected to see if the device that my RTK state says is connected is in fact connected, and if not, it reconnects with connectToDevice), but that seems clunky and I'm guessing you might have a better way? Note that I tried putting bleManager in my RTK state, which actually seems to work, but that too doesn't feel right (and I get nonSerializable errors from RTK, which I can suppress, but that doesn't seem right... I also tried serializing bleManager before putting it into my state to avoid the nonSerializable errors with JSON.stringify, then using JSON.parse to pull it back out, but I confirmed the result is not the same - maybe that's obvious, but it wasn't to me so I gave it a shot and wanted to let you know). So, all that to ask as I'm sure others will run into this as well: any advice for creating a single, persistent bleManager that survives react native re-renders, multiple components calling useBle on multiple screens?
@DanRNLab
@DanRNLab Рік тому
I don’t have access to your source code so I don’t really know what is going on. I think putting BLEmanager as a variable global to the app might be another approach you can try. Something like this: github.com/friyiajr/BluetoothLowEnergySample/blob/main/useBLE.tsx#L18
@msg144
@msg144 Рік тому
@@DanRNLab Thanks Dan, I think you're probably right on the approach (I've been so trained not to use globals I didn't think of that), but I don't see a global for bleManager in the example you provided... instead, it looks like the same way you called it before adding useMemo: const bleManager = new BleManager()... maybe I'm missing it?
@DanRNLab
@DanRNLab Рік тому
I declare it outside the hook in that example and not inside the hook
@B-kk6zp
@B-kk6zp 3 місяці тому
Also interested in this, did you make any headway @msg144? I've been chasing down all sorts of rabbit holes with redux+saga etc, but wondering if it really needs to be that complex...
@RidwanHD
@RidwanHD Рік тому
Great video! 2 Questions 1. Was prebuild necessary since I assume npx expo run:android would run prebuild regardless 2. You can still build iOS Locally right? Thre should be no reason to use EAS Build if you have xcode setup
@DanRNLab
@DanRNLab Рік тому
Yes you can run that command with the -device flag and build to any device you have hooked up to your machine
@justinkerr4628
@justinkerr4628 Рік тому
Hi so I have a random question that kinda pertains to the video, So im looking to connect a bluetooth clicker to an app like you hit a button ( only one button) and it does something in the app. Is it the same process as the other videos you've done? Im new to react native and trying to figure this all out.
@DanRNLab
@DanRNLab Рік тому
It’s certainly possible. It would depend on how you set up the clicker though. It would need to be an advertizer. My tutorials only deal with the client side
@furkanturkylmaz3781
@furkanturkylmaz3781 Рік тому
Hi Dan, I know I've asked you a lot of questions, but I have one last question left. I want to get the application I made as apk, but the apk I got from the "eas" page comes with an expo interface and works by communicating with a local server, that is, our terminal, but I want a pure apk directly.
@DanRNLab
@DanRNLab Рік тому
Hey, it depends on your audience for this build. I recommend checking out the Expo documentation on this topic docs.expo.dev/build/introduction/
@gofo9974
@gofo9974 Рік тому
Great video! grats! i am having some issues when i am trying to deploy it, can u please tell me wich version of SDK and java are u using? It is necessary install gradle? thanks!
@DanRNLab
@DanRNLab Рік тому
Hey you are right. To do this you need to install some native tooling to build locally. I recommend installing Android studio and any Java version 8 or above
@gofo9974
@gofo9974 Рік тому
@@DanRNLab Thanks! works using expo start --android because it was showing an error with the build, greetings from colombia and thanks again 👍
@nickwilliams6218
@nickwilliams6218 6 місяців тому
Hey Dan! Thanks for the tutorial! How exactly did you get your project running on your real Android device? I am trying to do this so I can test the Bluetooth functionality. It seems that Android Studio does not support Bluetooth.
@DanRNLab
@DanRNLab 6 місяців тому
Hey, so yes Android Simulators do. It support Bluetooth. You should just be able to plug in your phone and run the same commands I did. adb should detect your device
@digimonk-ym7br
@digimonk-ym7br Рік тому
nice
@ggchicote
@ggchicote 10 місяців тому
Hi Dan, thank you and congratulations on your videos, I found them a few weeks ago. I started a personal project and bought some Beacon Proximity devices (Estimote). I'm stuck at the beginning because they don't provide a React Native library, so I'm trying to create a bridge between the native SDKs (Android and iOS) and Expo or React Native. It's proving to be very difficult because I can't find a clear guide that explains how to do it, and my knowledge of Java/Kotlin and Swift is almost non-existent. I have a question for you, does the library you mention in the project work for proximity devices with BLE technology? I found this more up-to-date library, react-native-ble-manager, do you think it's better? Thanks!!!
@DanRNLab
@DanRNLab 10 місяців тому
I think you can follow this tutorial and avoid making native stuffs. I talk about CLI here but it should be no different in Expo. They use the same BLE library How to use Bluetooth Low Energy ( BLE ) Beacons with React-Native ukposts.info/have/v-deo/aZiKgZWqm4eUo4k.html
@ggchicote
@ggchicote 10 місяців тому
@@DanRNLab You mean to following that other tutorial, trying to use the same library (react-native-ble-plx) while ignoring the native code and utilizing Expo (prebuild), as you explain in this tutorial?
@DanRNLab
@DanRNLab 10 місяців тому
Yeah you’ll need to combine the two. This one shows you how to set up BLE with Expo. The next one shows you how to set up beacons with RN BLE. They all use the same library though. react-native-ble-plx
@ggchicote
@ggchicote 10 місяців тому
@@DanRNLab Thank you very much. I really appreciate it!!!
@ggchicote
@ggchicote 10 місяців тому
@@DanRNLab Hi dan! Do you have any idea why i am getting this error: [BleError: Cannot start scanning operation]?
@mbagideon6607
@mbagideon6607 10 місяців тому
nice video....do i have to do the eas-build setup if clone and run the project?
@DanRNLab
@DanRNLab 10 місяців тому
You can also use npx expo run:android npx expo run:ios Assuming you have Android Studio and Xcode set up. Remember that this tutorial must be done on a physical device and not an emulator. You also cannot use expo go you need to use the custom version of Expo that prebuild or EAS builds for you
@rileymorgan8845
@rileymorgan8845 Рік тому
Hey Dan, thank you so much for this video! I found it extremely useful and easy to follow. I have been looking for this sort of breakdown of implementing BLE in react native for a while. While following the tutorial I did come across an error I wanted to ask you about. I am receiving a render error with the message " Cannot read property 'createClient' of null". Is this something you have come across before or do you have any tips on where I may look to fix this error? Thanks again for you help and for the great tutorial!
@rileymorgan8845
@rileymorgan8845 Рік тому
TypeError: Cannot read property 'createClient' of null This error is located at: in App (created by withDevTools(App)) in withDevTools(App) in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in main(RootComponent), js engine: hermes at node_modules/react-native/Libraries/Core/ExceptionsManager.js:102:17 in reportException at node_modules/react-native/Libraries/Core/ExceptionsManager.js:148:19 in handleException - ... 7 more stack frames from framework internals
@DanRNLab
@DanRNLab Рік тому
When I’ve had this before it’s usually a problem with permission. You should look into double checking that you did them correctly
@rileymorgan8845
@rileymorgan8845 Рік тому
@@DanRNLab Thanks I will go and check. I appreciate your response!
@moyando9695
@moyando9695 Рік тому
@@rileymorgan8845 did you got how to solve?
@moyando9695
@moyando9695 Рік тому
@@DanRNLab I'm receiving the same error message after doing your tutorial even with the sample project... Do you have any ideas of how to solve this?
@CarlosEnmanuelOliveriMartinez
@CarlosEnmanuelOliveriMartinez 25 днів тому
Hi, i'm use "eas build --profile development --platform android" to prove it on my smartphone instead expo prebuild, that i understand serves the same purpose, but i have the exception of "Cannot read property 'createClient' of null" when BleManager() constructor is called, this could be due to use another method to build the app?
@DanRNLab
@DanRNLab 25 днів тому
It sounds like possibly the config plugin isn’t run. Not sure why that would happen though
@furkanturkylmaz3781
@furkanturkylmaz3781 Рік тому
Hello Dan, thank you for the great video. I have a question for you. How can we run this project on our own physical device? Normally, I can run my expo projects on my own phone, but it didn't work for this project. However, it works on a virtual device.
@DanRNLab
@DanRNLab Рік тому
Hey, you need to follow the steps I used in the video for using EAS Build. You can’t use Expo GO.
@Ner0176
@Ner0176 11 місяців тому
Hi Furkan, I am just a beginner with expo and React Native, so maybe the way I'll tell you right now it's wrong, but at least it worked for me. I executed the command expo start --localhost --android and in expo go I selected the development build option! I hope it works for you as well!
@sandaraly4053
@sandaraly4053 Місяць тому
do we need to pay apple developer program ( 99$ ) to use ble on iphone? thanks you for answers all.
@DanRNLab
@DanRNLab Місяць тому
You don’t need to use EAS to build the app but I haven’t tried to do this without a developer account. I recommend asking this in the Expo discord discord.com/invite/expo
@lm3allem9
@lm3allem9 Рік тому
Hello, Dan! This video was AMAZING!! Love it very much:) But can you make an app that connects to bluetooth headphones and disconects when you click?
@DanRNLab
@DanRNLab Рік тому
Hey, unfortunately this tutorial won't work for headphones. Those use Bluetooth Classic which is different then Bluetooth Low Energy
@user-vh9dc3dm1v
@user-vh9dc3dm1v 2 місяці тому
Hi dan can you mention the java sdk version, Gradle version, that ble supports that would be a grate help.
@DanRNLab
@DanRNLab 2 місяці тому
Hey you can just clone the repo, run the prebuild and look at the gradle file
@Mizerski_YTB
@Mizerski_YTB 11 місяців тому
I'm having difficulty running unit tests with React Native BLE Manager. Every time I try to execute the command 'yarn test,' it fails, and I can't find any relevant content on it either. Do you know how to do it?
@DanRNLab
@DanRNLab 11 місяців тому
I am not aware of any content on it. I think you would need to create a sophisticated mock for it unfortunately
@bilord1164
@bilord1164 7 місяців тому
Hello, i have a problem after "npx expo prebuild" i dont see any phone on my screen and after "npx expo run:android" i get error "CommandError: No Android connected device found, and no emulators could be started automatically." Did i misss something or it was explained in your other video?
@DanRNLab
@DanRNLab 7 місяців тому
Usually that means your computer can’t find your phone. You should make sure your Android phone is in developer mode and adb is configured correctly
@user-bt3xd8fd8v
@user-bt3xd8fd8v 11 місяців тому
Hi Dan and thanks for the helpful videos! Could you show how to scan for BLEs when the app is off and the screen is off. As I undestood after android 11 this task is quite challanging and there is almost no info that I can find on that topic.... thanks in advance
@user-bt3xd8fd8v
@user-bt3xd8fd8v 9 місяців тому
Hi Dan , could you please just give a sign if such functionality is possible using react native. I'm really stuck... I'm trying to get notification when the beacon is in range and the screen is locked.
@DanRNLab
@DanRNLab 9 місяців тому
I am not really sure if it is possible or not. I haven’t tried this with the screen locked before
@marinespaak2550
@marinespaak2550 6 місяців тому
@@user-bt3xd8fd8v @DanRNLab Hello ! thanks a lot for the tutorial. Have you found more information during the last monthes, concerning a way to scan BLE when app is OFF or in the background ?
@santiagomendez1787
@santiagomendez1787 2 місяці тому
Hi Dan, first of all, excellent video, it is very helpful, the second thing is that I'm trying to create something similar to what you show here, but the BPM data read them with the app so this is closed and then send this data to a backend and then treat them for features such as sms or emergency calls according to the data, do you see it viable? do you know how I could guide me? I would appreciate any help. its for my thesis:D
@DanRNLab
@DanRNLab 2 місяці тому
I think it depends on what you mean by closed. Does the device close it? Or do you mean you just don’t want to show it to the user? Also do you want this to run when the app is backgrounded or the screen is locked?
@santiagomendez1787
@santiagomendez1787 2 місяці тому
when it is not running, as the last two options you mention, both the application in the background and the cell phone is locked. Basically the user does not have to be with the app open, something portable for common use.@@DanRNLab
@santiagomendez1787
@santiagomendez1787 2 місяці тому
@@DanRNLab when it is not running, as the last two options you mention, both the application in the background and the cell phone is locked. Basically the user does not have to be with the app open, something portable for common use.
@DanRNLab
@DanRNLab 2 місяці тому
I haven’t tried to use this library with the screen locked or the app backgrounded. You’ll need to experiment with that I think
@YosephTeki
@YosephTeki 9 місяців тому
Hi Dan, thank you for this great tutorial. i get error cannot read property 'useMemo' of null, any idea to fix it?
@DanRNLab
@DanRNLab 9 місяців тому
That is a strange one since useMemo is part of React. You make have forgot to do yarn install or import useMemo from React
@cambrown2564
@cambrown2564 8 місяців тому
Hey@@DanRNLab , I am getting the same issue but it is not the useMemo, it seems to be on the new BleManager(), inside the useMemo. Any advice?
@DanRNLab
@DanRNLab 8 місяців тому
If you want to avoid this problem you should use a full state manager. This video was just meant to show the basics. Here is a tutorial on the full setup: Redux-Toolkit ( RTK ) and Bluetooth Low Energy ( BLE ) in React-Native ukposts.info/have/v-deo/gYd2dZunfXlhxqM.html
@gofo9974
@gofo9974 Рік тому
Hello, How can i do if i want to build and app that read a serial data from a sensor, it is a microcontroller build it by me, thanks for the info.
@DanRNLab
@DanRNLab Рік тому
You should be able to adapt this tutorial to read data from services and characteristics that you program into your BLE device. As for how to make the firmware, I don’t know how to do that. I’ve only worked on the Client side of BLE and have never had to build the BLE Broadcasters myself.
@benedictvillafuerte8595
@benedictvillafuerte8595 Місяць тому
Hey dan, amazing video first of all! Second, i have a question in regards to this…will this still work if i change from a managed workflow to a bare using npx expo pre build? Im also using Expo Go at the moment
@benedictvillafuerte8595
@benedictvillafuerte8595 Місяць тому
Also, would i need the EAS build?
@DanRNLab
@DanRNLab Місяць тому
Thanks happy to help! So this does use the bare workflow not the managed workflow so you should already be OK. You don’t need to use EAS, I haven’t done it before but the Expo team does say you can just build and deploy locally. You don’t need their service it just makes things easier as your team gets larger and your application scales. For a small solo team you probably don’t need EAS.
@benedictvillafuerte8595
@benedictvillafuerte8595 Місяць тому
thank you so much@@DanRNLab! One other thing, transitioning to a bareworkflow yet using Expo Go should allow me to use react-native-ble-plx right? and bypass the obstacle of not being able to use it? (My project requires me to use Expo Go)
@DanRNLab
@DanRNLab Місяць тому
Unfortunately no, you can’t use Expo Go with this library. It is a native dependency that isn’t built into Expo Go. You can’t access BLE without the Bare Workflow. You might be able to use custom dev clients if distribution is your concern
@benedictvillafuerte8595
@benedictvillafuerte8595 Місяць тому
thank you so much!@@DanRNLab
@LUCIFER-qr4og
@LUCIFER-qr4og 2 місяці тому
Hey , Dan i am using and esp32 module to connect it with mmy react native app to deliver heart rate with a heartrate sensor will this code work for it??
@DanRNLab
@DanRNLab 2 місяці тому
If you are using BLE you should be able to do something similar
@DanRNLab
@DanRNLab 2 місяці тому
In this video I connect to an Arduino Uno R4 Wifi which has a built in ESP 32 - Bluetooth Low Energy ( BLE ) Peripherals with Arduino for Beginners ukposts.info/have/v-deo/q5l6h2iao5yntmw.html
@gabrielfranco683
@gabrielfranco683 Рік тому
hey, thanks for the video, will help me a lot. I am stuck with this error: TypeError: null is not an object (evaluating '_BleModule'), double checked permissions, followed exactly what you did, no success...
@DanRNLab
@DanRNLab Рік тому
Hey @Gabrel Franco I tried in a variety of ways to reproduce this on my end but had no luck. Might be best for you to clone the sample project in the description and compare the code I wrote to yours
@swaris1326
@swaris1326 Місяць тому
Can we publish or run a production version of such an app, since it cannot be ran on Expo Go?
@DanRNLab
@DanRNLab Місяць тому
You can certainly publish a production version using Expo Application Services or by making a release build locally and uploading it like you would for a native app.
@swaris1326
@swaris1326 Місяць тому
@@DanRNLab Thanks a lot!
@furkanturkylmaz3781
@furkanturkylmaz3781 Рік тому
Hello Dan, I was able to establish a connection with my device using your video and successfully send and receive data in the "connectToDevice" section. However, it doesn't make sense to work in that section, so after making the necessary changes in the "startStreamingData" section, I made a few modifications to the "onHeartRateUpdate" section according to my needs, but I'm not receiving any data at all, and the program doesn't even pass through the "onHeartRateUpdate" section. Can you please help me? I'm very desperate. :(
@DanRNLab
@DanRNLab Рік тому
Hey so there are a couple things to try here. First make sure you are calling subscribeToAllServicesAndCharacteristics before you try and stream any data. This is key nothing will work without it. If you are already doing this the problem may be with the device. You may have to send it some signal to start streaming. I have no way of knowing what that would be though. You’d need to use your manual or contact the device manufacturer
@furkanturkylmaz3781
@furkanturkylmaz3781 Рік тому
@@DanRNLab Thank you for your response. Could it be because there is no service definition for a subscription process in my device's services? In other words, even if your code is actually working, there may not be such a definition for the service that is running in the background.
@DanRNLab
@DanRNLab Рік тому
I haven’t had to work at the hardware side at all so I am not sure how to debug that part. I usually just get the information on what I need to do from the Firmware engineer and consume their data as a client.
@tamtadumbadze6209
@tamtadumbadze6209 Рік тому
Hey Dan, thanks for the video! Trying to set up the application for ios. Logged in to my Apple account, however I get such error: "Authentication with Apple Developer Portal failed! You have no team associated with your Apple account, cannot proceed. (Do you have a paid Apple Developer account?)" Do I need paid membership in order to run for ios?
@DanRNLab
@DanRNLab Рік тому
Hey, if you have Xcode installed you should also be able to use this command to build locally: Npx expo run-ios -device
@tamtadumbadze6209
@tamtadumbadze6209 Рік тому
@@DanRNLab I have Xcode installed. When I tried to run 'npx expo run-ios -device' command I receive 0.6.2 as an output. How can I get the QR code to run the app?
@DanRNLab
@DanRNLab Рік тому
If you use that command you shouldn’t need the QR code. If you have your iPhone plugged in and wait a bit it should just install on the phone you selected from the menu.
@tamtadumbadze6209
@tamtadumbadze6209 Рік тому
@@DanRNLab So, as I understood I have to plug my iPhone into mac, open project in Xcode, select the device from the Xcode menu and after running 'npx expo run-ios -device' command I should be able to run the app? I have my iPhone plugged in. Should I open the expo-ble-sample folder in Xcode? I am unable to do it. When I tried opening ios folder, it has an endless loading.
@DanRNLab
@DanRNLab Рік тому
Not quite, you just need Xcode so that expo has access to the binaries to build your app. The steps would just be this: 1. In the terminal go to the root directory of your project 2. Plugin in your iPhone 3. Run the command which will list a bunch of simulators and your physical device 4. Choose your device from this list 5. Let it compile and wait a minute or so. The binary should install and open on your phone automatically
@amilaupendra7724
@amilaupendra7724 10 місяців тому
can i use this method for bluetooth printing with expo?
@DanRNLab
@DanRNLab 10 місяців тому
Only if the printer is Bluetooth Low Energy and not Bluetooth Classic
@123vitaha
@123vitaha 8 місяців тому
That is does not working at all Ill use expo and even if I download your code that is not working
@DippsoN
@DippsoN Рік тому
more expo, please 🙏
@DanRNLab
@DanRNLab Рік тому
💯 planning to do more Expo stuff
@MHonRomero
@MHonRomero 10 місяців тому
Hi Dan im confused when i start to run in video part 10:27 im getting this error This error is located at: in App (created by withDevTools(App)) in withDevTools(App) in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in main(RootComponent), js engine: hermes ERROR TypeError: Cannot read property 'createClient' of null
@DanRNLab
@DanRNLab 10 місяців тому
Hey this often happens if you are doing one of these things: 1) using an emulator and not physical hardware 2) using Expo Go instead of the custom dev client
@MHonRomero
@MHonRomero 10 місяців тому
@@DanRNLab oh i see but this is also may work for smartwatch device right? thats what im trying to connect now china smartwatch E600
@DanRNLab
@DanRNLab 10 місяців тому
@@MHonRomero It will only work if the Smart watch is Bluetooth Low Energy. It will not work if it uses Bluetooth Classic
@clementchoeur8228
@clementchoeur8228 Рік тому
Hi, i followed the video step by step but when i launch my application i get the following error. 'Cannot read property 'createClient' of null, js engine:Hermes, what Can i do ?
@lobbitv108
@lobbitv108 Рік тому
Same problem
@DanRNLab
@DanRNLab Рік тому
Please see this issue: github.com/friyiajr/BLESampleExpo/issues/1 . You are probably using Expo GO when you should be using prebuild.
@khanhnguyenduy7194
@khanhnguyenduy7194 10 місяців тому
Hi Dan. Thank you for your list tutorial videos I have a question My Device have password for Unlock. Now, I unlock it to click on button and it unlock immediately but if I do not have password so can I looping from 000 - 999 to find out correct password of devices is it possible ?
@DanRNLab
@DanRNLab 10 місяців тому
I don’t really know about this. Some devices will just lock you out after 3 or so attempts. I don’t think it’s will work
@khanhnguyenduy7194
@khanhnguyenduy7194 10 місяців тому
@@DanRNLab tks for your advice
@thuns6824
@thuns6824 9 місяців тому
What can I do about event emitter warning?
@DanRNLab
@DanRNLab 9 місяців тому
It’s a bug with the library. Doesn’t do anything harmful though so you can just silence it or ignore.
@JanKowalski-kz8ws
@JanKowalski-kz8ws Рік тому
I did step by step, but on Android it gives me the message: "Render Error null is not an object (evaluating '_BleModule.BleModule.createClient')" Maybe someone has any suggestions?
@DanRNLab
@DanRNLab Рік тому
There are a few things to try. First, make sure Bluetooth is on on your device. Sometimes I forget it’s not on and can’t connect. Second, delete the app and reinstall. Make sure all the permissions are requested when you try and connect again after reinstalling. If that doesn’t work then clone my version of the project in the description and see if you can find the differences in the useBLE.ts File
@DanRNLab
@DanRNLab Рік тому
Please see this issue: github.com/friyiajr/BLESampleExpo/issues/1. You are probably using Expo GO when you should be using prebuild
@calrogerscal7018
@calrogerscal7018 Рік тому
hey dan, can this work for android platform?
@DanRNLab
@DanRNLab Рік тому
Yes it does, in fact I am using a Pixel 7 in that video
@renancastro9051
@renancastro9051 2 місяці тому
Hello, I have a Xoss heart belt, it has the same uuid, I cloned your git and it still doesn't appear on Bluetooth, could you give me any tips on how it can appear?
@DanRNLab
@DanRNLab 2 місяці тому
You probably need to change the name of the filtered devices when scanning. I have it set to filter for CorSense or something
@renancastro9051
@renancastro9051 2 місяці тому
@@DanRNLab Thank you very much, that was it
@renancastro9051
@renancastro9051 2 місяці тому
@@DanRNLab If I update to SDK 50 will it break the application?
@DanRNLab
@DanRNLab 2 місяці тому
Happy to help. I don’t know about updating. I haven’t tried.
@GoMove-ik6vp
@GoMove-ik6vp Місяць тому
Can I use this on two different pages? I have tried and it gives me an error, it always closes the application
@ipcian
@ipcian 9 місяців тому
Can react-native-ble-plx send modbus data ???
@DanRNLab
@DanRNLab 9 місяців тому
I don’t think so. It doesn’t look like that protocol uses BLE but it something different. There may be a way to make them compatible but I am unaware of it
@ipcian
@ipcian 9 місяців тому
@@DanRNLab Thanks
@ipcian
@ipcian 9 місяців тому
@@DanRNLab it is possible !! I did it !!
@lakshaysagarrana3965
@lakshaysagarrana3965 Рік тому
why does not `npx expo run:ios` work for you ?
@DanRNLab
@DanRNLab Рік тому
That command will work fine if you want to use it. Just remember the -device flag. This tutorial will not work on simulator since they don’t support Bluetooth.
@lakshaysagarrana3965
@lakshaysagarrana3965 Рік тому
@@DanRNLab oh i see , thanx just trying to figure this expo thing
@Clytax
@Clytax 8 місяців тому
So you have to prebuild? It sucks because on windows you can only prebuild for android and not ios ...
@DanRNLab
@DanRNLab 8 місяців тому
You can use EAS Build free Tier if you want to build for iOS
@Clytax
@Clytax 8 місяців тому
@@DanRNLab ah that works there too? good to know thanks ^^
@uchieu6378
@uchieu6378 9 місяців тому
how I can get UUID and characteristic UUID
@DanRNLab
@DanRNLab 9 місяців тому
You need to get them from a Data Sheet or your Firmware Engineer.
@uchieu6378
@uchieu6378 9 місяців тому
@@DanRNLab I connect with my usb ble device but after that I got null of serviceUUIDs
@DanRNLab
@DanRNLab 9 місяців тому
Unfortunately I am not sure why. It probably has something to do with how your BLE device works. Without it tho I can’t give much advise
@uchieu6378
@uchieu6378 9 місяців тому
@@DanRNLab thanks
@tamasgreguss508
@tamasgreguss508 9 місяців тому
What is this VS Code theme?
@DanRNLab
@DanRNLab 9 місяців тому
It is poimandres. You can find it here: marketplace.visualstudio.com/items?itemName=pmndrs.pmndrs
@cambrown2564
@cambrown2564 8 місяців тому
is there no way to test this in the IOS simulator?
@DanRNLab
@DanRNLab 8 місяців тому
Bluetooth Low Energy cannot be tested on any Simulator iOS or Android
@cambrown2564
@cambrown2564 8 місяців тому
@@DanRNLab how are you doing it in this tutorial when you are showing the results in the simulator?
@DanRNLab
@DanRNLab 8 місяців тому
I am hooking up my physical mobile device to QuickTime (iOS) or Vysor (Android) so you can see the changes I am making. I don’t use Simulators in this tutorial
@cambrown2564
@cambrown2564 8 місяців тому
@@DanRNLab Thank you very much I appreciate the clarification. So you are running the app on your phone using Expo then the bluetooth is working? I am getting issues with initializing BleManager?
@DanRNLab
@DanRNLab 8 місяців тому
Usually when that happens it’s because you are using Expo Go and not the app that ‘npx expo run:android-device’ generates for your phone. You can’t use Expo Go here
@P0lntL3sS
@P0lntL3sS Місяць тому
Hey Dan quick question, since @config-plugins/react-native-ble-plx itself sets up the plugin for us, do we still need to copy your plugin setup? Also @config-plugins/react-native-ble-plx itself is depreciated and it sets up everything itself. How does that change things?
@DanRNLab
@DanRNLab Місяць тому
I haven’t had time to test it myself but I have seen that there is an official plugin now. I recommend trying the updated official one first then falling back on what I use if it doesn’t work
@shyye_
@shyye_ Місяць тому
When I type this command: npx expo install react-native-ble-plx @config-plugins/react-native-ble-plx I get this error: --- › Installing 2 other packages using npm npm install --save react-native-ble-plx @config-plugins/react-native-ble-plx npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: expo-ble-app@1.0.0 npm ERR! Found: expo@50.0.14 npm ERR! node_modules/expo npm ERR! expo@"~50.0.14" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer expo@"^49" from @config-plugins/react-native-ble-plx@7.0.0 npm ERR! node_modules/@config-plugins/react-native-ble-plx npm ERR! @config-plugins/react-native-ble-plx@"*" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. --- Do I need to downgrade the Expo version or should it work for the newest version?
@DanRNLab
@DanRNLab Місяць тому
There is now an official plugin for BLE PLX. Please try this one github.com/dotintent/react-native-ble-plx?tab=readme-ov-file#expo-sdk-43
@ChristopherAdams1
@ChristopherAdams1 6 днів тому
What I tried was omit the part after @config and just add config to the app.json in docs Dan mentioned: [ "react-native-ble-plx", { "isBackgroundEnabled": true, "modes": ["peripheral", "central"], "bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices" } ] So just the npx expo install react-native-ble-plx I also had to remove the @config part from the app.json and eas.json
BLE with ESP32 tutorial part 1: the Server
25:23
MoThunderz
Переглядів 68 тис.
Мама и дневник Зомби (часть 1)🧟 #shorts
00:47
КАК ГЛОТАЮТ ШПАГУ?😳
00:33
Masomka
Переглядів 2,1 млн
Лизка заплакала смотря видео котиков🙀😭
00:33
Moving Off React Native
20:50
Theo - t3․gg
Переглядів 163 тис.
React Native Tutorial for Beginners - Build a React Native App
2:06:30
Programming with Mosh
Переглядів 2,9 млн
MagicBox - ESP32 BLE + React Native Android App
1:24
tanat44
Переглядів 2,3 тис.
Bluetooth Low Energy ( BLE ) Peripherals with Arduino for Beginners
7:03
Dan's React Native Lab
Переглядів 7 тис.
ESP32 Step Tracker Tutorial React Native & Bluetooth
38:17
Taylor Galbraith
Переглядів 10 тис.
Mysterious AI Robot "Astribot S1" SHOCKS Everyone
16:18
AI Search
Переглядів 27 тис.
КАКОЙ ЛИНУКС ВЫБРАТЬ В 2024
24:21
PLAFON - Канал о линуксе
Переглядів 443 тис.
Master BLE Basics in Just 10 Minutes: The Ultimate Guide!
9:15
Novel Bits
Переглядів 86 тис.
Broken Flex Repair #technology #mobilerepair
0:55
ideal institute aligarh
Переглядів 15 млн
''Бесплатные умные'' домофоны для глупых людей. За чей счет банкет?
12:48
Вадим Шегалов.Оккультные игры элиты
Переглядів 21 тис.
GitHub Copilot just got promoted to Captain
4:01
Fireship
Переглядів 406 тис.
How Neuralink Works 🧠
0:28
Zack D. Films
Переглядів 12 млн