Challenges of Bluetooth
-
A few years ago I wanted to see if I could activate my garage door motor from my phone. I knew if I could remotely just close the switch on the two wires of the garage door motor I could do it. I knew nothing about Arduino but knew it might be an option. I figured I could get it to activate a relay to close the switch. Next I contemplated how to send a signal wirelessly. I had a smart phone (Android) and I knew it supported a wireless protocol named Bluetooth. >BOOM< Bluetooth was trending. Enter "Classic" Bluetooth These were the days before a thing called BLE (Bluetooth Low Energy -- which is a marketing ploy). Anyways, I searched for a component which would allow me to send a signal from my Android phone to the component which would be connected to an Arduino. Here's the Bluetooth module that hobbyists use: HC-05 Wireless Bluetooth RF Transceiver[^] These BT components vary wildly by manufacturer are very cranky & often don't work to proper specs. But once you learn all that, you're on the inside. I got mine working. Security Protocol Since this would be opening my garage door I knew it would be important that no one else be able to connect to the device. Here's the really cool thing. Bluetooth is a secure transmission type which includes pairing & bonding functionality. The HC-05 allows you to set a 4-digit passcode and forces the user to enter the passcode to pair & bond (create a lifetime connection). HC-05 Stores Secret So, if you wanted to open my garage door you had to know the passcode to pair. Only once properly paired could you send the transmission which would activate the garage door motor. The bonding causes the HC-05 to store a secret that only the newly paired phone knows. For each phone that successfully enters passcode it would store a new secret for that new phone. iPhone User: BLE Only I have used an Android phone for 10 years, but I finally gave in and became a iPhone user (2 weeks ago). iPhones do not support Classic Bluetooth*. They only support BLE. I knew I needed to replace the HC-05 with one that supports BLE. I had worked with a replacement component named a HM-10 (DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board[^]). Blithely I Roll On I had great su
-
A few years ago I wanted to see if I could activate my garage door motor from my phone. I knew if I could remotely just close the switch on the two wires of the garage door motor I could do it. I knew nothing about Arduino but knew it might be an option. I figured I could get it to activate a relay to close the switch. Next I contemplated how to send a signal wirelessly. I had a smart phone (Android) and I knew it supported a wireless protocol named Bluetooth. >BOOM< Bluetooth was trending. Enter "Classic" Bluetooth These were the days before a thing called BLE (Bluetooth Low Energy -- which is a marketing ploy). Anyways, I searched for a component which would allow me to send a signal from my Android phone to the component which would be connected to an Arduino. Here's the Bluetooth module that hobbyists use: HC-05 Wireless Bluetooth RF Transceiver[^] These BT components vary wildly by manufacturer are very cranky & often don't work to proper specs. But once you learn all that, you're on the inside. I got mine working. Security Protocol Since this would be opening my garage door I knew it would be important that no one else be able to connect to the device. Here's the really cool thing. Bluetooth is a secure transmission type which includes pairing & bonding functionality. The HC-05 allows you to set a 4-digit passcode and forces the user to enter the passcode to pair & bond (create a lifetime connection). HC-05 Stores Secret So, if you wanted to open my garage door you had to know the passcode to pair. Only once properly paired could you send the transmission which would activate the garage door motor. The bonding causes the HC-05 to store a secret that only the newly paired phone knows. For each phone that successfully enters passcode it would store a new secret for that new phone. iPhone User: BLE Only I have used an Android phone for 10 years, but I finally gave in and became a iPhone user (2 weeks ago). iPhones do not support Classic Bluetooth*. They only support BLE. I knew I needed to replace the HC-05 with one that supports BLE. I had worked with a replacement component named a HM-10 (DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board[^]). Blithely I Roll On I had great su
Have you tried posting this as a Tip/Trick instead? :-)
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
Have you tried posting this as a Tip/Trick instead? :-)
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
A few years ago I wanted to see if I could activate my garage door motor from my phone. I knew if I could remotely just close the switch on the two wires of the garage door motor I could do it. I knew nothing about Arduino but knew it might be an option. I figured I could get it to activate a relay to close the switch. Next I contemplated how to send a signal wirelessly. I had a smart phone (Android) and I knew it supported a wireless protocol named Bluetooth. >BOOM< Bluetooth was trending. Enter "Classic" Bluetooth These were the days before a thing called BLE (Bluetooth Low Energy -- which is a marketing ploy). Anyways, I searched for a component which would allow me to send a signal from my Android phone to the component which would be connected to an Arduino. Here's the Bluetooth module that hobbyists use: HC-05 Wireless Bluetooth RF Transceiver[^] These BT components vary wildly by manufacturer are very cranky & often don't work to proper specs. But once you learn all that, you're on the inside. I got mine working. Security Protocol Since this would be opening my garage door I knew it would be important that no one else be able to connect to the device. Here's the really cool thing. Bluetooth is a secure transmission type which includes pairing & bonding functionality. The HC-05 allows you to set a 4-digit passcode and forces the user to enter the passcode to pair & bond (create a lifetime connection). HC-05 Stores Secret So, if you wanted to open my garage door you had to know the passcode to pair. Only once properly paired could you send the transmission which would activate the garage door motor. The bonding causes the HC-05 to store a secret that only the newly paired phone knows. For each phone that successfully enters passcode it would store a new secret for that new phone. iPhone User: BLE Only I have used an Android phone for 10 years, but I finally gave in and became a iPhone user (2 weeks ago). iPhones do not support Classic Bluetooth*. They only support BLE. I knew I needed to replace the HC-05 with one that supports BLE. I had worked with a replacement component named a HM-10 (DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board[^]). Blithely I Roll On I had great su
You didn't use an ESP32? They have embedded bluetooth and BLE into the MCU SoC, and it's like half the price of an arduino board with way more power. You can write your own pairing negotiation with it.
To err is human. Fortune favors the monsters.
-
You didn't use an ESP32? They have embedded bluetooth and BLE into the MCU SoC, and it's like half the price of an arduino board with way more power. You can write your own pairing negotiation with it.
To err is human. Fortune favors the monsters.
Thanks for reading my rant and replying. I was hoping you might offer some adivce.
honey the codewitch wrote:
You can write your own pairing negotiation with it.
I don't really want to write my own pairing negotiation. I mean the basic "Phone"-based pairing is super simple. It just works. It forces the user to provide the passcode & then stores the secret that will be used in future. However, would you mind showing me the code that would run on the ESP32? I haven't been able to determine if ESP32 will force the pairing or not, but if there is just some ESP32-based code that I call to insure the pairing runs (requests passcode & stores secret) that would be really great. I thought the Arduino Nano 33 BLE would definitely include that, but Arduino libraries don't support the pairing yet. Which I thought was crazy. Thanks again for reading.
-
Thanks for reading my rant and replying. I was hoping you might offer some adivce.
honey the codewitch wrote:
You can write your own pairing negotiation with it.
I don't really want to write my own pairing negotiation. I mean the basic "Phone"-based pairing is super simple. It just works. It forces the user to provide the passcode & then stores the secret that will be used in future. However, would you mind showing me the code that would run on the ESP32? I haven't been able to determine if ESP32 will force the pairing or not, but if there is just some ESP32-based code that I call to insure the pairing runs (requests passcode & stores secret) that would be really great. I thought the Arduino Nano 33 BLE would definitely include that, but Arduino libraries don't support the pairing yet. Which I thought was crazy. Thanks again for reading.
I've never actually used the secure/encrypted pairing feature myself, as I've never needed the security feature. I just know there's a callback for handling it in the NimBLE stack. The code you are asking for is more appropriate for an article than it is for a comments section. One of the reasons I haven't written any bluetooth articles is frankly, bluetooth doesn't actually work, and I like it when my code works. Maybe bluetooth 6 will finally work? Until then I use it only at gunpoint and when I do I wave a dead chicken over it and pray to gods I normally don't dare name. Anyway, I found this. Pairing or bonding from ESP32 Central using NimBLE stack - ESP32 Forum[^] This doesn't cover everything, but their problem hints that I could be wrong. The problem hints that the stack itself is storing credentials, which in your case is not what you want. It might be possible to change that by digging into the HAL, as the entire thing is open source, but YMMV. Never mind, I misunderstood your initial post. Forgive me, I'm a bit slow right now. Yes, the ESP32 should do what you want. I just don't use that feature but involves creating a callback and handling the key validation at which point i believe encryption is enabled. I'm not a bluetooth expert though. Frankly, I think whoever designed it should be forced to use it.
To err is human. Fortune favors the monsters.
-
I've never actually used the secure/encrypted pairing feature myself, as I've never needed the security feature. I just know there's a callback for handling it in the NimBLE stack. The code you are asking for is more appropriate for an article than it is for a comments section. One of the reasons I haven't written any bluetooth articles is frankly, bluetooth doesn't actually work, and I like it when my code works. Maybe bluetooth 6 will finally work? Until then I use it only at gunpoint and when I do I wave a dead chicken over it and pray to gods I normally don't dare name. Anyway, I found this. Pairing or bonding from ESP32 Central using NimBLE stack - ESP32 Forum[^] This doesn't cover everything, but their problem hints that I could be wrong. The problem hints that the stack itself is storing credentials, which in your case is not what you want. It might be possible to change that by digging into the HAL, as the entire thing is open source, but YMMV. Never mind, I misunderstood your initial post. Forgive me, I'm a bit slow right now. Yes, the ESP32 should do what you want. I just don't use that feature but involves creating a callback and handling the key validation at which point i believe encryption is enabled. I'm not a bluetooth expert though. Frankly, I think whoever designed it should be forced to use it.
To err is human. Fortune favors the monsters.
-
Thanks for reading my rant and replying. I was hoping you might offer some adivce.
honey the codewitch wrote:
You can write your own pairing negotiation with it.
I don't really want to write my own pairing negotiation. I mean the basic "Phone"-based pairing is super simple. It just works. It forces the user to provide the passcode & then stores the secret that will be used in future. However, would you mind showing me the code that would run on the ESP32? I haven't been able to determine if ESP32 will force the pairing or not, but if there is just some ESP32-based code that I call to insure the pairing runs (requests passcode & stores secret) that would be really great. I thought the Arduino Nano 33 BLE would definitely include that, but Arduino libraries don't support the pairing yet. Which I thought was crazy. Thanks again for reading.
-
A few years ago I wanted to see if I could activate my garage door motor from my phone. I knew if I could remotely just close the switch on the two wires of the garage door motor I could do it. I knew nothing about Arduino but knew it might be an option. I figured I could get it to activate a relay to close the switch. Next I contemplated how to send a signal wirelessly. I had a smart phone (Android) and I knew it supported a wireless protocol named Bluetooth. >BOOM< Bluetooth was trending. Enter "Classic" Bluetooth These were the days before a thing called BLE (Bluetooth Low Energy -- which is a marketing ploy). Anyways, I searched for a component which would allow me to send a signal from my Android phone to the component which would be connected to an Arduino. Here's the Bluetooth module that hobbyists use: HC-05 Wireless Bluetooth RF Transceiver[^] These BT components vary wildly by manufacturer are very cranky & often don't work to proper specs. But once you learn all that, you're on the inside. I got mine working. Security Protocol Since this would be opening my garage door I knew it would be important that no one else be able to connect to the device. Here's the really cool thing. Bluetooth is a secure transmission type which includes pairing & bonding functionality. The HC-05 allows you to set a 4-digit passcode and forces the user to enter the passcode to pair & bond (create a lifetime connection). HC-05 Stores Secret So, if you wanted to open my garage door you had to know the passcode to pair. Only once properly paired could you send the transmission which would activate the garage door motor. The bonding causes the HC-05 to store a secret that only the newly paired phone knows. For each phone that successfully enters passcode it would store a new secret for that new phone. iPhone User: BLE Only I have used an Android phone for 10 years, but I finally gave in and became a iPhone user (2 weeks ago). iPhones do not support Classic Bluetooth*. They only support BLE. I knew I needed to replace the HC-05 with one that supports BLE. I had worked with a replacement component named a HM-10 (DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board[^]). Blithely I Roll On I had great su
-
A few years ago I wanted to see if I could activate my garage door motor from my phone. I knew if I could remotely just close the switch on the two wires of the garage door motor I could do it. I knew nothing about Arduino but knew it might be an option. I figured I could get it to activate a relay to close the switch. Next I contemplated how to send a signal wirelessly. I had a smart phone (Android) and I knew it supported a wireless protocol named Bluetooth. >BOOM< Bluetooth was trending. Enter "Classic" Bluetooth These were the days before a thing called BLE (Bluetooth Low Energy -- which is a marketing ploy). Anyways, I searched for a component which would allow me to send a signal from my Android phone to the component which would be connected to an Arduino. Here's the Bluetooth module that hobbyists use: HC-05 Wireless Bluetooth RF Transceiver[^] These BT components vary wildly by manufacturer are very cranky & often don't work to proper specs. But once you learn all that, you're on the inside. I got mine working. Security Protocol Since this would be opening my garage door I knew it would be important that no one else be able to connect to the device. Here's the really cool thing. Bluetooth is a secure transmission type which includes pairing & bonding functionality. The HC-05 allows you to set a 4-digit passcode and forces the user to enter the passcode to pair & bond (create a lifetime connection). HC-05 Stores Secret So, if you wanted to open my garage door you had to know the passcode to pair. Only once properly paired could you send the transmission which would activate the garage door motor. The bonding causes the HC-05 to store a secret that only the newly paired phone knows. For each phone that successfully enters passcode it would store a new secret for that new phone. iPhone User: BLE Only I have used an Android phone for 10 years, but I finally gave in and became a iPhone user (2 weeks ago). iPhones do not support Classic Bluetooth*. They only support BLE. I knew I needed to replace the HC-05 with one that supports BLE. I had worked with a replacement component named a HM-10 (DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board[^]). Blithely I Roll On I had great su
Buy a second (and third?) HM-10 and/or have multiple relays across the switch in parallel. Either device could close the switch. I am not sure if you would need a second microcontroller or if you could manage with one. Minor update to phone app to allow selection of target device when pairing. Might be able to leave the old HC-5 in the mix as well for your old user base. You might need a mini-rack if you take this approach. Find a simple solution with stuff that already works.
-
Buy a second (and third?) HM-10 and/or have multiple relays across the switch in parallel. Either device could close the switch. I am not sure if you would need a second microcontroller or if you could manage with one. Minor update to phone app to allow selection of target device when pairing. Might be able to leave the old HC-5 in the mix as well for your old user base. You might need a mini-rack if you take this approach. Find a simple solution with stuff that already works.
englebart wrote:
Buy a second (and third?) HM-10
Great minds!! :thumbsup: I walked out to the garage and took this picture[^] of the two HM-10s connected to the garage door opener. It's not the most elegant solution, but it does work. I have a 5V / 1amp power supply (salvaged from a old (2002) PocketPC device) that I am using to power the device. When I added the 3rd HM-10 the power supply couldn't provide the amps it needed to activate the relay so I can only have two. Next, I will replace the relay [^] with a MOSFET [^] & see if I can power more HM-10s. Thanks for reading the thread and chiming in.:thumbsup:
-
englebart wrote:
Buy a second (and third?) HM-10
Great minds!! :thumbsup: I walked out to the garage and took this picture[^] of the two HM-10s connected to the garage door opener. It's not the most elegant solution, but it does work. I have a 5V / 1amp power supply (salvaged from a old (2002) PocketPC device) that I am using to power the device. When I added the 3rd HM-10 the power supply couldn't provide the amps it needed to activate the relay so I can only have two. Next, I will replace the relay [^] with a MOSFET [^] & see if I can power more HM-10s. Thanks for reading the thread and chiming in.:thumbsup: