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 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

This might also be interesting for you

My new 3D printer and housing from Ikea side table

I had the intention to buy myself a 3D printer ages ago. However, this project failed until the end due to bad reviews I had to read about various models and their price-performance ratio. This changed when I discovered the at Amazon. This is rated almost completely positive and was reduced from 499,- to 399,- … Continue reading "My new 3D printer and housing from Ikea side table"


Build Activity Board for children - Do it yourself

As you know as a mother or father, babies and toddlers love everything that moves, makes sounds and feels interesting. Everything has to be tried out. Parents can actively support this research urge by creating their own . Through the innumerable design possibilities you can support your child playfully and send him on a fun … Continue reading "Build Activity Board for children - Do it yourself"


Ikea Upcycling idea: LED lamp with WiFi remote control

Inspired by some of my last lighting projects for bedrooms and children's rooms, I had some motivation and above all time to tinker on the weekend. As with the Ikea Upcycling lamp for the children's room from the 3D printer, I wanted to turn something old into something new. This time, however, the lamp was … Continue reading "Ikea Upcycling idea: LED lamp with WiFi remote control"


Children, cold weather and lots of fun

Several doctors recommend that children spend at least half an hour a day in the fresh air, which I personally find quite conclusive. In some weather conditions, however, you may wonder whether it is good for the child's health. Often you have no idea about activities in cold weather, which would be fun for you … Continue reading "Children, cold weather and lots of fun"


Telegram Messenger and the Bot API

Telegram is basically a messenger similar to Whatsapp or Threema , free and easy to use. I don't want to say that it is better or worse than other messengers, but I like the Telegram Bot API so much that I want to write a little tutorial here. Table of contents:Using Telegram Messenger and the … Continue reading "Telegram Messenger and the Bot API"


Leave a Reply

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

I have read and accepted the privacy policy!