Reader small image

You're reading from  Arduino Home Automation Projects

Product typeBook
Published inJul 2014
Publisher
ISBN-139781783986064
Edition1st Edition
Tools
Right arrow
Author (1)
Marco Schwartz
Marco Schwartz
author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz

Right arrow

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 page is locked
Previous PageNext Page
You have been reading a chapter from
Arduino Home Automation Projects
Published in: Jul 2014Publisher: ISBN-13: 9781783986064

Author (1)

author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz