Hardware Reference
In-Depth Information
because you will need the information from this page when you configure your
Arduino sketch later in this section.
Installing the Xively and HttpClient Libraries
Xively provides a convenient Arduino library that makes it easier to get your
Arduino talking to the web through their service. The Xively library depends
on the HttpClient library, so you will need to download that as well. Both librar-
ies are available on GitHub, a popular code hosting website. Visit the following
two links and click the ZIP download button to download the code repositories:
https://github.com/xively/xively-arduino and https://github.com/amcewen/
HttpClient . (These download links can also be found on the web page for this
chapter: www.exploringarduino.com/content/ch14 .) For now, save these ZIP
files on your desktop. Then complete the following steps:
1. Unzip the files and rename the library folders so that they do not contain
dashes (GitHub adds dashes to the folder names automatically). I recom-
mend renaming the “HttpClient-master” folder to “HttpClient” and the
“Xively-Arduino-master” folder to “xively.”
2. Move these folders to your Arduino libraries directory, as you did in
the “Getting the Library” section of Chapter 12, “Hardware and Timer
Interrupts.”
3. Open the Arduino integrated development environment (IDE) (you'll need
to restart it if it was open when you copied the libraries) and navigate to
File > Examples. Confirm that you see “HttpClient” and “xively” in the
Examples list. This confirms that the libraries were installed successfully.
For your first experiment with Xively, you'll use their handy example sketch,
which broadcasts the state of one analog sensor to web. In the example menu
of your Arduino IDE, open the DatastreamUpload example under the “xively”
heading. This should open a new sketch. (This sketch is also included in the
code download package for this chapter.) Because you'll be modifying the
example sketch, use the File > Save As option to save this sketch to your own
directory before continuing. A quick glance at the example file reveals that it
will be transmitting the analog value that is read by analog input pin 2:
// Analog pin which we're monitoring (0 and 1 are used by the
// Ethernet shield)
int sensorPin = 2;
Knowing this, you'll wire up your Arduino accordingly in the next section,
with the Ethernet shield equipped. You'll come back to this sketch once you've
wired your Arduino.
Search WWH ::




Custom Search