Hans on IoT

ThingSpeak, MATLAB, and the Internet of Things

Hidden API Commands

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.

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。