Sainath Komakula
Published © GPL3+

Netra

Smart IR Blaster.

IntermediateFull instructions provided5 hours920
Netra

Things used in this project

Hardware components

General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Jumper wires (generic)
Jumper wires (generic)
Male to female Jumper wire
×1
Breadboard (generic)
Breadboard (generic)
×1
IR receiver (generic)
To decode IR protocol
×1
IR transmitter (generic)
To transmit IR protocol
×1

Software apps and online services

Node JS
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Smart IR Blaster

JavaScript
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var serialPort = require('serialport'); // include the serialport library
  var SerialPort = serialPort.SerialPort;
    var portName = '/dev/ttyS0';
	serialPort = new SerialPort(portName, {
	    baudrate: 57600,
	    // defaults for Arduino serial communication
	     dataBits: 8,
	     parity: 'none',
	     stopBits: 1,
	     flowControl: false
       });
  app.get('/', function(req, res){
    res.sendfile('index_with_numeric_buttons.html');
  });


  io.on('connection', function(socket){

    console.log('new client connected');
    socket.on('TVPwr', function(data){
          console.log(data);
      serialPort.write('TVPwr');
        });
    socket.on('TVchUP', function(data){
          console.log(data);
      serialPort.write('TVchUP');
        });
    socket.on('TVchDW', function(data){
              console.log(data);
             serialPort.write('TVchDW');
    });
 socket.on('TVvUP', function(data){
                  console.log(data);
                  serialPort.write('TVvUP');
      });
socket.on('TVvDW', function(data){
                  console.log(data);
                  serialPort.write('TVvDW');
                });

socket.on('STBPwr', function(data){
                console.log(data);
                serialPort.write('STBPwr');
                  });
socket.on('STBchUP', function(data){
          console.log(data);
          serialPort.write('STBchUP');
                    });
socket.on('STBchDW', function(data){
          console.log(data);
          serialPort.write('STBchDW');
              });
socket.on('STBvUP', function(data){
          console.log(data);
          serialPort.write('STBvUP');
              });
socket.on('STBvDW', function(data){
          console.log(data);
          serialPort.write('STBvDW');
                   });

  socket.on('HTPwr', function(data){
               console.log(data);
                  serialPort.write('HTPwr');
                      });
  socket.on('HTvUP', function(data){
                console.log(data);
                   serialPort.write('HTvUP');
                  });
   socket.on('HTvDW', function(data){
                console.log(data);
                    serialPort.write('HTvDW');
                });
  socket.on('1', function(data){
                console.log(data);
                  serialPort.write('1');
      });
  socket.on('2', function(data){
                console.log(data);
                  serialPort.write('2');
          });
socket.on('3', function(data){
                  console.log(data);
                  serialPort.write('3');
                  });

  socket.on('4', function(data){
                console.log(data);
                  serialPort.write('4');
      });
  socket.on('5', function(data){
                console.log(data);
                  serialPort.write('5');
          });
  socket.on('6', function(data){
                console.log(data);
                serialPort.write('6');
                  });

  socket.on('7', function(data){
                console.log(data);
                serialPort.write('7');
      });
  socket.on('8', function(data){
                console.log(data);
                serialPort.write('8');
          });
  socket.on('9', function(data){
                console.log(data);
                serialPort.write('9');
                  });
socket.on('0', function(data){
                console.log(data);
            serialPort.write('0');
                  });

  });

  http.listen(3000, function(){
    console.log('listening on *:3000');
  });

Index page for webUI

HTML
<!DOCTYPE html>
<html>
<head>
  <!-- Include meta tag to ensure proper rendering and touch zooming -->
  <meta name="viewport" content="width=device-width, initial-scale=1" >
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <!-- Include jQuery Mobile stylesheets -->
  <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

<!-- Include the jQuery library -->
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

<!-- Include the jQuery Mobile library -->
  <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

  <script src="socket.io/socket.io.js"></script>
  <title> Testing</title>
<style>
  .ui-bar-c{
    text-align: center;
    padding: 5px 4px;

  }
</style>

</head>
<body>
<div data-role="page" id="pageone">
  <div data-role="header" data-theme="b">
  <h1>Smart Control Panel</h1>
  </div>

  <div data-role="main" class="ui-content">
<a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-b ui-btn-inline ui-corner-all">Set Top Box</a>

<div class="ui-grid-b ui-responsive">

<div data-role="popup" id="myPopup" class="ui-content" data-theme="b">
      <a href="#" data-rel="back" class="ui-btn ui-btn-a ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
     <div>
       <button class="ui-btn" type="button" id="STBPwr">Power</button>
     </div>

     <br>
     <div class="ui-grid-b ">
     <div class="ui-block-a"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="1" > 1 </a></div>
     <div class="ui-block-b"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="2" > 2 </a></div>
     <div class="ui-block-c"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="3" > 3 </a></div>
     <div class="ui-block-a"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="4" > 4 </a></div>
     <div class="ui-block-b"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="5" > 5 </a></div>
     <div class="ui-block-c"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="6" > 6 </a></div>
     <div class="ui-block-a"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="7" > 7 </a></div>
     <div class="ui-block-b"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="8"> 8 </a></div>
     <div class="ui-block-c"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="9" > 9 </a></div>
     <div class="ui-block-c"><a href="#" class="ui-btn ui-shadow ui-corner-all" id="0" > 0 </a></div>
 </div> <div>
           <button class="ui-btn" type="button" id="STBchUP">CH ++ </button>
           <button class="ui-btn" type="button" id="STBchDW">CH -- </button>
         </div>
         <br>
         <div>
           <button class="ui-btn" type="button" id="STBvUP">Vol +</button>
           <button class="ui-btn" type="button" id="STBvDW">Vol -</button>
         </div>
        </div>

    </div>
    <br>
    <div>
      <H1>TV</H1>
      <div>
        <button class="ui-btn" type="button" id="TVPwr">Power</button>
      </div>

      <div>
           <button class="ui-btn" type="button" id="TVchUP">CH ++ </button>
           <button class="ui-btn" type="button" id="TVchDW">CH -- </button>
         </div>
         <br>
         <div>
           <button class="ui-btn" type="button" id="TVvUP">Vol +</button>
           <button class="ui-btn" type="button" id="TVvDW">Vol -</button>
         </div>

    </div>
  <br>
    <div>
      <H1>AC</H1>
      <button class="ui-btn" type="button" id="ACtempDec">AC Temp ++ </button>
      <button class="ui-btn" type="button" id="ACtempInc">AC Temp --</button>

    </div>

    <br>

 <div>
      <H1>Home Theater</H1>
 <div>
       <button class="ui-btn" type="button" id="HTPwr">Power</button>
     </div>
      <button class="ui-btn" type="button" id="HTvUP">Home Theater Vol ++ </button>
      <button class="ui-btn" type="button" id="HTvDW">Home Theater Vol --</button>
    </div>
  </div>

</div>

<script>
  var socket = io();
  $('#STBPwr').on("click", function() {
            socket.emit('STBPwr', 'Set Top Box power button is clicked ' );
                });

$('#STBchUP').on("click", function() {
              socket.emit('STBchUP', 'Forward channel is clicked ' );
              });
$('#STBchDW').on("click", function() {
             socket.emit('STBchDW', 'Backward channel is clicked ' );
             });
$('#STBvUP').on("click", function() {
            socket.emit('STBvUP', ' Volume Up ' );
              });

$('#STBvDW').on("click", function() {
             socket.emit('STBvDW', ' Volume Down ' );
                        });
$('#TVPwr').on("click", function() {
               socket.emit('TVPwr', ' TV power button is clicked ' );
                      });
$('#TVchUP').on("click", function() {
              socket.emit('TVchUP', 'Forward channel is clicked ' );
              });
 $('#TVchDW').on("click", function() {
               socket.emit('TVchDW', 'Backward channel is clicked ' );
               });
$('#TVvUP').on("click", function() {
                socket.emit('TVvUP', ' Volume Up ' );
              });

$('#TVvDW').on("click", function() {
                 socket.emit('TVvDW', ' Volume Down ' );

                });

$('#HTPwr').on("click", function() {
              socket.emit('HTPwr', ' Home Theater Power button ' );
             });

$('#HTvUP').on("click", function() {
              socket.emit('HTvUP', ' Home Theater Volume Up ' );
             });
$('#HTvDW').on("click", function() {
              socket.emit('HTvDW', ' Home Theater Volume Down ' );
             });
 $('#1').on("click", function() {
               socket.emit('1', ' Number 1 clicked  ' );
             });
  $('#2').on("click", function() {
              socket.emit('2', ' Number 2 clicked  ' );
             });
 $('#3').on("click", function() {
               socket.emit('3', ' Number 3 clicked  ' );
            });
 $('#4').on("click", function() {
              socket.emit('4', ' Number 4 clicked  ' );
                                   });
  $('#5').on("click", function() {
               socket.emit('5', ' Number 5 clicked  ' );
             });
  $('#6').on("click", function() {
              socket.emit('6', ' Number 6 clicked  ' );
             });
  $('#7').on("click", function() {
             socket.emit('7', ' Number 7 clicked  ' );
              });
  $('#8').on("click", function() {
            socket.emit('8', ' Number 8 clicked  ' );
               });
 $('#9').on("click", function() {
            socket.emit('9', ' Number 9 clicked  ' );
               });
 $('#0').on("click", function() {
            socket.emit('0', ' Number 0 clicked  ' );
               });
     </script>


</body>
</html>

Arduino code for IR

Arduino
#include <IRremote.h>

  const int LED_BUILTIN = 13;
String serial_string;


IRsend irsend;

  void setup() {
   
 Serial.begin(115200);  // open serial connection to USB Serial port (connected to your computer)
    Serial1.begin(57600);  // open internal serial connection to MT7688AN

  // init LEDS
  pinMode(LED_BUILTIN,OUTPUT);

}

void loop() {

 if (Serial1.available() > 0) {
  serial_string = Serial1.readString();
  // put your main code here, to run repeatedly:

// Toshiba TV code 
if(serial_string=="TVPwr")
{    irsend.sendNEC(0x2FD48B7, 32);// channel up
 Serial1.flush(); 

   }
if(serial_string=="TVchUP")
{    irsend.sendNEC(0x2FDD827, 32);// channel up
 Serial1.flush(); 

   }
  else if(serial_string=="TVchDW")
   {
      irsend.sendNEC(0x2FDF807, 32);
       Serial1.flush(); 
      
   }
   else if(serial_string=="TVvUP")
   {
      irsend.sendNEC(0x2FD58A7, 32);
       Serial1.flush();
 }
 else if(serial_string=="TVvDW")
   {
      irsend.sendNEC(0x2FD7887, 32);
       Serial1.flush();
 
}


// Set Top Box code 

if(serial_string=="STBPwr")
{    irsend.sendRC6(0xC0000C, 24);// channel up
 Serial1.flush(); 

   }
   if(serial_string=="STBchUP")
{    irsend.sendRC6(0xC00020, 24);// channel up
 Serial1.flush(); 

   }
  else if(serial_string=="STBchDW")
   {
      irsend.sendRC6(0xC00021, 24);
       Serial1.flush(); 
      
   }
   else if(serial_string=="STBvUP")
   {
      irsend.sendRC6(0xC00010, 24);
       Serial1.flush();
 }
 else if(serial_string=="STBvDW")
   {
      irsend.sendRC6(0xC00011, 24);
       Serial1.flush();
 
}
else if(serial_string=="1")
   {
      irsend.sendRC6(0xC00001, 24);
       Serial1.flush();
 
}
else if(serial_string=="2")
   {
      irsend.sendRC6(0xC00002, 24);
       Serial1.flush();
 
}else if(serial_string=="3")
   {
      irsend.sendRC6(0xC00003, 24);
       Serial1.flush();
 
}else if(serial_string=="4")
   {
      irsend.sendRC6(0xC00004, 24);
       Serial1.flush();
 
}else if(serial_string=="5")
   {
      irsend.sendRC6(0xC00005, 24);
       Serial1.flush();
 
}else if(serial_string=="6")
   {
      irsend.sendRC6(0xC00006, 24);
       Serial1.flush();
 
}else if(serial_string=="7")
   {
      irsend.sendRC6(0xC00007, 24);
       Serial1.flush();
 
}else if(serial_string=="8")
   {
      irsend.sendRC6(0xC00008, 24);
       Serial1.flush();
 
}
else if(serial_string=="9")
   {
      irsend.sendRC6(0xC00009, 24);
       Serial1.flush();
 
}else if(serial_string=="0")
   {
      irsend.sendRC6(0xC00000, 24);
       Serial1.flush();
 
}
 }
}

Credits

Sainath Komakula

Sainath Komakula

3 projects • 5 followers

Comments