Project Domo: Domotics with Arduino

Turning the heating on before arriving home, watching real-time video from the inside, automatically turning the alarm on when you leave home… These are common tasks you would like to implement in a smart domotized home.

However, incorporating domotic systems to our home is still hard due to lack of an effective, simple and cheap commercial solution that fits our needs, or maybe the steps required to make it yourself are far too complex. When you realize the options available aren’t what you were looking for, and you have tried DIY solutions to automate things with Arduino, the idea comes up clear to your mind: I want to create my own domotics with arduino.

Domotics with Arduino

In this post I will talk about my domotics project using Arduino to incorporate some automation to my bedroom.

Cheap, simple and completely customizable

When I started to think about my own domotic system I tried to follow three main ideas:

  • Simple: Easy to develop system focused on usefulness. Both form the hardware and the software side.
  • Cheap: Minimum high-cost components, standard parts, common Arduino sensors and JUST ONE Arduino board.
  • Customizable: Modular design, easy to expand and completely adjusted to fit someone needs.

Project Domo: Domotics with Arduino

My domotics project is mainly based on the automation of lights, blinds, plugs and the alarm clock.

Currently the project is still developing and things working are:

  • Automatic lights
  • Smart plug
  • Remote Control

This is the configuration of my bedroom:

Bedroom

  • Two lights, one in the corridor (at the entrance) and the main light.
  • Two double three-way-switches, one next to the door and the other one nex to to my bed.
  • One plug at the right wall.
  • Arduino MEGA 2560 next to the bed (centralized control).

 Materials

  • Arduino Mega 2560
  • 2 PIR sensors
  • 4 conductor wire
  • 3 Relay modules
  • Buttons
  • IR receiver
  • Remote Control

The domotic system incorporates just one Arduino Mega 2560 board to ensure a high amount of digital I/O pins. The board is connected to different electronic modules of sensors/actuators by a 4 conductor wire.

Domotics with Arduino requires indeed of good Arduino boards and cables

The original wires for the switches of my bedroom were replaced by this other kind. Power supply goes directly to the lights which are now controlled by a relay.

Plugs maintain original wiring and are only equipped with another relay to control power supply and a button to interact with its operation modes.

PIR (Passive InfraRed) sensors are placed above the door and the other on the ceiling next to the main light.

Domotics with Arduino requires too infrared sensors.

 The IR receiver is next to the Arduino board to ensure the maximum visibility to control everything from the remote control.

Domotics with arduino requires to an IR receiver to send commands from the remote control.

Hacking Arduino

 There are great projects using Arduino with domotic pruposes, like Open Home Automation, that are very well developed or more specific ones, like Souliss or Excontrol, but those solutions use more than one Arduino board and have more expensive components.

Arduino powered by biicode

To program Arduino in a robust and structured way I have chosen C++ language and splitted the code in a modular way (the same way the electronics are set-up). This functionalities are decoupled and can be incorporated progressively to the domotic system or reused in other similar projects. Here’s where the potential of biicode’s way of programming comes to make the difference.

Utilities to incorporate to an Arduino project are countless, but many times there’s no reusable code and you have to completely adapt it. biicode lets you reuse third-party code and include it directly to your project.

 My domotic project is stored at Dani_MTB/Domo block and it has two implementations:

  • main.cpp: currently code running in the domotic system of my bedroom.
  • domo.cpp: parallel implementation to test new features.

This is main.cpp’s code:

As you can see there are some class definitions that make the program look so much cleaner and it also makes it easy to understand what’s going on!

Reusing code: Make domotics powerful

If you take a look at [requirements] section you’ll notice that some portions of code (the classes used in the code) are reused from other blocks, and even those other blocks reuse more blocks again.

Requirements of Domo: Domotics with Arduino

Here is a brief explanation for each one:

  • MultiwaySwitches: This block implements a C++ class that encapsulates the usage of three-way switches that power on and off the same light. Switches  are now digital arduino inputs (5v), which is safer for people when manipulating them.
  • SmartPlug: Here is where the code for plugs is stored. This class incorporates the activation of power supply by a relay when a button is pressed. You can select two modes: Normal activation and Sensor activation. It also incorporates a security time to automatically power off the plug. SmartPlug is useful if you want to connect an electric stove for example. This block reuses some other utilities in other blocks of biicode like SimpleTimer, Button or Relay.
  • Relay: Relay block simplifies the usage of relays with arduino (handles HIGH or LOW level activation). In my case, it is useful to control lights and plugs.
  • IRremote: IRremote implements and simplifies the usage of a remote control receiver for different kinds of standard remotes.
  • PIR: A class that encapsulates PIR sensor’s code, with methods to detect rising or falling edges and the state of the sensor.

Other developed classes and utilities are already allocated in biicode so you can incorporate and use them in your project with just an #include: Clock (Non-blocking Real Time clock without RTC module), Ultrasonic

Future implementations

There’s still a lot work ahead in my small domotic system based in arduino: internet wireless connection, a graphical user interface with a display (under construction), blind implementation… However, thanks to its modularity, robust C++ code and biicode powered Arduino, this system is a great bet to achieve a full domotic system for our bedroom.

As always, we’re available at our forum or Stackoverflow tag. You can also write us and request features at our roadmap.


Related Posts