I bought a bluetooth relay, which has a BT04-A module. With Kodular I can connect with the device once paired (PIN 1234). But in order to activate or deactivate the relay, I need to send hexadecimal codes A0 01 01 A2 to open the relay and A0 01 00 A1 to close it.
I can do this (manually) with several apps in the Play Store, like BlueSPP. But I need to do it in unattended way. That’s why I need to know how I can send these hexadecimal codes from Kodular. I have searched a lot and I have done many tests but I can not find a way to get it.
Sadly, I do not think it is possible. I have also done some research and I was nowhere to find the solution. But, we are not giving up. I will look even more and I will update you @vetono. But can you also help me? Just search what you need, at the end add keywords: “kodular app inventor thunkable makeroid appybuilder”. Why you may ask. Since they are pretty much the same platform, it will double the chances to find the results.
Hi, thanks for reply. Maybe the solution is here (Copy & Paste from another site):
Another idea that may work far better in App Inventor. In the Math blocks section using the “convert number base 10 to hex block”. This would convert, potentially, a large numeric value into a text string of hex digits. Then you can text string block functions to extract each byte from the text and send it across the BT link as byte sized hex values.
This answer was for someone who asked how they could send a 6-byte hex sequence via Kodular bluetooth component.
Maybe you or a partner in this forum can find a way to implement this possible solution. I, of course, have tried but I have not succeeded. It’s logical, I just started with Kodular and my knowledge is very limited .
Impossible is nothing. Finally, I have managed to solve the problem by myself. And, of course, I want to share it here. Actually, as so often happens, it is easier than it seems.
As I suspected, the solution is in my previous comment that I found in another forum. The key is to send the bytes sequentially, one by one, but converting them previously from Hex to Base 10, since Kodular only supports the transmission, over Bluetooth, of 1, 2 or 4-byte binary values.
For the example that I can use, in which I need to send the hexadecimal string A0 01 01 A2 to activate the relay and A0 01 00 A1 to deactivate it, it is done as follows (tested and working on the device in the upper image):