Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Arduino Home Automation Projects

You're reading from   Arduino Home Automation Projects Automate your home using the powerful Arduino platform.

Arrow left icon
Product type Paperback
Published in Jul 2014
Publisher
ISBN-13 9781783986064
Length 132 pages
Edition 1st Edition
Tools
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

Table of Contents (14) Chapters Close

Arduino Home Automation Projects
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Building Wireless XBee Motion Detectors FREE CHAPTER 2. Control Lights from Your Phone or Tablet 3. Measuring the Temperature Using Bluetooth 4. Weather Station in the Cloud with Xively 5. Monitor Your Energy Consumption in the Cloud 6. Hack a Commercial Home Automation Device 7. Build Your Own Home Automation System Index

Building the Arduino sketch


At this point, we have working sensors on our Arduino board, and we also have an account on Xively that is ready to receive some data. We are now going to write the sketch that will connect to your Wi-Fi network and upload data automatically to your Xively account.

We are now going to write down the code in the Arduino IDE. We start by including the correct libraries as shown:

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

Then, just as in Chapter 2, Control Lights from Your Phone or Tablet, we need to define on which pins the CC3000 board is connected:

#define ADAFRUIT_CC3000_IRQ   3
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10

And define the pin and type of the DHT sensor:

#define DHTPIN 7
#define DHTTYPE DHT11

We can now create the instance of the CC3000 chip:

Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);

Now, you will have a few things to modify...

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 £13.99/month. Cancel anytime
Visually different images