Control AC from anywhere with smartphone — DIY Smart Home

Written by obniz.io | Published 2018/08/02
Tech Story Tags: javascript | control-ac-from-anywhere | diy-smart-home | ac-control | air-conditioning

TLDRvia the TL;DR App

This remote AC controller enables you to measure room temperature and switch on/off your air conditioner from outside with your smartphone. You can turn on your air conditioner before reaching home and stay comfortable at home. Let’s create DIY air conditioner remote controller with obniz.

Things used in this project

· Obniz

· IR module

· LM32DZ

· Smartphone

Step 1 — setting up obniz

To get started, all you need to do is to follow three steps.1. Connect obniz to wifi2. Connect devices like LED or motors to obniz3. Scan QR code of obniz and start programming. You do not need to install any software.

Step 2

Connect IR module and LM32DZ to obniz as below and place it in your house.

Step 3

Write the program written in the program section. You need to change obniz ID in the program to yours. By clicking “save & open,” you can see the room temperature.

Step 4

Record your air conditioner’s signal for ON/OFF.

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

Write the recorded data array into your program.

Use it!

Open the HTML on the web browser with your smartphone. You can control your air conditioner from everywhere in the world!

What is Obniz?

Obniz is a cloud-connected IoT development board. You can program on the web browser of any smartphone or computer and the command is sent to obniz through the internet via obniz cloud. By connecting the Obniz to the cloud through wifi, users can remotely control devices that are physically connected to obniz.

Obniz has 12 IO and WiFi-BLE module. It can be controlled through the APIs — REST or WebSocket API — on obniz cloud. Not only simple IO on/off but also UART, I2C, BLE etc can be used by remotely controlling obniz via internet. All you need to do to connect obniz is to input unique ID by scanning QR code. Complicated processes are done by obniz and its cloud. You can just start programming in HTML, browser and circuit have already been integrated. If you write a program to collect sensor values, you can make a chart of the values easily.

In terms of hardware, every IO can drive up to 1A with overcorrect protection, therefore high current demanding devices such as motors can be directly connected to Obniz IO. GPIO and AD can be used on every IO. UART, SPI etc peripherals can be assigned to every IO. Even output voltage 3v/5v can be changed by software. Most electrical parts can be connected directly. Embedded parts such as switch, OLED display, and BLE are ready for use on program.

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/[email protected]/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>


Published by HackerNoon on 2018/08/02