Friday, 31 October 2014

Android App to connect to Thingspeak

Hi, everyone. Few days back we learned how we can upload data to Thingspeak cloud IoT platform. But it is very tedious job to every time open the web browser and insert command or data. So today we will develop an android app that will do it for us. It is recommended that you go through the Thingspeak documentation first. Ok so let's get started.

What you need

  • Laptop or PC with internet connection.
  • Thingspeak account.
  • Android smartphone.
  • Google account.

What is this APP thing?

In this tutorial we will make use of the Thingspeak Apps. You may ask what is this App. It is nothing but services provided by Thingspeak to communicate with your devices. These apps can be accessed by POST, GET, PUT and DELETE HTTP requests. You can check out my previous post on how to make an HTTP request to upload data to your Thingspeak Channel. In this tutorial we will make use of the following Thingspeak Apps.
  • Talkback - This App is used to control your device based on some decision made on the basis of your sensor data in your channel. Using this app you can store commands which your device may fetch at regular intervals or when an event occurs to execute.
  • React - This is a decision making App. We can use this app to trigger an event based on your Thingspeak data channel. The field on which decision is to be made can be String, Location or Numeric data. There are a whole lot of logic that you can execute based on the data. In this project I will use my android app to get my current GPS location and upload it to my channel based on which an event will be triggered. 
  • ThingHTTP - This App is used to do an HTTP request from within Thingspeak. So we can use this App to trigger our Talkback App in turn to update the commands.

Getting the Idea

What I am trying to do here is that I will develop an Android app that will POST my current location to my Thingspeak channel which will trigger some logic in the React App. This App will in turn call the ThingHTTP App to send a PUT request to my Talkback App and update the current command. This command will be fetched by my device on regular interval to perfom some action. The last part will not be covered in this post. I will cover it in my next post.

Setting up Thingspeak

It is assumed that you already have a Thingspeak channel set up. If not follow my previous post.
Before moving on please read the documentation each of this App so that you have a better understanding of how they work.
  • Open your Thingspeak account and click on the Apps tab.
  • You will get your Apps menu. Now click on Talkback App.
  • Now click on "New Talkback".
  • Now Fill in the Name and select your channel and set a default command by clicking add new command. For now we will add "CLOSE".

  • Now again click on the Apps tab and go to the "ThingHTTP" App.
  • Now click on "New ThingHTTP" and fill  up like this and save your ThingHTTP.

  • Now create another ThingHTTP App for closing. Like this.
  • Now click on App and now go to the React App.
  • Click on :"New React" and fill up like this. Save your React App.
  • Now create another React App in similar manner for closing like this.
  • While doing all the above steps give the parameters carefully like latitude, longitude,api_key etc. specific to your Apps.
  • Now you are ready to go. Lets create the Android App.

Setting up App Inventor 2

Since you are developing an app for android it is already assumed that you have a google account. Now go to the website Use your google account to log in and create a new project. App Inventor is an online development platform for creating android apps without any knowledge of programming. It is based on graphical block development. You only need to arranged the required blocks just like a puzzle. Follow the getting started guide to have a clear understanding.
  • After you have opened App Inventor 2 and created a project bring the following objects to the canvas. Check this image to get a list.
  • Change the Button1 Text to Turn OFF and the Button2 Text to Turn ON
  • Change the Web1 url to<your Talkback ID>/commands/<your command ID> 
  • Change the Web2 url to
  • Change the Clock1 Time interval to 10000.
  • Change LocationSensor1 Time interval to 10000.

  • Now click on "Blocks" on the top left corner of your screen.
  • If you have gone through the Getting started portion then you will be familiar with the blocks. So arrange the blocks as shown below.
  • Replace Web1.PutText api_key to your Talkback API_Key.
  • Replace Web2.PostText api_key to your Channel API_Key.

  • Now click on "Build"->"App(save .apk to my Computer)". It will download the file to your PC. Transfer the file to your android phone and install the app.

Running the Apps

  • Now turn ON you GPS and WiFi/Data connection.
  • Now open the Talkback App on your Thingspeak account. You will find the default command as CLOSE.
  • Now open the app in your android phone and wait for sometime untill the location is displayed.
  • Now refresh the Talkback page. If you are at or near the location you specified in your React App, the command will automatically change to OPEN. You can also manually TURN ON/OFF using the buttons provided.

What will you Make?

Isn't it awesome? Now you can automatically pre-cool your room when you are close to your home or you can turn the room lights ON or OFF using the app. There are limitless possibilities of things that you can connect and control through the internet using simple tools like Thingspeak, App Inventor etc. Please keep me posted about your projects and if you are facing any difficulty in understanding the instructions please let me know through the comments. In our next post we will see how we can make our devices fetch these commands at regular intervals and perform certain tasks. Till then keep making and if you like my post please share and +1 me on google.


  1. Hi! I just wanna do autowatering system. How I can start watering with buttons start/stop

  2. In your android app create a button which will send POST request to update the commands in the talkback app. On the controller side use GET requests to execute those commands. One command can be executed only once. Check out this page for more info.

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. hi, Sounak
    Thank you for showing your project.
    I could learn thingspeak app by you too.
    Now talkback app's version was changed and it did not become to return a response about OPEN & CLOSE as status on its app.

    If possible, Advice me with something.
    I want to get a response and the status on thingspeak's Channel and android app(app inventor).
    Thank you.

  6. i cant acces my thingspeak talkback using this app to add a new command, inorder to add a talkback command. what i have to do?????

  7. is there any video tutorials explaining more about talkback,react and thinghttp ??

  8. Hii thanks for showing that....I actually want to get a graph from the thingspeak to Android app......can you help me with that please!!!!

    1. Hi,

      You can do an HTTP request to thingspeak to get your past data. Refer to Thingspeak documentation for that. After that you can use some graph plotting APIs like Plotly to get some graphs.

  9. how can i login thingspeak user account in my own android app?

    1. Hi Jatin,

      Everything in Thingspeak works through HTTP requests. Every profile will have it's unique API key which allows you to use all the features of thingspeak.

  10. Hey! I wanna send a command from my android app to control some ports on my development board, how can I do it?

    1. hey bro!
      I also want to do the same but even above project is not working , when I run my app it always pop-up an error "wrong no. of argument for posts" would u please help. any help is appreciable.


    Best app for thingspeak work

    1. That is cool. At the time I wrote this blog I think this app was not there.


    Best for esp8266 work

  13. You can still use this applications to track someones location.

  14. Hi,
    Sorry guys I was out of touch from this blog for 2 years. I couldn't reply to most of your comments. But now I am planning to continue the blog with some new projects.

  15. Hi,thanks for this tutorial,can this be done in android studio?

  16. I have ESP8266 connected to DHT22. I see Temperature and Humidity on Thingspeak, both Private or Public. All I want to do now is control a relay from my Android cell phone. It would be great to see a step by step and comments from someone. I really do want to learn, but finding it really tough.

  17. hi,how do i notify my android when some changes occur in the threshold level which is an matlab output

  18. if you try renaming the master file, like the way some people did on gaana app, it won't play.  download

  19. But how can I get data from thingspeak...I am facing problem in that part. Can u guide us?

  20. that's awesome! Am having some difficulties with my project, that is building an app that will be able to track my wearable tracking device.

  21. sir i just need send or post mobile gps data to thingspeak.can you explain me? sir.

  22. tutuapp is the best app to download any kind of paid app free of charge. tutuapp android pokemon go game is the most famous game in the world and you can download it free of charge. Not only pokemon go app you can download any kind of apps free of charge.

  23. You are doing a great job. You inspire me to write for other. Thank you very much. I would like to appreciate your work for good accuracy and got informative knowledge from here... Embedded System Training in Chennai
    Embedded System Training Institute in Chennai

  24. install kodi firestick app using above link and unlock the features of it. all updates are free of charge.

  25. This information is impressive; I am inspired by your post writing style & how continuously you describe this topic. Embedded System Training in Chennai
    Embedded System Training Institute in Chennai

  26. I have recently started a blog, the info you provide on this site has helped me greatly. Thanks for all of your time & work.
    How to create an app

  27. This comment has been removed by the author.

  28. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    rpa training in Chennai | rpa training in pune

    rpa online training | rpa training in bangalore

  29. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    Data Science training in Chennai | Data science training in bangalore
    Data science training in pune| Data science online training
    Pyton training in Kalyan nagar

  30. After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.
    java training in omr | oracle training in chennai

    java training in annanagar | java training in chennai

  31. I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
    python training Course in chennai
    python training in Bangalore
    Python training institute in kalyan nagar

  32. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 

    best rpa training in chennai | rpa online training |
    rpa training in chennai |
    rpa training in bangalore
    rpa training in pune

  33. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Best Devops Training in pune
    Devops Training in Chennai

  34. Howdy, would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 completely different web browsers, and I must say this blog loads a lot quicker than most. Can you suggest a good internet hosting provider at a reasonable price?

    Best AWS Training Institute in BTM Layout Bangalore ,AWS Coursesin BTM

    Best AWS Training in Marathahalli | AWS Training in Marathahalli

    Amazon Web Services Training in Jaya Nagar | Best AWS Training in Jaya Nagar

    AWS Training in BTM Layout |Best AWS Training in BTM Layout

  35. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    health and safrety courses in chennai

  36. Superb post, valuable and excellent article, lots of great information, thanks for sharing with peoples.

    Data Science Courses in Bangalore

  37. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.
    date analytics certification training courses
    data science courses training

  38. I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.
    AI learning course malaysia

  39. Just pure brilliance from you here. I have never expected something less than this from you and you have not disappointed me at all. I suppose you will keep the quality work going on.
    Data Science Course in Pune


  40. I was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more.

    Data Science Course

  41. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.Data Science Courses

  42. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!digital marketing course in singapore

  43. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!digital marketing course in singapore