Smart Home V1 - Do it yourself

RemoteControl Box WLan

I've been planning my smart home for some time now. Besides the cost factor for all the great things I imagine, I often lack the necessary time for detailed planning and implementation.

So I decided to start somewhere and write down this DIY project in parallel...let's see where it leads...I ask for your indulgence if I don't go into every little detail, but I think it's all quite understandable. If you have any questions you can send me a mail and I will see if I can help. 🙂

Table of contents:

Smart Home - Do it yourself

AmazonThe long-term goal is to assign a central app for my smartphone, which can control all electronic components in the household if possible. The whole thing should run on my iPhone (+Apple Watch) as well as on my iPad and if possible without Alexa & Co., because I think it's crazy to send data around the globe just to switch on a lamp or a TV. From that point on this is a hobby project and just a lot of fun!

Mainly I use the WLan module ESP8266 ESP-01, which is also used in many Wifi switches (e.g. light switches, dimmers, etc.) and sockets (e.g. Sonoff S20). The advantage is that the firmware of the modules can be overwritten or flashed relatively easily and the chip can be fed and operated with its own code. So you are able to connect them directly to your own home network without having to rely on cloud services like Amazon AWS.

A start: control TV and Horizon recorder

In the first step I thought about being able to control my LG-TV and the Horizon recorder from Unitymedia via an app within my own WLAN.

Required components for controlling devices via infrared and WLAN:
- Arduino UNO
- 5V Breadboard power supply
- IR (Infrared) Receiver module and one IR LED
- WLAN Module ESP8266 ESP-01
- A few cables, rechargeable drills, soldering iron, hot glue gun and if necessary a case (for example out of the 3D Printer) where the whole technology is accommodated.

When I put it together, it looks like this:

DIY RemoteControl BoxAt first sight simple because the TV as well as the DVD player are controlled by IR signals (infrared), which is not a big problem. Simply connect the IR receiver to the Arduino, integrate the IRremote library, and output the received IR codes via if (irrecv.decode(&results)) and results->value in loop().

Then you can point the remote control of the TV at the IR receiver, press the required buttons and get the corresponding codes, which you can then send later via IRSend and an attached IR LED. The corresponding code is simple (in my case for a LG-TV) and could look like this:

#define TV_POWER_ON 0x20DF10EF
.....
void sendIR(unsigned long code)

{
irsend.sendNEC(code, 32); //LG uses NEC-Protocol
}

Next, I connected the ESP8266 to my Arduino, connected it to my WLAN using a small Wifi library (WiFiEsp), and opened port 10005 for UDP packets. So I can send instructions to this port via my small iOS app, which the Arduino then sends to the TV via IR.

iOS App to remote control the Horizon-Box

AmazonTV or other IR-capable devices is no big deal. As so often, the trick is in the detail, because the Horizon Recorder from Unitymedia is controlled via radio or WLan.

Since there is no documentation about the control codes I did some research on the internet and got friendly support in several forums and websites.

After a lot of testing it was finally easy to program the desired functionality in Objective-C and bring it to my iPhone. Nice at this solution that the Arduino is relieved, because the app can communicate directly without detours with the Horizon recorder.

In short, I have defined the keys (2 bytes each) as follows.

#define key_power @"E000"
#define key_number0 @"E300"
#define key_number1 @"E301"
...e.g...

Then I wrote a small function which takes the respective control code after the handshake with the Horizon recorder, forms a corresponding byte array and sends it to the box. The 8 bytes that make up the whole control code are sent 2 times in a row with a short pause, where byte no. 2 is one (key pressed) and zero (key released). The whole thing looks like this...

-(void)sendWifiCmdUM:(NSString*)sCode
{
char data[] = {0x04, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; //the last 2 bytes represent the key code

unsigned int anInt;
NSString *hexCharStr = [sCode substringWithRange:NSMakeRange(0, 2)];
NSScanner *scanner = [[NSScanner alloc] initWithString:hexCharStr];
[scanner scanHexInt:&anInt];
data[6] = (char)anInt;
scanner = nil;

hexCharStr = [sCode substringWithRange:NSMakeRange(2, 2)];
scanner = [[NSScanner alloc] initWithString:hexCharStr];
[scanner scanHexInt:&anInt];
data[7] = (char)anInt;
scanner = nil;

//press button
[socket sendBytes:data count:8];

//wait
[NSThread sleepForTimeInterval:0.1f];

//release button
data[1] = 0x0;
[socket sendBytes:data count:8];

NSLog(@"SENT (%@)", sCode);
}

RemoteControl App iOSSubsequently I built a small frontend for the app and implemented the corresponding functionalities.

In principle, the app currently consists of 3 tabs. Horizon, TV and Config.

I included the volume control for the TV in the dialogues for Horizon, because in practice switching back and forth was a bit annoying.

For a short time I also had OpenEars for speech recognition in it. But I commented this out again, because the recognition is not good enough for my taste, and I simply find the operation faster and more target-oriented via a tap in the app.

The configuration dialog is good for setting the IP addresses of the Horizon-Box and Arduino, but also handy for saving the Horizon-Recorder's youth protection pin. So you can let the app transfer the whole pin input without having to do it on your own.

WatchOS RemoteControl AppSince I was in the flow while writing the app, I also connected the Apple Watch.

Unnecessary but somehow also a funny toy if you can control the TV and Horizon with your watch on your wrist.

That's the state for now...You can find out how the project will continue here at Tinkering-Sascha.com in due course.

Suggestions, improvements or references to your own projects are welcome and can be sent to me by mail. I'd like to present them here as a source of inspiration. 🙂

 

Author: Sascha from Tinkering-Sascha.com

Author: Sascha

Some words about myself. My name is Sascha - i'm in my mid-30s and a software developer and martial artist from germany. Besides programming and martial arts some of my interests and hobbies are cooking, fitness and hearing loud heavy metal music. :D

Related postings

Meditation Bench - Do it yourself

A pleasant upright posture is enormously important when meditating. As already described in a previous article (Introduction to Meditation), there are a variety of aids such as meditation benches, meditation stools or . These make the meditation phase pleasant and comfortable, whereby a simple woollen blanket or similar is sufficient for some. Especially a has … Continue reading "Meditation Bench - Do it yourself"


Kids toys and Ikea hacks from the 3D printer

3D printers are great toys for adults and now relatively good, easy to use and relatively affordable. As already mentioned in this article (build your own Hörbert similar MP3 player) you can even print padlocks and fasteners. Even wall mounts for swords and knives or even a closed housing for the 3D printer with the … Continue reading "Kids toys and Ikea hacks from the 3D printer"


Telegram Messenger and the Bot API - Part 2

In the first part - Telegram Messenger and the Bot API - I explained some basics how to set up a telegram bot and how to use it to send messages, states, informations and more to your . Since this tool has proven to be very practical, I decided to take up the previous article … Continue reading "Telegram Messenger and the Bot API - Part 2"


Build your own family bed

When we had prepared the children's room of our daughter including wardrobe and own bed, we assumed at that time that she would also sleep there. After some time, however, we noticed, as many parents before us have, that this was simply not the time yet. Be it through thirst, hunger, toothache or night scare, … Continue reading "Build your own family bed"


self-construction - DynDNS-Alternative

If you already have your own webserver/webspace on the Internet and some programming knowledge, you can save yourself a service like DynDNS.org & Co. without much effort if you want to access parts of your home network from the road. Such services provide a host name/URL (e.g. my-home-network.dyndns.org) which is then forwarded to the IP … Continue reading "self-construction - DynDNS-Alternative"


Leave a Reply

Your email address will not be published. Required fields are marked *

I have read and accepted the privacy policy!