Home automation – part II

Home automation system with Arduino Mega 2560, Ethernet and NFC shields

With Eastern around, I had the time today to add a few new features to my home automation project.

First of all I have bought an Ethernet shield, a NFC shield and a relay shield, such that my Arduino now is connected to the network, running a telnet server, and it can respond to NFC tags. With the relay shield I’m now also able to control high currents directly, without the detour through the remote controlled power outlets.

Getting the telnet server and NFC reader to work simultaniously was a little challenging, since the telnet server didn’t respond when run in a loop with the “readPassiveTargetID” method from the Adafruit NFC library, which blocks until a tag is read. Even after adding an overloaded “readPassiveTargetID” method with a timeout parameter, which would return after the timeout had past, the telnet server didn’t respond to the incoming data. I resolved this problem by using a timeout of 500 ms and only run the “readPassiveTargetID” method every 100th iteration, which still is about twice a second.

Right now the Arduino reacts to any NFC tag, but it is relatively simple to restrict it to certain tags. When a tag is recognized, the Arduino will turn on all lights/outlets and set the variable allIsOn to true. Next time a tag is read, all lights/outlets are turned off. The idea is, that the NFC reader is at the entrance, maybe even at the door on the outside, combined with a motorized lock, such that the door is unlocked and all lights turn on, when I get home, and the door is locked and all lights turned off, when I leave.

All code is available here: home_automation_part2.zip

By the way, this is what the webinterface looks like:

The webinterface

Comments are closed.