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

pi_robot - Playing with Raspberry Pi, iPad and some Code

The Raspberry Pi is still one of the most popular mini computers, not only among hobbyists. Cost-effective (about 30 to 40,- EUR depending on the model), flexible in the field of application and at the latest since the equipped with enough CPU power and memory to solve even more complex tasks. With the 1.2 GHz … Continue reading "pi_robot - Playing with Raspberry Pi, iPad and some Code"


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"


Ikea Upcycling idea - Old lamp in a new look

Almost everyone knows the furniture giant Ikea and has one or the other piece of furniture from this Swedish furniture chain at home. The offer is huge and often you unintentionally buy more than you actually wanted. Stylish tables, chairs, shelves, decorative items and fragrant scented candles and lamps for a great atmosphere and much … Continue reading "Ikea Upcycling idea - Old lamp in a new look"


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"


Arduino Fitnessboard v1 - Experiment

On the weekend I fortunately had some time for handicrafts and a nice idea for a fitness board for training at home, which is operated from the push-up position. A video can be found further down in this article and on the Youtube channel of tedokai.de. Table of contents:Building  an Arduino Fitness BoardFitnessboard - RequirementsFitnessboard … Continue reading "Arduino Fitnessboard v1 - Experiment"


Leave a Reply

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

I have read and accepted the privacy policy!