The IoT platform ThingSpeak in practical test
Everyone is talking about the Internet of Things at the moment. This is why this year's Zühlke camp was largely about this topic. Using different scenarios, we experimented with IoT technologies and also examined various platforms. After all, you shouldn't keep reinventing the wheel, but use existing infrastructures and applications.
This article is about the IoT platform ThingSpeak, which we tested in practice using the scenario described below.
An ammeter, which another team implemented on the basis of a Raspberry Pi, sends data to ThingSpeak about the ongoing current consumption of the connected devices. The IoT platform will visualise this data and post a message on Twitter as soon as a certain threshold is exceeded.
Insight in brief
- ThingSpeak is an IoT analysis platform that enables data streams to be aggregated, visualised and analysed, all in real time.
- In addition to the publicly accessible version on the web, ThingSpeak can also be hosted on your own server as an open source application.
- The ThingSpeak Apps (e.g. additional visualisations or a Twitter connector) are not available in the open source version, however.
How it's used
It is generally very easy to use. All you have to do first is create a new channel through the web interface or via the API. Then you can send your data to the channel using simple HTTP requests:
By specifying the Write API key of the desired channel, a maximum of eight numeric and alphanumeric values in the fields 1 to 8 can be sent to the channel. In addition, it is also possible to specify a location in the form of latitude, longitude and altitude (parameters lat, long and elevation) and a status message (parameter status).
This data is stored in the channel and can be visualised in ThingSpeak or on external websites. Retrieving data from a channel is done with different options. For example, the whole channel feed (maximum 8000 entries), only the last entry, a special entry or all values of a certain field can be retrieved. ThingSpeak can send the response in plain text, JSON or XML.
As well as the actual core functionality and the previously mentioned channels that contain the actual data, ThingSpeak provides five features known as Apps:
- React: React enables you to respond to certain messages in a channel. To do this, the channel and data field to be monitored must first be selected via the web interface. Depending on the type of data field, different operators are available for the check function, such as contains, starts with, ends with, is equal to, is greater than, is less than, etc. After stipulating the test frequency (when inserting new data, or every 10, 30 or 60 minutes), all that remains is to set the desired action. This is where two other Apps, ThingHTTP and ThingTweet, come into play, as they can be executed if a data set checks positively. In the case of ThingTweet, the checked value can be inserted in the text of the status update using the placeholder %%trigger%%.
- ThingHTTP: this App enables ThingSpeak to access external APIs on the web. The HTTP verbs GET, POST, PUT and DELETE are supported, as well as functions such as Basic Authentication, encryption via SSL, HTTP 1.0 and 1.1, as well as any Content Types and Headers, among others. On the one hand, as mentioned earlier, ThingHTTP can be used as an action in a React. On the other hand, it also allows "connected" devices or sensors to send data to or retrieve data from external APIs via ThingSpeak. Data can be sent using the following example request:
- ThingTweet: Wie der Name schon vermuten lässt, kann man mit ThingTweet Statusupdates auf Twitter posten. Für die Konfiguration dieser App muss lediglich ein Twitter-Konto inklusive der dazugehörigen Zugangsdaten hinterlegt werden. Anschließend kann die so erstellte ThingTweet-Instanz als Aktion in einem React verwendet oder die Nachricht auch direkt an sie gesendet werden:
- TalkBack: a TalkBack can be used to give instructions to "connected" devices by sending commands to a "TalkBack queue" in ThingSpeak. The devices can then retrieve these commands and perform a corresponding action. As long as you do not give a new command an explicit position, it is processed in accordance with the FIFO principle, i.e. the command that entered the queue first is also delivered first when commands are retrieved. If an explicit position is assigned, the new command is inserted at this position in the queue and all subsequent commands are moved back by one position.
TweetControl: TweetControl enables ThingSpeak to respond to Twitter updates. To do this, the application uses the Twitter streaming API to listen for new status updates from a user and/or a hashtag. If a new tweet with the configured keyword is detected, a ThingHTTP instance can be executed.
Hosting or Open Source?
There are two different variants of ThingSpeak that you can use. On the one hand, there is a hosted version, which can be reached at https://thingspeak.com/. Here you only have to register and create a channel, and then you can start immediately.
On the other hand, you can also run ThingSpeak in an open source version yourself. In this case, the relevant code can be downloaded from a GitHub-Repository. You can also find installation instructions for Linux (Ubuntu) there.
Unfortunately, both variants have their particular disadvantages.
The hosted version, for example, as a freely accessible and free-of-charge service has a limit of one message every 15 seconds. I.e. a device that wants to send its data to a ThingSpeak channel can only do this every 15 seconds. This limitation may mean, for example, that microcontrollers or low-level devices have to be used to collect and aggregate data over this period, which naturally requires computing power and memory and can therefore result in increased power consumption.
The open source version, on the other hand, has the limitation that the Apps are completely missing, which unfortunately is not mentioned either on the official websites or in the GitHub repository. This means that you cannot forward the ThingSpeak data to another platform, for example, or retrieve additional data from the Internet. This in turn means that you are completely restricted to the channel functionality and visualisation possibilities of ThingSpeak itself. At this point, of course, there is still the possibility of covering more complex scenarios by retrieving the data from another application and processing it there.
ThingSpeak: "Pros and Cons."
ThingSpeak is a free and easy to use IoT platform that is well suited for rapid prototyping. In addition, ThingSpeak already offers good data visualisation capabilities for simple scenarios. In practice, however, the channels themselves, with only eight data fields, and the very limited data processing and data forwarding options can quickly prove to be restrictions that are simply too great.
Author: Gerd Pühl