ThingSpeak Client to Connect Arduino to the Internet

I have created a tutorial on how to use the Arduino+Ethernet Shield and ThingSpeak. You can use it to data log on the web, see charts, connect a device to the internet, or even send status updates to Twitter.

The sketch shows you how to send an HTTP POST to the ThingSpeak API. It's updated to use Arduino 22, the native String library, and includes a watchdog timer for the Ethernet Shield. When 5 failed transactions are detected in a row, the Arduino re-initializes the Ethernet Shield (soft-reset). This will not solve every lockup, but it will make the setup more stable.

ThingSpeakClient Sketch

Here's how you get started with the ThingSpeakClient sketch...

  • Sign Up for New User Account -
  • Create a New Channel by selecting Channels and then Create New Channel
  • Enter the Write API Key in this sketch under "ThingSpeak Settings"

A ThingSpeak Channel can hold any type of data - sensor data (decimal and comma), binary data, serial strings... You can also send geo location information in dedicated location for mobile things. We just released an app you can install that allows you to send Twitter updates without doing OAuth on the Arduino side. The other part of ThingSpeak is that you can get data from a channel and start connecting things together.

We welcome anyone to try it out and looking for feedback as the service is new. The source code for the API will go up on GitHub and be open source once the kinks are worked out. The app is localized with language YML files, so you can even translate into pirate if you want. We hope this makes it easier to connect things to the web.

How much do you folks expect to charge for this service when you come out of testing mode?

I hope it's always in testing mode so that we keeping adding new features and keep it free. We are operating under the MySQL guidelines. Like I said, shortly the API source code will be on GitHub so you can fork on to your own server or put it on a shared host.

Do you have any ideas for it?

Being able to save data over extended periods is my top item. Comparing this year to last, this month to last, that kind of thing. Also, being able to import data for the past so one can bring in older data. Charts and stuff are cool, but if you don't have the data from the past you can't make comparisons.

So this is basically a MySQL server, just wrapped up and easier to use???

I got my Arduino communicating with MySQL already, and writing to the database, just gotta make it look pretty and have PHP read from it.

Is that what your service is basically providing?? A PHP front end and MySQL database?

Yes, you have the right idea ... there is a database component. It's a full web app with Charts, Apps, and Plugins that extend that base functionality - much like Wordpress is a PHP/MySQL front-end for blog posts with plugins. The goal is to make it easy and not have to run a local server if you don't want to or put this on a shared web host. An import tool is in progress so you can use the visualization tools if you have data already maybe from an SD card logger or something like that.

Sounds like you are making good progress with your project. Maybe they will link...

will this work without an ethernet shield? Just straight USB serial?

Thanks for all of the feedback over at our site.

Since we released, we have added many more features and tutorials. So, if it was no so clear a few months ago, I think you can see the direction that we are going.

Here's a link to the tutorials:

The biggest addition to our apps is called ThingHTTP - which allows you to send a simple command to the app, then the app does the connection to the resource that you want to get or command. It also can parse the response so you don't have to have an XML or JSON parser on the arduino. We hope that it simplifies connections to web services and saves code space on the mcu.

We also released the API to GitHub, so you can roll your own "ThingSpeak" on your home network.

Have fun!

polishdude20: will this work without an ethernet shield? Just straight USB serial?

polishdude20, I wrote a windows application that I call Seriot to communicate with an Arduino (or any other serial device) via usb/serial. The application logs the data to a file locally and optionally can send it to ThingSpeak. It's easy to configure and you can run it in several different modes depending on your needs.

You can read more and download it here:


Looks promising. Will definately give it a try, now that I got my ethernet shield :)

The things that I am interested in would be to -store/view historical data of my setup. -add alarm conditions to various signals that are monitored, and send notifications based on the alarm conditions. -schedule actions / timed actions for home control etc (ie switching on the ligt at 7 am...)

Will get back to you when I test further :)

Hi again.

So I have had a go at gathering some temperature data, and storing them on ThingSpeak. Works great, so far... (except that for some reason, it stopped logging at 04:00 this morning)... anyway. :drooling_face:

If the developers over at ThingSpeak are listening in, I have a feature request:

Add a display, that will only show the latest reading from the chart/field. -and display it as a number in a little neat box (no graph). That way, for any stored data on ThingSpeak, it would be possible to see the historical data, and also the most current value.

The same idea for digital values: make a text display, where you can assign some text for each value. Example: 0 = off / 1 = on etc... That way it would be really easy to build up a webpage, and include all the info from ThingSpeak, to show current and historical status of whatever is monitored.

Nice service by the way 8)

Spumanti, You can use the ThingSpeak API to get the last value for a given channel.

Retrieving the Last Entry in Channel Feed Method: POST or GET Feed URL:

For example to get the last value of my Outdoor temperature sensor (public channel #233) click the following link:

You could use some Javascript to go get the last value then parse the result and format it however you like on your web page. Note, if you don't want to make your channel public you can also generate a Read API key and pass that to the API. Check out the ThingSpeak API docs for more info:

You could also use one of their existing plugins to render a Google Gauge. See the following post for more info:



can you pls post a tutorial on how to set up a GPRS shield to log data to Thingspeak ??

Thank you

hi I was wondering is it possible to send data FROM Thingspeak TO the Arduino? Thanks

I see traffic from this old post is still making it to ThingSpeak, so I wanted to post an update.

We have released an official library for Arduino. This library makes it easier to get sketches up and running that send data to ThingSpeak or read data from ThingSpeak.

Installation... In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.

The library includes several examples to help you get started.

  • CheerLights: Reads the latest CheerLights color on ThingSpeak, and sets an RGB LED.
  • ReadLastTemperature: Reads the latest temperature from the public MathWorks weather station in Natick, MA on ThingSpeak.
  • ReadPrivateChannel: Reads the latest voltage value from a private channel on ThingSpeak.
  • ReadWeatherStation: Reads the latest weather data from the public MathWorks weather station in Natick, MA on ThingSpeak.
  • WriteMultipleVoltages: Reads analog voltages from pins 0-7 and writes them to the 8 fields of a channel on ThingSpeak.
  • WriteVoltage: Reads an analog voltage from pin 0, converts to a voltage, and writes it to a channel on ThingSpeak.

Hi all,

Version 1.1.0 of the libraries Has mentions now supports ESP8226 devices, the Particle Electron (coming soon!).

You can use these libraries directly from within the Arduino and Particle IDEs.

All the best,

So I’m a big time newb to the IoT world and HTTP. I’m trying to read my status on Thingspeak using an ESP8266 running Arduino. I’ve edited one of the examples to try to do what I want, but I don’t seem to have things right. I’ve also tried sending my tweet as a string to a field on Thingspeak so that I could use the built in “readField” command(s). Any help is greatly appreciated. I’m running road block after roadblock here.

#include "ThingSpeak.h"

  #include <ESP8266WiFi.h>
    char ssid[] = "<Work Sucks, Quit Now>";          //  your network SSID (name) 
    char pass[] = "<Seriously Quit Now>";            // your network password
  int status = WL_IDLE_STATUS;
  WiFiClient  client;

long myChannelNumber = 78204;
const char * myReadAPIKey = "HP5KTQQFBRTT7FRU";

void setup() {
  #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
    #ifdef ARDUINO_AVR_YUN
      #if defined(USE_WIFI_SHIELD) || defined(ARDUINO_ARCH_ESP8266)
        WiFi.begin(ssid, pass);


void loop() {
  // Read the latest value from field 1 of channel 31461
 delay (10);
 String Tweet =;
 // String sTweet = ThingSpeak.readStringField(myChannelNumber,2);
 //String sTweet = Tweet;
  int nField1 = ThingSpeak.readIntField(myChannelNumber, 1);
  int nField2 = ThingSpeak.readIntField(myChannelNumber, 2);
  #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
    Serial.print("Latest tweet is: "); 
    Serial.print (nField1);
    Serial.print (nField2);
    Serial.println(" , holy crap it worked!"); 
   //sTweet = client.print("GET");

Hi TipsEZ,

Love to help. Just a note -- it's best if you hide your API keys when you post, or anyone can access your private channel.

The ThingSpeak library is designed to hide all the HTTP stuff from you.

I can't quite figure out what your goal is from the code you've posted. If you want to read a string from a provate channel from ThingSpeak, check out the ReadPrivateChannel example. Try getting that to work first without any changes. Then switch it to read your channel. Since it looks like your channel has a text string in it, you'll need to change to the readStringField method.

You may find this ThingSpeak video helpful:


Thank you for your reply. What I am trying to do is send a tweet from my phone, that activitates a stepper motor ran from an Adafruit Huzzah (ESP8266). So I have my thing speak set up currently, per examples, so that when I Tweet something like "TweetControl, #FlagsHalfStaff" it posts this tweet as a status update on my Thingspeak page. When I try to do a "GET" from Thingspeak I get nothing back.

I'd really like to parse my Tweet, similiar to the example, so that anything after the # sign is dropped into Field 2 as a string, then simply use the "readStringField(myChannel, 2)" command.

Hi! I would like to ask if this would work on ESP8266 Wifi Module.