Home automation using Arduino

Nice day to all!

I would like to make a complex small home automation system based

on Arduino or, depending on its efficiency, on ARM

microcontroller. The question is, will there be enough resources

(memory, speed) of the AVR microcontroller to control such a

system. And if not, what microcontroller would you recommend to

realise this idea? Could you comment is it possible to realise on Arduino?

The system will implement next functions:

  1. Interior and outdoor lighting. Control of 5 RGB LED groups

using DMX 512 protocol (and DMX Master Shield from tinker.it, of

course). LEDs will be controlled via special DMX drivers,

available on the market. DMX is needed because I want to control

brightness and color balance of lighting. LEDs can be controlled

either via the web app on Android phone, or via the wall mounted

switches, that will provide discrete low voltage signals (on/off)

to Arduino. Changing brightness and color balance will available

only via web app.

  1. Remote control of home appliances (equipped with IR remote

contols), such as TV, AV receiver, air-conditioning system, etc.

For this I will use 4 IR LEDs, directed to appropiate devices.

Arduino will produce appropriate PWM signals to control these

devices.

  1. Remote management of 11 solid-state relays, which in turn will

turn on / off power electrics, such as boiler, ventilation, blinds

actuators, etc.

  1. Getting the signal from following 20 sensors: state

(opened/closed) of doors, windows, blinds, locks. Monitoring water

level in water storage tank, air quality (CO2 concentration).

Getting the signal from 5 presence sensors (for lighting control)

  1. Sending following data to web app: electricity consumption,

consumption of hot and cold water, indoor and outdoor temperature.

In attachment you will find simplified structural scheme of my project.

The problem in your system is probably not CPU power, but instead the sheer number of I/Os. I think an Arduino Mega will have enough input/output pins to serve your use case, but you should carefully count the different kinds of pins (PWM, ADC, digital, etc) and make sure yourself.
The only case where CPU speed might matter is if there is some timing critical device where you have to emulate the protocol in software instead of using built-in peripherals. However, at that point, it's not clear that an ARM would do any better, because the limiting factor is typically concurrency and latency, and only indirectly CPU speed.

Thank you for quick reply!
My project is based on the assumption that I can connect up to 112 digital inputs and outputs to the i2c bus. Connecting i2c to Arduino uses only two analog pins, as I understand it.
Yes, it is so, I have to emulate the IR protocol, with accuracy up to 10 microseconds. I want to avoid using functions such as delay, but the loop time may be critical still, as the software emulates multiple interfaces such as DMX and IR. And MC as a web server must serve up to 4 clients simultaneously.
Another problem is memory. The code uses many libraries and I'm afraid that after compiling the code will be larger than 32KB.
I'd be happy to find any hardware shield that is compliant with Arduino and supports different IR protocols :slight_smile:

The biggest problem I see it using I2C for such long distances, it's not designed for that although you have an expander in there so maybe. However to get long distance from the expanders you typically have to have them at every node.

As for the processor, you could start with a Mega and if it runs out of steam the Due should be available by then and you can port to that.


Rob

I can connect up to 112 digital inputs and outputs to the i2c bus.

I don't think that's realistic, for a few reasons:

  1. Driving the bus. The Arduino only gives you a few milliamps of drive (20?) which is not enough to drive 112 separate input stages, and the pull-ups. You'll need very strong pull-ups for driving a lot of devices, too.
  2. Device addressing. Most devices don't allow you to configure arbitrary addresses -- they either come with a fixed address, or have control over, at best, something like the three lower bits of the address they want to listen to.
  3. Distance. It's not clear that you can lay out 112 devices on a single PCB such that all of them will communicate correctly over the distance from them to the Arduino. It certainly won't work if you have a hundred feet of copper in between.

If I were to go long distances, I'd use Cat5e or Cat6 cabling, and use Ethernet interfacing. Not only does this give me a lot of flexibility in how I talk between the nodes, but it also allows me to use commercial hubs/switches as boosters/repeaters if I need to. Plus it can plug into existing wiring in many cases (assuming you're in a commercial space or a home with Ethernet.)

There is a cost per node to do this, though, as you'd need a MCU and an Ethernet PHY in each location. Something integrated, like the NXP1768, might give overall lower system cost, if you put one per location like that. There are also AVR chips, cousins of the Arduino, that come with built-in Ethernet.

Finally: If you use an Arduino Mega, you get 128 kB of flash RAM, which is more than the 32 kB you get with an Uno.

Ethernet PHY in each location

RS485 would have to be cheaper I think.


Rob

Graynomad:

Ethernet PHY in each location

RS485 would have to be cheaper I think.

If you have to run new cable anyway (no available Ethernet), and don't want to re-use it for other computer communications, and don't want to be able to talk to the nodes from a regular computer, and are OK with a point-to-point or single-sender topology, then yes, it may be cheaper!
Personally, I think the economies of scale, and the adoption of wireless and wired Ethernet, makes it the de facto ubiquitous communications network. Wireless USB dongles are now $5 -- can can be used from bigger AVR chips directly.

I'm sorry. I brought you into an error, signing the i2c bus after the expander. i2c bus is between expander and arduino :slight_smile: In fact, the expander is 2..4 MCP23016 ICs, connected in parallel to the i2c bus. They are located in close proximity to the Arduino, and each can deliver 5V, 20 mA current at each of its I/O pins. After the expander there is only dry contacts and 5V signals to solid state relays. Maximum length of wires between expander and dry contacts/relays is about 7 m.

P.S. Thanks to your tip, I found a hardware solution for working with IR protocol, based on PIC16F627A chip. All the work of sending 16-bit IR codes is transferred to this chip.

Ethernet and RS485 are much more expensive solutions. Not less important goal of my project is a low power consumption and low price.

OK I see.

Bear in mind then that depending on the physical layout of the house you may be spending a lot on wires if you don't use a network of some type.


Rob

You should use the RF transceiver for communication between two arduino 12c connections over 1-2 mtrs start to become unstable