In this project we can control electrical sockets and the main lights in house using iPhone. It’s all totally wireless and you can set up smart run-times within it.
For example, when you press the shower button it will turn on the boiler, the bathroom lights and the upstairs lights, after 1 minute it’ll turn off any downstairs lights that are still on and then after two minutes it’ll turn off the upstairs lights, and after 20 minutes it will turn off the bathroom lights.
1) An arduino (Arduino Uno).
2) An arduino Ethernet shield.
3) A RTC (real time clock) module. (Adafruit kit is highly recommended).
4) A set of RF plug sockets and remote. (Maplin’s Remote Controlled Mains Sockets).
5) Mains extensions.
6) Pattress block extenders (46mm depth recommended).
7) 75mm electrical socket screws (2x pattress block extender).
8) A router with at least one free Ethernet port that is also used for your WiFi network .
9) An iPhone or iPad.
10) Mains to USB power supply.
11) An ethernet cable.
12) A USB A to B cable.
13) Access to the mains breaker/fuse box for the building in which you’re installing this.
• How to avoid electrocuting yourself when sticking your fingers into exposed light switches
Connecting the remote to Arduino
Open the remote case.
We need to solder three wires on to the exposed circuit board. One 5V, one ground, and one data control. The 5V and Ground go to the appropriate sides of the battery holder.
If you do decide to use a separate power supply, make sure to connect the power supply’s ground to the ground pin of the arduino else the data connection won’t work(they both need the same 0V reference).
The data wire must be connected to the Dout pin of the chip (see pictures). There is a resistor which has one side directly connected to the Dout pin (see pictures).
It is much easier to solder my communications wire to this than to the chip itself. It doesn’t matter which pin on the arduino it goes into provided you change the code accordingly. Here we used pin 10 and as such that’s what the code will have as a default.
Setting Up Basic Applications ready for use
If you want to turn on things like TVs, speakers, lamps etc. then you can use the plugs you’ve already got!
Simply select which group and which channel you would like the device to have assigned to it on the back of the plug. You should note that there are a maximum of 16 possible separate plugs (four channels within four groups).
To select the group and channel turn the upper and lower dials on the back of the plug (the upper dial is the group and the lower is the channel).
Plug the RF receiver into a wall socket and the appliance into the RF plug. Your appliance is now ready to be controlled by your arduino!
Setting the IP Addresses of the Arduino and IPhone
First stack the Ethernet shield atop the arduino.
Plug the Ethernet shield into the router. The next stage is to give the arduino and your iPhone or iPad (Controlling Device) a permanent IP address each. This means that they will be able to communicate with each other over your home network.
Find the IP address of your router.Open up your internet browser of choice and type in this IP address. The web page that opens should be the setting page for your router. You will probably be asked for a username and password.
Find your Ethernet shield (you can look for the MAC address which will be printed on the bottom of your shield). Now you will need to reserve an IP address for this device. This is often just a tick box next to the device and this will mean that, whenever that device is connected to the network, it will be assigned the same IP address and that no other device can be assigned that address. Once you’ve done that, find your iPhone on the list of connected devices and do the same thing. Copy these down, as you will need to input them into the arduino code.
Updating the Code With Your IPhone and Arduino Connection Specifics
Click on the above link to download the arduino code.
Open up one of the arduino sketches. A few lines in you will find a section labelled
“//////////////// NETWORK INFO ////////////////”
Next update the IP address for your iPhone in the sketch.
The port number MUST be the same for both devices. I would recommend using 7777 as, unless you know it’s already being used by another of your projects, it is likely to be available for use. If it isn’t try using other numbers between 7718 and 7776.
Setting Up Ardumote on the IPhone
You will need to download the Ardumote app from the app store (https://itun.es/gb/RVIXA.i). On opening it you will notice a “+” symbol in the bottom right hand corner. Holding this down will give three options as to what kind of interface you want: a button, a toggle, or a slider.
A button will send a one-time message, a toggle will send a specific on or off message, and a slider will send a number from 0-255.
Choose which type of selector you’d like to use. Hold down the selector and you will be given the option to either to select the parameters or delete the selector. Click “Set Params”. The first option will be to name the selector. This is what will identify it to you on the iPhone.
The next box to fill out is the IP address of the Arduino (NOT the iPhone!). Fill this in as you filled it out in the arduino code. When you’ve done this once it should be automatically filled out for any more you create.
The next is the port number. This number is discussed in the previous step “Updating the arduino code with your iPhone and arduino specifics” but 7777 will normally do it. Make sure that the number in the arduino code and the one you enter here are the same.
The fourth box is “Message”. This is the data that’s sent to the arduino, which will identify the particular selector.
The next and final message is the number of times it will send the message when it’s pressed.
Wiring Up the Arduino
We need to solder a few wires to the RTC module (Vc++, ground, SCL and SDA).
The communications wire we soldered on to the RF remote will need to be plugged into a single digital pin on the arduino.
Tags: 201307, W5500, Adafruit, Home Automation, Arduino, Real Time Clock