-->
Page 1 of 2

Using SENDTS to send a floating point number

PostPosted: Sat Dec 05, 2015 8:11 pm
by Nick McBride
I'm trying to use the SENDTS function to send ThingSpeak a floating point number (a temperature value actually)

When I do this: SENDTS("APIKEYHERE",1,tempF), the data doesn't get logged on ThingSpeak. But, when I use SENDTS("APIKEYHERE",1,"1"), the value does get logged (as it's a hard coded string). Is there a way to convert an integer to a string so this value can be sent? I also tried this: SENDTS("APIKEYHERE",1,"'" & tempF & "'"), but no dice.

Re: Using SENDTS to send a floating point number

PostPosted: Sun Dec 06, 2015 12:51 pm
by Mmiscool
Can you let the full code. It should be working with vatlriables for any functions parameter.

Re: Using SENDTS to send a floating point number

PostPosted: Sun Dec 06, 2015 1:38 pm
by Jokkepappa
Funny enough for me when i tried yesterday:
Code: Select alltemp 0 curr
    SENDTS(APIKEY,1,curr)

Worked perfectly but then
Code: Select allSENDTS(APIKEY,2,"1")


Did not. But i think in my case, as i tried to send them quickly eachother ThingSpeak api did not record it because there is time limit that you can only upload data every 15sec.

Re: Using SENDTS to send a floating point number

PostPosted: Mon Dec 07, 2015 2:49 pm
by Nick McBride
I'm using the Themometer example from the BASIC website, but here's my modification for the [refresh] subroutine with trying to send the data to ThingSpeak.


[refresh]
tempF = 0
temp 0 curr
let tempF = curr * 1.8
let tempF = tempF + 32
SERIALPRINTLN tempF
SENDTS("6DWOBDYDGIPQP4AC",1,tempF)
if tempF < setp then goto [on2] else goto [off2]
Wait


The result on the thingspeak side is NAN.

If I use:
bla = "api.thingspeak.com/update?key=6DWOBDYDGIPQP4AC&field1=" & tempF
print wget(bla)
cls

This works fine.