Friday, November 22, 2024

Voice and Google Assistant Control Universal Remote For TV And AC

We all have televisions in our homes, whether it is a slim smart TV or a large CRT-based TV. And they require a set top box for obtaining different television channels. However, both the devices i.e. the TV and set top box have different remotes and settings. Remembering a TV channel number is another problem. 

To get rid of this issue, I have decided to make a smart remote that operates using voice commands. So instead of remembering a TV channel number, one can simply give a voice command to watch a particular TV channel. The remote is universal as well. Therefore besides TV and set top box, one can add various remote codes and functions to control a CD player, music system, home theatre system, projector and even an air-conditioner (if it works on IR). 

The project requires retrieving the RAW or HEX code from a TV remote control. However, we can eliminate this step by getting the remote codes for each button from the internet.

- Advertisement -

- Advertisement -

Bill Of Materials

 We need the following components for this project.

Prerequisite 

First install the Raspberry Pi with the latest AIY version of the Raspbian image. Then open the terminal in Raspberry Pi and install the Speech Recognition Module for Python. Also install the PySerial module for Python using the following commands:

sudo pip3 install pyaudio
sudo pip3 install speechrecognition 
sudo pip3 install pyserial 

Next, install the required libraries in Arduino IDE for decoding the IR signal and transmitting it. There are lots of different IR libraries available in Arduino to decode IR signals. Here I have used a library called Infrared. To install it, go to Sketch → Library Manager→ Infrared.

IR Decoder Circuit 

It will read the signal of the remote and capture the codes of each button so that they can be transmitted from Arduino for operating the TV. You can skip this step by directly searching the IR codes of each button on the internet. Refer the website given below to get the IR codes of various remote control devices.

URL: http://irdb.tk/find/

If you could not find the code on the internet, then you can take the help of the given circuit.

First, connect the TSOP IR receiver pins as described below. 

Now again open the Arduino IDE, open all reader codes, upload them to Arduino and change the IR receive pin to 9 in the code. Upload the code and then open the serial monitor. Press each button of the remote one by one, note them and save them in another .text file.

Preparing the IR Transmitter 

To prepare the IR transmitter, connect the -ve pin of IR LED to the -ve pin or GND pin of Arduino and +ve pin to pin 9 of Arduino.

Coding

Include the Infrared library in the code and then paste the remote button array in the code (as shown in the figure below). Then create a setup function where we will set the serial port using Serial.begin (baudrate). Enter a specific baud rate (here i am using 115200). 

Next create a loop function for checking the commands coming from the serial port. After that, create a nested if condition to check the received commands and define the functions. 

For instance, if the command is 1 and you have to watch the Discovery channel, then set the function for this command to open the channel. Then send the channel number of Discovery from IR LED using IR send. That is, if the Discovery channel in my set top box is 102, we need to send the code for button 1, then 0 and then 2 with a delay of 200 microseconds. 

Preparing The Raspberry Pi 

Import the AIY Voice Kit library to use the voice bonnet for recording the voice from the speaker. By importing the PySerial library in the code, the Raspberry Pi and Arduino start to communicate with each other.

Next import the speech recognition library into the Raspberry Pi, which will recognise the command given by the speaker. After that, check the serial port of Arduino and add that serial port number in the Python code (as shown in the pic.).

 Now create a while function for checking the button pressed on the bonnet. When pressed, the voice command is recognised and sent to Arduino to open the specified channel as given through the voice command.

Testing

Connect the Arduino with Raspberry Pi’s USB port. Run the code and then bring the IR Transmitter LED (that is present on Arduino) in front of the set top box. Press the button on the bonnet and give it a command by saying “channel up“  or “discovery“. The bonnet will recognise the voice and send the command to Arduino to set the TV channel.

Ashwini Sinha
Ashwini Sinha
A tech journalist at EFY, with hands-on expertise in electronics DIY. He has an extraordinary passion for AI, IoT, and electronics. Holder of two design records and two times winner of US-China Makers Award.

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics