“Alexa, Movie mode on” | Cron-Dev


To begin with, I hate remotes! Probably all of us do, and this post talks about how I eased my life a little using a bit of electronics along with my Alexa Echo dot to get rid of remotes.

Here’s the result:

Vankyo V600 – Best budget projector with amazing quality

I love watching TV on projectors, and after a lot of research, the Vankyo V600 seems to fit in my requirements perfectly. In a world where professional projectors can cost $3000, it supports a native 1920X1080 resolution at a much lower price point of 250$. The display quality is amazing with a lamp of 5000 lumens, and I can see everything even with the lights turned on (although it isn’t so much fun).

The only miss I see is that there is no Wifi support (Honestly, WiFi streaming sucks, and you can always use a FireTV stick to do Miracast if you want). I don’t mind it at all because I don’t use WiFi streaming, and my FireTV stick is always plugged in.

The image below doesn’t do complete justice to the projector because of my bad camera, but you can still see how sharp the image is.

Vankyo V600 image quality

Vankyo V600 image quality using Fight Club!

Remotes, remotes everywhere

The setup(V600 + FireTV stick) led to me having multiple remotes, one for FireTV and one for the projector. I need a remote for the projector to just switch it on and off. Let’s try to build something to get rid of this.

The FireTV stick supports something called “HDMI CEC” which allows waking up the projector through HDMI. Sadly, it doesn’t work for this projector, and even if it did, it is pointless since I still need the remote to switch it back off. (Why switch it off? Projector lamps have a lifetime, keeping it on even when you are playing nothing is killing your projector).

Alexa, open Netflix on FireTV

Amazon Echo very well integrates with FireTV. Here are the steps if you still aren’t using your Alexa device to control your FireTV. Agreed that this solution isn’t perfect, and I still use the remote for browsing, but I love that I can do things like pausing / playing without touching my remote.

Keep losing your remote like me too? I use the FireTV app on my phone, the FireTV remote is ready to be thrown away now.

Alexa, why can’t you turn on the damn projector?

Let’s get to our hacking to build a solution to control our Projector using Alexa. Keep in mind that the device can be controlled only using IR signals of a remote. On the other hand, Alexa can only talk to the internet, so we need to build a solution that helps us become a bridge between the two.

Overall, we need an an IR LED to send the signals to the projector, and a controller device to which our IR LED is connected and we mimic our remote signals. We also need this controller to be on our local network so that it can talk to Alexa.

Which controller/development board to pick?

I had an Odroid system with me(if you remember my NAS post), but it is too heavyweight, it is basically a small computer and too much of an overkill for running an LED. Also, it needs me to use a WiFi dongle or a LAN cable to connect to the internet (messy).

READ ALSO  Clio raises $250m to expand operations from Dublin headquarters

Rather, I wanted to try out the ESP8266, a very tiny microcontroller, with WiFi and Arduino capabilities, 2 of the most amazing things for an electronics hacker! (If you don’t know Arduino is one of the most popular development platforms for microcontrollers, and it is easy to find a lot of electronics development done on it).

Wait, if I have to mimic the remote, I need to understand what it is doing first.

Yes, we require to decoding our remote’s signals to be able to mimic them. We do it with help of a TSOP 1738 receiver. It is basically an IR receiver which is capable of handling IR signals at the frequency of 38kHz which is where most remotes operate on.

The circuit for reading IR remote signals is very straightforward, simply connect the 3 pins of the TSOP receiver to the microcontroller.

The code for reading the IR codes and dumping it is already present in the examples section of the library that we will be using: IRremoteESP8266
We use the IRRecvDump2.ino example to dump the remote codes as we press them on the remote. Remember to change the variable kRecvPin to the pin you connect your TSOP out to. Here it is Pin 4.

TSOP Circuit with ESP8266 to read IR signals

TSOP Circuit with ESP8266 to read IR signals

Vankyo V600 projector IR remote codes

The projector uses the NEC protocol and the On-Off code is 0xFF15EA

Let’s get our IR circuit ready

The ESP8266 is a very small chip and thus the amount of current generated on the GPIO pins is very low even to run a simple IR LED.

To allow us running our IR LED using our ESP board, we use transistors (the magical things that brought in the Computer revolution). We will use a transistor to act as an electronic switch and it will be controlled by our GPIO pin on our ESP board.

Here’s what our circuit looks like, the transistor’s Collector pin is connected to our IR LED which is connected to the 3.3V pin on our board. The Emitter pin on the transistor is connected to Ground, and the circuit only completes whenever our Base gets set to High.

IR LED Circuit with BC547 transistor with ESP8266

IR LED Circuit with BC547 transistor with ESP8266

Understand more about this circuit

A minimal theory for readers who are interested on how our transistor works. Skip this if you don’t really want to know. ESP8266 has a rated “Maximum Drive Capacity” ie the maximum current that can be delivered by any GPIO pin at 12mA. (Source Datasheet)

An IR LED on the other hand requires much higher current to be operating. eg: A 5mm IR LED requires 100mA current (Source Datasheet)

How does a transistor come into picture? 

READ ALSO  Good News! Xiaomi reportedly working on opt-out switch for MIUI Ads

We use the concept of a Transistor as a Switch. Whenever current is applied to the Base Pin of the transistor, it allows current to flow through the Collector to the emitter.

The “Cut-off region” for the transistor is the region where the flow of current from the Collector to the emitter is blocked.

Transistor to drive IR led using ESP8266

Transistor to drive IR led using ESP8266

The “Saturation region” is where the transistor allows current to flow from the Collector to emitter. As evident from the image, the current that passes through the Collector to the emitter depends on how much current is supplied at the Base. For our setup, we want the maximum supported current by the transistor (~100mA) to flow through the LED. The maximum current that can be applied to the base of BC547 is ~5mA.

We can calculate the resistance to supply the current simply using:

      Base Current = (Base Voltage - Emitter Voltage) / (Resistance)

GPIO pins in ESP8266 are 3.3V, and the Emitter Voltage in our circuit is 0V. Solving the above equation, we get a resistance of ~1kOhm.

List of electronics used

Just so you don’t get lost, here’s everything we need for the above steps:

Handling this with Alexa

Now we have a capability to turn our projector On and Off. How to make Alexa use this? I used the Wemo switch repo. It spins up a Multicast Server that can control multiple devices and talks to Alexa.

I modified the code in the repo to do the actions for my device. The only thing different that the projector I use does is how it handles the “Switch Off” action, it requires you to press the Off button twice with a certain delay. You can go ahead and make changes in the file wemo.ino



// Initialize all libraries for remote support 
#include <IRremoteESP8266.h>
#include <IRsend.h>
IRsend irsend(4);  // IR LED Pin as per our circuit.

// Inside begin -> isWifiConnected condition, we define our device and callbacks
projector = new Switch("Projector", 80, projectorOn, projectorOff);
upnpBroadcastResponder.addDevice(*projector);

bool projectorOn() {
    Serial.println("Projector on ...");
    isProjectorOn = true;

    irsend.sendNEC(0xFF15EA);
    return isProjectorOn;
}

bool projectorOff() {
    Serial.println("Projector off ...");
    
    isProjectorOn = false;    
    irsend.sendNEC(0xFF15EA);
    delay(2000); // Wait for 2 seconds and send again because our projector requires 2 Off button presses. Most devices don't need this.
    irsend.sendNEC(0xFF15EA);
    return isProjectorOn;
}

Note: I also had some troubles in getting ESP to connect to the WiFi, and increasing the timeout for the connection solved the problem.

Once you have this server up and running, you should be able to Add a new Device in the Alexa app and control your device.

Alexa combinations / routines

That isn’t it, Not yet!

I also have a smart bulb fixed in my room that works with my Alexa and supports me to turn it On and Off. Since I wanted Alexa to turn the lights Off and turn on the projector at the same time, I created an Alexa routine that does both of these things for me when I say “Movie mode On”.

Alexa routine to control ir projector and lights

Alexa routine to control ir projector and lights

And that finishes my journey to get to this point where I have lesser remotes and more peace! Except when Alexa sometimes thinks “Movie mode on” means “Play Justin Bieber music”, sigh.



Source link

?
WP Twitter Auto Publish Powered By : XYZScripts.com