Remote Air Conditioner Controller

Control an air conditioner from your smartphone with obniz! Put obniz + IR + temperature sensor to your home. You can control it from a browser on your Smartphone.

Materials

(*) These are included in IoT Home Kit.

Steps

First, connect parts to an obniz like the table and the image below.

obniz parts
0 [IR Module] Vcc
1 [IR Module] send(IR LED anode)
2 [IR Module] recv(IR Receiver output)
3 [IR Module] GND(IR LED cathode)
7 [LM35DZ] GND
8 [LM35DZ] output
9 [LM35DZ] Vcc

Supply power to the obniz and run the program. The temperature measured by temperature sensor will be displayed.

Second, record your air conditioner’s signal for ON/OFF.

The example contains comment outed code for IR receiver. Remove the comment out and record your air conditioner’s ON/OFF signal. Your signal will be showed in log.

Put recorded data into the array of the infraredLed.send([]) at the “Program”(line 46).

$("#on").click(function(){
    // your value for ON here.
    infraredLed.send([])
  })
  
  $("#off").click(function(){
   // your value for OFF here
    infraredLed.send([])
  })

At last, run the program again and push tap the “ON/OFF” button.

Use it !

Just open the HTML, and you can control your air conditioner from everywhere in the world!

Program

<!-- HTML Example -->
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
  <script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
  <script src="https://unpkg.com/obniz@2.0.2/obniz.js"></script>
  
</head>
<body>

<div id="obniz-debug"></div>

<h1 id="temp">Measuring...</h1>
  
<p>
  <button id="on" class="btn btn-primary btn-block">Turn ON</button>
</p>
<p>
  <button id="off" class="btn btn-primary btn-block">Turn OFF</button>
</p>

<script>
  
var obniz = new Obniz("OBNIZ_ID_HERE");

obniz.onconnect = async function () {
  
  //var sensor = obniz.wired('IRSensor', {vcc:0, gnd:3, output: 2});
  //sensor.start(function (arr) {
  //  console.log('detected!!')
  //  console.log(JSON.stringify(arr));
  //})

  // Javascript Example
  var tempsens = obniz.wired("LM35DZ",   { gnd:7 , output:8, vcc:9});
  tempsens.onchange = function(temp){
    $("#temp").text('' + parseInt(temp)+ ' degree')
    obniz.display.clear();
    obniz.display.font('Avenir', 60)
    obniz.display.print('' + parseInt(temp) + '℃')
  };
  
  var infraredLed = obniz.wired('InfraredLED', {anode: 1, cathode: 3});
  
  $("#on").click(function(){
    // your value for ON here.
    infraredLed.send([])
  })
  
  $("#off").click(function(){
   // your value for OFF here
    infraredLed.send([])
  })
}


</script>
</body>
</html>
 

 

 

Recommended