Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Android client ThingSpeak extension for MIT Application Inventor 2

The following attached file contains a ThingSpeak client extension
IconTS.png

that allows one to easily make use of the Read and Write features of the ThingSpeak cloud service provided by MathWorks in such a manner that programmer is able to transparently make use of the service without having to deal with much details of the implementation in the code side. With the App - also attached - you can easily check the extension working on a friendly interface:

AppRunning.png


For those who are not familiar with IoT stuffs, the key point to be aware is that the main goal achieved by using cloud servers is that we can design an architecture so that we don't need provide the server, which means that both sides of the system - the one being monitored, and the supervisory itself - now work as clients, as follow:

Architecture.png


Essentially ThingSpeak is a Web server on which data is read and written via GET commands of the Http protocol. All replies come on the JSon format in raw text with no formatting, which means that no LF or CR characters are added, as can be seen on the left side of the following picture:

JSonFormatter.png


( picture taken form Jsonformatter )

All you have to do is subscribe to the ThingSpeak website, create a channel, and take note of the following data automatically generated:

ThingSpeak.png


Please note that at the same above page, it is available the links with which you cam make experiments on the web browser, either to read or write values to the fields:

ApiRequests.png


If you are not going to use multiple fields simultaneously, you can configure the channel to use only 1 of the 8 fields available, which would also reduce the size of the JSON structure:

Channel.png



It is important to note that all data sent and received are in the ASCII format at the URL body, which means that if one wish provide extra security, it should be considered any kind of cyphering or even cryptography in order to atleast detect whether data was maliciously corrupted or not.

Another poit to remark is that parsing was performed without using any JSon library, which means that if on the one hand the structural integrity of the JSON format is not checked out, on the other hand it means that tasks are performed lightweight, not wasting core processing if application require update realtime.

Here's an overview of the "source code" or rather, "source blocs" of the above demo application.
That's all you need, nothing else:

AppProject.png



Below, a snapshot of the components:

Components.png



Here, a snippet showing how much of the boring coding task can be avoided by customer, once it is embedded on the extension itself:

Snippet.png



This project is also available on Github repository, at which releases will be updated.
Feel free to make experiments and give feedback.

Usage:
=====
Parameters to Fill:​
  • Channel: A number containing 6 or 7 decimal digits which is the ID of the channel
  • ReadKey: The alphanumerical key provided by ThingSpeak to read the channel you have just created
  • WriteKey: The alphanumerical key provided by ThingSpeak to write at the channel you have just created
  • Field: One of the 8 available at each channel
  • Value (w): The value (atually, a string) to be stored at the cloud service
  • Security: The mode you selected to grant access to the channel (public/ private)

Returned parameters:​
  • TimeStamp: Date-Time of the last value updated to cloud server
  • Value (r): Value got from cloud server (Read:Field content / Write:Opperation succeeded)
  • Status: Just to trace some inner status of the component during execution

Comments

There are no comments to display.

Part and Inventory Search

Blog entry information

Author
andre_luis
Read time
2 min read
Views
1,799
Last update

Downloads

  • Client_ThingSpeak_AI2_Ext.rar
    3.1 MB · Views: 13,506

More entries in Uncategorized

More entries from andre_luis

Share this entry

Back
Top