Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Arduino Networking

You're reading from   Arduino Networking Connect your projects to the Web using the Arduino Ethernet library

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783986866
Length 118 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Schwartz Marco Schwartz
Author Profile Icon Marco Schwartz
Marco Schwartz
Arrow right icon
View More author details
Toc

Sending data to Xively

We are now going to build the Arduino sketch for this project. The goal is to measure data on the Arduino board, connect with the Xively server, and send the data.

The first step is to include the following required libraries:

#include <SPI.h>
#include <Ethernet.h>
#include "DHT.h"

Enter the MAC address of your board:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xFE, 0x40 };

We can then define the pin and the type of the DHT sensor as follows:

#define DHTPIN 7
#define DHTTYPE DHT11

Create an instance on the sensor, as shown in the following line:

DHT dht(DHTPIN, DHTTYPE);

Create an instance of the Ethernet client:

EthernetClient client;

We also define a default IP address for the board:

IPAddress ip(192,168,1,50);

In the sketch, we also set the address of the secured Xively server that we will connect to using the Ethernet shield:

IPAddress server(216,52,233,120);

Now, we have to modify the sketch a little bit to enter your own information about your Xively account...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime