(Solved) Send hexadecimal codes to a Bluetooth relay


Hi, I’m new to the community, my name is Alberto.

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.

Can you help me ?. Thanks and greetings to all. :slightly_smiling_face:

Welcome @vetono

This is the Kodular forum not the App Inventor forum. You should ask your question there if you are using App Inventor.


1 Like

Oh, I’m sorry, maybe I did not explain myself well. I have used AI2, true, but now I have started using Kodular, although I have not mentioned it.

Can you please make my post visible again? I edited my first message.

Thank you.

1 Like

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.

1 Like

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 .:smirk:

1 Like

Will do. :slight_smile:

Ok, I’m impatient to know if you can make it work. If it does not work for you, please, will you publish the code for me to try?

I wilk do it ASAP. I have homework that is more important than this, sorry.

Of course … my relay can wait :slightly_smiling_face:!

I don’t think it’s possible.

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):


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.