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 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

Testing the project


We can now write a simple test for the project, just to see if the hardware connections are correct. We are going to write the code inside the Arduino IDE. Note that this section explains the code for testing the project, and that can you find the complete code in the GitHub repository of the project.

The code starts by defining the pin of the current sensor:

#define CURRENT_SENSOR A0

We then define the different variables that are necessary for the test. Here, we are going to measure the current and the power. Note that we don't measure the voltage of the device, so you will have to define it yourself depending on your country:

float amplitude_current;
float effective_value;
float effective_voltage = 230; // Set voltage to 230V (Europe) or 110V (US)
float effective_power;
float zero_sensor;

Then, in the setup() function of the sketch, we need to get the zero value of the sensor. As we have an analog sensor, we need to know what the sensor is reading when no current is flowing...

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