You are previewing Raspberry Pi Home Automation with Arduino.

Raspberry Pi Home Automation with Arduino

Cover of Raspberry Pi Home Automation with Arduino by Andrew K. Dennis Published by Packt Publishing
  1. Raspberry Pi Home Automation with Arduino
    1. Table of Contents
    2. Raspberry Pi Home Automation with Arduino
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewer
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
      2. Why Subscribe?
      3. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
    9. 1. An Introduction to the Raspberry Pi, Arduino, and Home Automation
      1. What we will explore in this book
      2. History and background of the Raspberry Pi
      3. History and background of Arduino
      4. What home automation is
      5. Summary
    10. 2. Getting Started Part 1 – Setting up Your Raspberry Pi
      1. The SD card – our Raspberry Pi's storage device
      2. Pre-installed SD card versus a blank one
      3. Setting up the SD card
      4. BerryBoot – our tool for installing an operating system
      5. Summary
    11. 3. Getting Started Part 2 – Setting up Your Raspberry Pi to Arduino Bridge Shield
      1. Raspberry Pi to Arduino bridge shield
      2. Summary
    12. 4. Our First Project – A Basic Thermometer
      1. Building a thermometer
      2. Software for our thermometer
      3. Summary
    13. 5. From Thermometer to Thermostat – Building upon Our First Project
      1. Safety first
      2. Introducing the thermostat
      3. Setting up our hardware
      4. Setting up our software
      5. Testing our thermostat and fan
      6. Summary
    14. 6. Temperature Storage – Setting up a Database to Store Your Results
      1. SQLite
      2. Apache web server
      3. HTSQL
      4. Testing our Arduino shield with our database
      5. Summary
    15. 7. Curtain Automation – Open and Close the Curtains Based on the Ambient Light
      1. Photoresistors
      2. Motor shield and motors
      3. Setting up the photoresistor
      4. Curtain control application
      5. Summary
    16. 8. Wrapping up
      1. A brief review of what we have learned
      2. Next steps
      3. Ideas for next step projects
      4. The future of home automation
      5. Summary
    17. A. References
      1. Raspberry Pi
      2. Raspberry Pi to Arduino bridge shield
      3. Linux
      4. Python
      5. C/C++
      6. Arduino
      7. SQL
      8. HTSQL
      9. Apache
      10. Electronics
      11. Packt Publishing titles
      12. Home automation technology
      13. 3D printing
      14. EEG headsets
      15. Miscellaneous resources
    18. Index
O'Reilly logo

Setting up our software

Let's start with writing a simple program that opens and closes a relay connected to the Raspberry Pi. Once we have confirmed this works we can then modify the application we wrote in the previous chapter to switch the relays on and off and construct a URL to post the data to the web.

A program to test the relay

Load up Geany and add the following program to a file called Relay.cpp in the same directory as your arduPi library:

//Include ArduPi library #include "arduPi.h" //Needed for Serial communication SerialPi Serial; //Needed for accesing GPIO (pinMode, digitalWrite, digitalRead, I2C functions) WirePi Wire; //Needed for SPI SPIPi SPI; /********************************************************* * IF YOUR ARDUINO CODE HAS ...

The best content for your career. Discover unlimited learning on demand for around $1/day.