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

kraken.jpgThe 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 ESP8266 ESP-01, which is also used in many Wifi switches (e.g. light switches, dimmers, etc.) and sockets (e.g. Sonoff S20 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 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

kraken.jpgTV 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 a software developer, trader and martial artist from germany. Besides programming, trading and martial arts some of my interests and hobbies are cooking, fitness and hearing loud heavy metal music. :D

This might also be interesting for you

Window child safety locks for a safe home

A very big source of danger for children are windows, because the own child climbs from time to time with much skill on the window sill to look outside. An opened window, or one which can be opened easily, quickly becomes a threatening danger to life and limb if no appropriate precautions are taken. Security … Continue reading "Window child safety locks for a safe home"


Kids toys and other useful things from the 3D printer

Many projects and ideas have already been presented here in the blog, which can be realised quickly and cost-effectively thanks to 3D printing. It's impossible to capture and collect everything that creative minds around the world come up with. Some funny toys for children and also helpful templates for the 3D printer from the field … Continue reading "Kids toys and other useful things from the 3D printer"


Unity 2D Platformer - Level Generator

For some time now I have been experimenting here and there with the 2D and 3D engine Unity. Especially the programming of a 2D-Platformers has been very interesting for me. However, programming a 2D game (if you are a programmer) is not the biggest problem, but in my opinion the look, because I am not … Continue reading "Unity 2D Platformer - Level Generator"


Even more useful things from the 3D printer

Here and now the continuation from the first part, about sense and nonsense from the 3D printer. You can argue about the usefulness and usability, but for example you can't discuss away some practical kitchen helpers. What can you do if you want to prepare Wiener Schnitzel, for example, but the wooden meat tenderizer has … Continue reading "Even more useful things from the 3D printer"


Build your own washbasin for your toddlers

Since our little daughter (and probably also every other toddler) would like to do everything herself, we try our best to fulfill her wish. Of course we do not want to slow down this zest for action in the bathroom when washing our hands or brushing our teeth and so a wooden children's chair was … Continue reading "Build your own washbasin for your toddlers"


Leave a Reply

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

I have read and accepted the privacy policy!