Logging Data and Displaying Graphs over the Internet with Arduino

 



Logging Data and Displaying Graphs over the Internet with Arduino

Created on: 16 March 2016

In this tutorial, an Arduino and Ethernet shield are used to send data over the Internet which is then logged and displayed in a graph using an external IoT (Internet of Things) service called ThingSpeak.

Using an external IoT service is a lot easier than using the Arduino and Ethernet shield as a webserver that hosts its own webpage to display the logged data in graphs. When using ThingSpeak, the Arduino is set up as a web client instead of a web server. This simplifies connecting the Arduino to the Internet. The ThingSpeak server also handles capturing the data and displaying the graphs.

Any data can be logged, for example, voltage on Arduino analog pins, temperature from a temperature sensor, pressure, humidity, etc. Just set up the Arduino with the desired sensor or sensors and send the data over the Internet for logging and display in a line graph.

This tutorial uses an Arduino Uno R3 and Ethernet shield, but any Arduino that can connect to the Internet should work, such as an Arduino MEGA 2560 and Ethernet shield, Arduino Ethernet board, Arduino Yun and ESP8266. No SD card is needed.

Principle of Operation of Arduino with ThingSpeak

This section gives an overview of how to use an Arduino with ThingSpeak, the tutorial follows.

Install the ThingSpeak Library

The ThingSpeak library must be installed in the Arduino IDE software, which is easy with the Arduino library manager which handles the installation.

Create a ThingSpeak Account

In order to create a "channel" that the Arduino can send data over and to view the logged data in graphs, an account at ThingSpeak must be created (free of charge).

After an account is created, one or more channels can be created. Each channel can have multiple fields, so you can send for example, temperature and humidity over one channel to your ThingSpeak account using separate temperature and humidity fields.

Creating an Arduino Sketch to Send Data to ThingSpeak

Once you have created a channel on ThingSpeak, you can send data from an Arduino to your ThingSpeak account by writing a sketch that uses functions from the ThingSpeak library installed in Arduino. There are several example sketches that are installed when the ThingSpeak library is installed and this tutorial shows how to use one of the examples to send voltage from Arduino analog pin A0 to ThingSpeak to be displayed in a graph.

ThingSpeak Server

To avoid any confusion, it is not necessary to set up a ThingSpeak server if you have created an account at ThingSpeak. This option is available if you want to host your own server, which I am sure most users will not want to do.

1. Installing the ThingSpeak Library in the Arduino IDE

To install the ThingSpeak library, open the Arduino IDE and do the following:

  • From the top Arduino menu, select Sketch → Include Library → Manage Libraries...
  • In the Filter your search... field of the Library Manager dialog box, enter ThingSpeak.
  • Click ThingSpeak in the dialog box to select it.
  • Click the Install button to install the ThingSpeak library which will then be downloaded from the Internet.

2. Create a ThingSpeak Account

Go to the ThingSpeak website and click the Sign Up link. You will need to provide a user name (user ID), email address and password and also agree to the terms of use and privacy policy to create an account.

3. Create a Channel and Field

In order to send data from the Arduino to ThingSpeak, you need to create a channel. When you log into your ThingSpeak account for the first time, you should see the New Channel button. If it is not visible, click Channels → My Channels.

Comentários

Postagens mais visitadas