How to add 2 variables in a api write request?

CHATILLON Patrick on 15 Apr 2021 (Edited on 17 Apr 2021)
Latest activity Reply by CHATILLON Patrick on 19 Apr 2021

HI! The following line works well to send my var1 value to thingspeak.

GET https://api.thingspeak.com/update?api_key=****************&field1={var1}

But I would like to send the addition of var1+var2 in the same command. I tried many differents commands like:

    GET https://api.thingspeak.com/update?api_key=****************&field1={var1+var2}

any help? Thanks

Christopher Stapels
Christopher Stapels on 19 Apr 2021

Where are you sending the command from? A device, MATLAB or some other code?

CHATILLON Patrick
CHATILLON Patrick on 19 Apr 2021

Thanks for reply.

From a Sigfox callback.

But for my tests I use firefox or chrome.

 https://api.thingspeak.com/update?api_key=****************&field1={10+2}
Christopher Stapels
Christopher Stapels on 19 Apr 2021

I'm sorry, the API does not include the ability to do math in the URL.

As an alternative, you could write to two fields of a channel and then create a MATLAB analysis that reads the channel, adds the values and stores them in a different channel. You can update two fields in a a single update by appending ...&field1=x&field2=y... to your request. You can use the react app to trigger a MATLAB analysis on data entry, or use a time control to regularly read a specified selection of entries and do the processing in groups as small as 5 minutes.

CHATILLON Patrick
CHATILLON Patrick on 19 Apr 2021 (Edited on 19 Apr 2021)

Thanks a lot.

That's what I started to do.

Is that possible to delete the old value instead of create a other channel?

Christopher Stapels
Christopher Stapels on 19 Apr 2021

ThingSpeak is meant to create a time record of your device readings, so delete operations are possible, but not encouraged. You can only delete the whole channel feed, not individual entries.

Can you tell us more about the application ? What are you measuring?

CHATILLON Patrick
CHATILLON Patrick on 19 Apr 2021

OK, thanks.

I'm measuring differents parameters from a hive. (weight, temp, ...)

Tags

No tags entered yet.