Send the data to hex

I need to send the data to hex several times, but so far had no success

did you try the convert number block?
http://ai2.appinventor.mit.edu/reference/blocks/math.html#convertnumber

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

There's hex, and there's hex.
Which hex did you want?

  • The readable version for humans, all text, or
  • the compressed version, like line feeds (\n) and carriage returns (\r) ?

For BlueTooth, the compressed version is done by sending and receiving decimal bytes in a list.

I am doing a project using a HC05 Bluetooth module, stm32 & mit app inventor. Now I send the data to hex via Bluetooth, for example, I send 5D 13 00 1E 40 40. But I don't success

I think, inbuilt conversion blocks can only convert between numbers... Alternate way to do this is to convert data to other form and then convert to hex, and reverse for converting back, check my binary converter, you may get some help converting data.

Your trying to convert to base10 Insted of byte

Your AI2 blocks look reasonable to me, so maybe it's the code on the other end.
Could you post your .ino file?

I also tested this program and even tried several other models.

You need to convert data to byte code before sending... I think...

the compressed version

Here is a sample conversion procedure and a sample call using your codes...



All blocks are draggable into your Blocks Editor.

Notice that a single SendBytes call replaces your sequence of single byte calls.

Try it and let us know if it works for you?

P.S. I improved on the parameter name, changing it from hex to hexText , but it didn't stick to the board post. Change it manually if you like.

2 Likes

thank you so much! :grinning:
Your suggested structure works fine.

1 Like

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

Can you explain a little bit about how your proposed structure works?
Can I use this data sending help to send a list like the one I uploaded?

The signed-bytes procedure is intended for people with hardware that responds to particular code sequences, like a device that would come with a complex remote control, and not for data collection purposes. It is meant to offer the coder a compact way to represent the code sequences he might read off a device manual.

It is totally useless for sending weight, age, height, etc.

You need to learn about data representation at the byte level before you can proceed any further in this project.

Be aware that signed bytes can range from -128 to 127, and unsigned bytes can range from 0-255, and remember that if you think you can squeeze a height or weight into a single byte.