Value of 3072 for absolute Humidity | ThingSpeak API | Forum


Please consider registering

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
Value of 3072 for absolute Humidity
No permission to create posts
March 11, 2019
5:32 am
New Member
Forum Posts: 4
Member Since:
March 11, 2019
sp_UserOfflineSmall Offline


I encountered a problem with my thingspeak data. I want to get the absolute humidity values out of temperature and relative humidity and automatically write the data to the same channel. So i set up a code and a timecontrol where it runs the code every 15 minutes. The problem is that it often displays the value "3072" and it seems like it happens inbetween the times the code is supposed to run. i attached a screenshot of how it looks like. I also cant run the code more often because the minimal periods are 5 minutes and the error occures even if i do that. I think it has to do with the sensors i use transmitting data at a set time (e.g. every 2 minutes) and if theres no data from the Code during that moment it turns into 3072. Im thankfull for any help.

readChannelID = *******;
readAPIKey = '****************';

T = thingSpeakRead(readChannelID, 'Fields',1, 'ReadKey', readAPIKey,'NumMinutes',120)
rF = thingSpeakRead(readChannelID, 'Fields',2, 'ReadKey', readAPIKey,'NumMinutes',120)

BrF = ~isnan(rF);
IndicesrF = arrayfun(@(x) find(BrF(:, x), 1, 'last'), 1:size(rF, 2));
rF = arrayfun(@(x,y) rF(x,y), IndicesrF, 1:size(rF, 2));

BT = ~isnan(T);
IndicesT = arrayfun(@(x) find(BT(:, x), 1, 'last'), 1:size(T, 2));
T = arrayfun(@(x,y) T(x,y), IndicesT, 1:size(T, 2));


aF = (6.112*exp((17.67*T)/(T+243.5))*rF*18.02)/((273.15+T)*100*0.08314)

aFaR = round(aF,2)

writeChannelID = ******;
writeAPIKey = '******************';

thingSpeakWrite(writeChannelID, 'Fields',[4],'Values',aFaR, 'WriteKey', writeAPIKey)

sp_PlupAttachments Attachments
March 12, 2019
9:26 am

Forum Posts: 669
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

I would definitely recommend setting up a second channel to hold the results. If your device (or something else) is writing values to the same channel, then may collide with the writes from your analysis. That may be why you aren't allowed to write as often as you wish.

For the calculation, I did some simulation and algebra but I wasnt able to fins a solution that leads to 3072. I would also record the values of rF and T that you read to make sure they are coming as you expect. Once you debug the problem, you can remove them.

You could use

thingSpeakWrite(writeChannelID, 'Fields',[4 5 6],'Values',[aFaR, rF,T], 'WriteKey', writeAPIKey)

Last, instead of two reads at the top, I recommend using a timetable.

The first example shows the format you can use:
data = thingSpeakRead(12397,'Fields',[1,4],'NumMinutes',3,'OutputFormat','table')

Then you can use dot notation and the field names.

March 13, 2019
7:09 am
New Member
Forum Posts: 4
Member Since:
March 11, 2019
sp_UserOfflineSmall Offline

switching the write channel seems to work.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
31 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:

Matthewdupreez1, sbhunu, pabcstar, johnhutcheson1, madhuhada, dayne

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457