HomeAutomation - Controlling all lighting appliances and more


I have been around on this forum some while now but not really made any noise around here until now. :smiley:

I have been working with automation of my home since 2008 and as we now built our house I decided to go all in with controlling it. Earlier I controlled everything wirelessly with the Tellstick but wireless is always wireless and as the devices I have used have no feedback signal you can´t really tell if the devices have the status you tell them to have, therefore I deciced to go with Arduino.

This is my first Arduino project, but I´m sure it is not the last one :smiley:


  • Arduino Mega
  • Ethernet shield
  • IO expander board communicating through I2C (uses MCP23017 chips) - designed by me
  • 16 channel relay board

For my house I need at least 35 inputs and 35 outputs which makes the I/O pins even on the Mega not to be enough and therefore I started looking for some way to extend the number of I/Os and ended up with designing and manufacturing a I/O expander card which uses the MCP23017 chip giving 8 inputs and 8 outputs per chip. On the current version (second version) of the IO expander board I have 2 chips but I might change this in some later version. The I/O expander board communicates with the Arduino through I2C and with current configuration I can chain 4 cards giving 64 inputs and 64 outputs. Every I/O expander board is connected to a 16 channel 10A 250V relay board. The garage has a similar setup but there I only use 1 I/O card and 1 relay card.

To communicate with the Arduino I have a simple rest interface to be able to control and request status of the inputs and outputs. The rest interface will be used in the HomeAutomation webinterface which I have developed, this interface can be found at http://karpero.mine.nu/ha. With HomeAutomation you can control almost any device which has got some API or interface to connect to (some plugin development is needed if the system isn´t supported yet.

Schematic and how it looks installed you can see attached. I have a gallery for the I/O expander card too, this you can find here http://gallery.karpero.mine.nu/index.php?/category/170

This project will be extended with some sensor inputs like doors and other interesting stuff.

I plan to release the code for this too but feel that I need to get it more cleaned up before sharing with all you guys, if you have any questions please don´t hesitate to ask.



Nice !
I found this tutorial for anyone interested in learning how to use that I/O Expander chip.

Nice !
I found this tutorial for anyone interested in learning how to use that I/O Expander chip.
Tutorial: Maximising your Arduino’s I/O ports with MCP23017 | tronixstuff.com

I have also used that guide as a guideline designing my board. At the moment I use I2C library instead of Wire library just to see if the communication would be more stable. Reason for this is that I have experienced some hickups during use of Wire library but I am not sure if it is my board or the library, and switching library is easier than designing a new board for test.

Hi gyz i am working on a Home automation project using Arduino MEGA 2560 and VRM-04 wfi shield(HLK-RM04) . So i m having a little trouble linking both devices. i have been connecting
Arduino pins VRM-04(DB9 pins)
RX2 TXD(3)
TX2 RXD(2)

From this connection serial monitor is showing "WIFI SHIELD NOT FOUND"
Can u gyzzz plzzz tell me a source code for arduino mega to control 8 relays and a temperature sensor.
I have been using this "DOMOTICHOME" app so help me gyzz.
plzz check that the code given below is correct for arduino mega and my project.


I don´t think this is the right topic to get the answer for that. I think you are better of in one the subsections of Using Arduino. Try searching and/or posting there. Here is one topic HiLink-HLK-RM04 modules review - Networking, Protocols, and Devices - Arduino Forum

Nice job Tom. Excellent job in fact.

I know it was posted a while ago now, but I am newly arrived on the scene, and you have obviously committed much time and effort into producing such a comprehensive project, so I am sure it's not something you've abondoned.

I've started doing an Arduino replacement for my now unsupported Homeseer plus Homevision system, and I was quite pleased with how it was going... until I saw your post! I hope you don't regret inviting questions pal, cos I have a few!

I can't blow up the circuit diagram sufficient to show much detail, so can you explain your 'Inputs' please... I assume the 1uF caps are to absorb spikes, but are the diodes just for negative V protection or are they zener 'crowbars', and most sensor outputs would have no-volts 'dry' relay contacts so how and where are you supplying signal power to the opto inputs?
Are inputs handled by interupt?
Can inputs be triggered by both On or Off states, ie: notify when a door is opened and also when it is closed?
Have inputs got some form of individual configurable non-retrigger timeout delays to prevent continuous repeat re-triggering, ie: when someone is stood under a PIR?
Can events be time or duration triggered, ie: turn a light On at a specified time, and turn it Off after a specified duration?
Have you included any other 'event' actions yet, such as voice announcements, IR remote control, or transmitting of event-triggered IR commands etc?
Are you loading/saving defaults from configuration file and saving event logs to file on the Arduino, and if so, what media storage is being used?
Is all the home-automation functionality autonomous to the Arduino, and therefore the use of computer web interface just an option?

I've got most of the things mentioned at least partially implemented (haven't tackled timer interupts or media storage yet) but it's all only crudely hacked together as proof-of-concept so far (this is my first Arduino project also) .... so how's your code-tidying come along, because I would love to be able to compare and perhaps combine functionality with you?

Hi, glad you like it! I have by no means abandoned this project, it has now been in use in my house for over a year, 1,5 years almost, still using it every day.

  • The caps are there to absorb some of the spikes, bounce protection. This is also done in code.
  • Diodes are there for negative voltage protection as the opto isolators are very sensitive for inverse voltage and as the cables induces both negative and positive voltage this is needed.
  • The switches are feed with 24V which then is feed into the inputs when pressed.
  • No interrupts, have not seen any need for that.
  • In principle the buttons can trigger on both on and off state, this is up to the code. My solution now is to have a on trigger and a hold trigger, this way I get two functions on the same button.
  • At the moment the inputs use the same bounce timeout, but this is completely up to the code and should not be any problem to make them individual.
  • The code has no automation in it at all, all the time based events are triggered externally via REST calls to the Arduino.
  • Defaults are not saved/loaded anywhere at the moment but I have been thinking about saving the states of the outputs either on the SD-card or in the Arduino itself. Has not been a problem yet that it resets its states during a powerloss / reboot.
  • To make the project autonomous a computer is needed, at least for the time beeing, but also I think it is way too complex to implement that into Arduino.

Maybe I missed some of your questions now, but don´t hesitate to ask again :smiley: