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 now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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 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 (9) Chapters Close

Preface 1. Building Wireless XBee Motion Detectors 2. Control Lights from Your Phone or Tablet FREE CHAPTER 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

Controlling the device from your computer


We are now going to build the Arduino sketch we will use to control the relay remotely. This will be based again on the aREST library that will help us handle the request sent from your computer.

This Arduino sketch starts by including the required libraries as follows:

#include <SPI.h>
#include <aREST.h>

Then, we can create the aREST instance:

// Create aREST instance
aREST rest = aREST();

Then, in the setup() function of the sketch, we simply start the serial connection so that we can access the board later:

void setup(void)
{
  // Start Serial
  Serial.begin(9600);

}

Next, we can handle the requests coming on the serial port by using the following code:

void loop() {

  // Handle REST calls
  rest.handle(Serial);

}

Note

Now, we can actually test the device you just hacked. Note that the code for this part is available on the GitHub repository of the project at the following location:

https://github.com/openhomeautomation/arduino-home-automation...

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