prepend – Internet of Things https://blogs.mathworks.com/iot Hans Scharler is an Internet of Things pioneer. He writes about IoT and ThingSpeak IoT platform features. Mon, 22 May 2017 17:24:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 Hidden API Commands https://blogs.mathworks.com/iot/2011/04/13/hidden-api-commands/?s_tid=feedtopost https://blogs.mathworks.com/iot/2011/04/13/hidden-api-commands/#respond Wed, 13 Apr 2011 06:08:03 +0000 https://blogs.mathworks.com/iot/?p=545 When you are retrieving data from a ThingSpeak channel you have many options and formats to choose from. We wanted to highlight a few options that are easily overlooked. Last.txt Let’s say you... read more >>

]]>
When you are retrieving data from a ThingSpeak channel you have many options and formats to choose from. We wanted to highlight a few options that are easily overlooked.

Last.txt

Let’s say you have an Arduino and you want to get the last value in a channel. You could get your feed and then write some parsing code to extract the data that you are looking for. It’s a waste of code space and also fills your finite buffers on your microcontroller. Let the cloud do the work and give you just the value you are looking for.

Here’s how you would get our light levels: Live Demo

[cce]http://api.thingspeak.com/channels/9/field/1/last.txt[/cce]

Modifying the response

You can even add data to the response. Maybe you have Twilio reading back your temperature. It would not be much fun if Twillio says to you, “80”. Sensor data without context is noise!

Here are two optional parameters when returning the last data on a ThingSpeak Channel:

  • prepend=[text to add before the API response]
  • append=[text to add after the API response]

Live Demo

[cce]http://api.thingspeak.com/channels/9/field/1/last.txt?prepend=Your%20light%20level%20is%20&append=.%20Is%20someone%20in%20your%20room?[/cce]

Check out the ThingSpeak Documentation for more information.

]]>
https://blogs.mathworks.com/iot/2011/04/13/hidden-api-commands/feed/ 0