Matlab - hexadecimal number conversion | MATLAB IoT Analytics | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Matlab - hexadecimal number conversion
No permission to create posts
January 4, 2018
9:22 am
Avatar
avbuuren
New Member
Members
Forum Posts: 1
Member Since:
January 4, 2018
sp_UserOfflineSmall Offline

Hi, i would like to ask for help.

I am sending value to thingspeek periodically (lets say every 5 minute) where the original message is number. But the transmission changes the string(number value) into hex format, so instead of 40 i do receive 3430, after 5 minutes instead of value lets say 45 i receive 3435 and so on. I want to plot original values. I started with analysis tool writing code below, but i need help with function for changing hexadeciaml value back into original value.

readChannelID = xxxxx;
readAPIKey = 'xxxxxx;
writeChannelID = xxxxxx;
writeAPIKey = 'xxxxxx;

data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey,'OutputFormat','table');
analyzedData = data;

analyzedData.('Counter') = data.('Counter');
thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);

Tank you
January 4, 2018
11:09 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 691
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

try this:

value = '3435';

intConvert=str2num(char(sscanf(value,'%2x')'))

notice that value has to be a character vector.

If you can keep the device or program that is posting from converting to hex, ThingSpeak will definitely accept field values as string.  However, adding a string manipulation class your code may not be easy if you are using a limited hardware.  

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Sahil Nair, ahancity, samexpert, Senseworks, h-kasiri, kleifimmakly

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457