Send Data to ThingSpeak with Arduino

Getting Started

In order to send data to ThingSpeak™ using an Arduino®, you need an Arduino with network connectivity either onboard or with a shield. We have an official library for ThingSpeak and we require Arduino 1.6.x or above running on Windows®, MAC OS X®, and Linux®. This library needs to be installed and used by the Arduino device in order to send data to ThingSpeak using one of our examples.

Setup ThingSpeak

ThingSpeak requires a user account and a channel. A channel is where you send data and where ThingSpeak stores data. Each channel has up to 8 data fields, location fields, and a status field. You can send data every 15 seconds to ThingSpeak, but most applications work well every minute.

  • Sign up for new User Account
  • Create a new Channel by selecting Channels, My Channels, and then New Channel
  • Note the Write API Key and Channel ID

Full REST Interface API information for ThingSpeak is available in the documentation.

Install ThingSpeak Communication Library for Arduino

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

Setup Arduino Sketch

We have provided a few Arduino sketch examples with the ThingSpeak library. They are designed to work right away with no changes.  To make the examples work with your ThingSpeak channel, you will need to configure the myChannelNumber and myWriteAPIKey variables.

[cce]unsigned long myChannelNumber = 31461;
const char * myWriteAPIKey = “LD79EOAAWRVYF04Y”;[/cce]

Send an Analog Voltage to ThingSpeak

The WriteVoltage.ino Arduino sketch reads an analog voltage from pin 0, and writes it to a channel on ThingSpeak every 20 seconds. Load the example in the Arduino IDE. Make sure to select the correct Arduino board and COM port. Then, upload the code to your Arduino.

Sending Multiple Values to ThingSpeak

Since ThingSpeak supports up to 8 data fields, you might want to send more than one value to ThingSpeak. To send multiple value to ThingSpeak from an Arduino, you use ThingSpeak.setField(#,value) for each value to send and then use ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey) to send everything to ThingSpeak. Use the WriteMultipleVoltages.ino Arduino sketch to send multiple pin voltages to ThingSpeak.


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.

Complete source code and examples for the ThingSpeak Library are available on GitHub.

MATLAB Visualization

Now that your data is on ThingSpeak you can see this data on ThingSpeak using the MATLAB Visualizations app. On ThingSpeak, select Apps and then MATLAB Visualizations. Click “New”, select “Custom (no starter code), and click “Create”.

Enter the following MATLAB code and click Run and Save:

readChannelID = 93156;
fieldID1 = 1;

readAPIKey = 'MCI6XM81ZFOY8UCE';

%% Read Data %%
[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 10, 'ReadKey', readAPIKey);

%% Visualize Data %%
thingSpeakPlot(time, data);