Read data as integer only? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

8   +   4   =  

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
Read data as integer only?
No permission to create posts
June 17, 2020
6:00 pm
Avatar
pelikano
New Member
Members
Forum Posts: 2
Member Since:
June 17, 2020
sp_UserOfflineSmall Offline

hi, I read temperature data from my channel with this code;

long temp = ThingSpeak.readLongField(counterChannelNumber, FieldNumber1, myCounterReadAPIKey);

The result in my chart of n the portal is “16,7” but the result from my code is “16” although I expect from “readLongField” the “long” version and not the integer version.

What and where does something go wrong?

June 18, 2020
7:59 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 339
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

I believe it is the separator being used -- 16,7 instead of 16.7

June 18, 2020
5:07 pm
Avatar
pelikano
New Member
Members
Forum Posts: 2
Member Since:
June 17, 2020
sp_UserOfflineSmall Offline

Thanks Vinod, you triggered my thoughts and I found another function.

I am using ThingSpeak.readFloatField now and get “16.70” as result.

Documentation:
https://github.com/mathworks/thingspeak-arduino/blob/master/README.md

To get rid of the trailing digit I used this code;

tempKelderStr.concat(tempKelder); // float to string
tempKelderStr.remove(tempKelderStr.length() - 1, 1); //remove trailing digit

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457