Friday, June 21, 2013

Control Your AirCon from a Raspberry Pi

  
Having an Aircon is good but the time it takes to cool down your apartment is frustrating!!! solution is to turn it on before you arrive right? let the PI do the job for you. there are two ways
  • you can assign a cronjob task to turn on the ac at a specific time of the day
  • you can run a php server giving control to the outside world etc android phone or a browser.
things you need
  • relay board,cables,insulating tape and casings.
lets hack the controls.

and make sure to get a photo before you remove the control from the wall. here's mine


raspberry pi connections are as follows

   
Now lets do some programming.

I'm not going to cover the basics here. you should first setup your raspberry pi with  raspbian OS.
to setup apache webserver with php type

sudo apt-get install apache2 php5 libapache2-mod-php5

if you get an installer error run

sudo groupadd www-data
sudo usermod -g www-data www-data

now to restart the service type

sudo service apache2 restart

after it finishes we can install WiringPi

cd /tmp
wget http://project-downloads.drogon.net/files/wiringPi.tgz
tar xfz wiringPi.tgz
cd wiringPi/wiringPi
make
sudo make install
cd ../gpio
make
sudo make install

lets give the pi a static ip from the router. remember to give an ip that is outside the DHCP range.
see this awesome video from YouTube. (all credit goes to Raspberry Pi for Beginners Author)


and we are done. lets control the power button of the ac via a simple web page.

create a web page in php with 2 simple buttons and save it as sam.php

<html>
<form action="sam.php?message=ON"  method="post">
<input type="submit" style="width:400px; height:180px; font-size:250%; margin-left:35%;"  value="AC ON">
</form>
<br/>

<form action="sam.php?message=OFF"  method="post">
<input type="submit" style="width:400px; height:180px; font-size:250%;  margin-left:35%;" value="AC OFF">
</form>
</body></html>


<?php
shell_exec("/usr/local/bin/gpio -g mode 18 out");
$name = $_GET["message"];


function bulbon(){

shell_exec("/usr/local/bin/gpio -g write 18 0");
usleep(250000);
shell_exec("/usr/local/bin/gpio -g write 18 1");
WriteName();
WriteDate();
}

function bulboff(){

shell_exec("/usr/local/bin/gpio -g write 18 0");
usleep(250000);
shell_exec("/usr/local/bin/gpio -g write 18 1");
usleep(250000);
shell_exec("/usr/local/bin/gpio -g write 18 0");
usleep(250000);
shell_exec("/usr/local/bin/gpio -g write 18 1");
WriteName();
WriteDate();
}

switch($name) {
case 'OFF':
bulboff();
break;
case 'ON':
bulbon();
break;
}
?>


log in to your pi using WinScp and put this file into var/www/ directory.
type the ip that you assigned in your browser and control the AC :)

if you want to control it from outside your house just forward port 80 and use  NOIP service





Friday, April 20, 2012

I was able to receive the following images from NOAA 19 satellite. the frequency is 137.100 Mhz.
and you can use WxtoImg software to decode the pictures.


Monday, March 12, 2012

Control your old fan.....From a SONY tv remote

It's really nice when you have the control of your fan in your hands....specially in a cold morning..that you do not like to getup form the bed. I will post the details of the schematic later. but its nothing much just replace your regular fan switch with 2/3 relays.
give the relay control to the Arduino board. I have connected 2 relays to the pins 5 and 7 of the Arduino board. and pin 4 for a buzzer. attach the IR sensor head to Pin 11
include IRremote library with the code
*************** source code for Arduino *******************************

// example 32.2 - IR receiver code translator
// for Sony IR codes (ignores 2nd and 3rd signal repeat)
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com

#include <IRremote.h> // use the library for IR
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;

void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
pinMode(4, OUTPUT); // beeper
pinMode(5, OUTPUT); // speed 1
pinMode(7, OUTPUT); // speed 2
}

void translateIR()
// takes action based on IR code received
// describing Sony IR codes on LCD module
{
switch(results.value)
{
//case 0x37EE: Serial.println(" Favourite "); break;
//case 0xA90: Serial.println(" Power button "); break;
//case 0x290: Serial.println(" mute ");
// Serial.println(" mute hi ");
// beep();

//break;
case 0x52E9: Serial.println(" one ");
speed1();
beep();
break;
case 0x32E9: Serial.println(" two ");
speed2();
beep();
break;
case 0x12E9: Serial.println(" three ");
off();
break;
//case 0xC10: Serial.println(" four "); break;
//case 0x210: Serial.println(" five "); break;
//case 0xA10: Serial.println(" six "); break;
//case 0x610: Serial.println(" seven "); break;
//case 0xE10: Serial.println(" eight "); break;
//case 0x110: Serial.println(" nine "); break;
//case 0x910: Serial.println(" zero "); break;
//case 0x490: Serial.println(" volume up "); break;
//case 0xC90: Serial.println(" volume down "); break;
//case 0x90: Serial.println(" channel up "); break;
//case 0x890: Serial.println(" channel down "); break;
default: Serial.println(" other button ");
}
delay(500);

}

void beep()
{
digitalWrite (4, HIGH);
delay (50);
digitalWrite (4, LOW);
}

void speed1()
{
digitalWrite (7, LOW);
digitalWrite (5, HIGH);
}
void speed2()
{
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
}

void off()
{
digitalWrite (5, LOW);
digitalWrite (7, LOW);
}

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
for (int z=0; z<2; z++) // ignore 2nd and 3rd signal repeat
{
irrecv.resume(); // receive the next value
}
}
}

******************************************************************************








Thursday, March 1, 2012

Controlling your Scanner over the Internet

if you want to control your scanner over the internet & if it doesn't have any serial port to control, then this is for you.
Things you need
1. one Arduino board (for the Ethernet Shield)
2. one Ardino board for the scanner interface
3. IIS server running on Windows 7 with PHP
4. PHP interface
5  Port forwarding knowledge
6. Audio streaming server 

we have to use some sort of power saving to control the PC running the servers. and we should be able to boot up the PC remotely. that's why we have to use  one Arduino with Ethernet shield for this purpose.

first we have to install the IIS server in windows 7 with PHP.

First of all, you need PHP (obviously). Go to the PHP download page and grab the latest non-thread-safe ZIP archive for Windows. As of writing this, the package is called "PHP 5.2.8 Non-thread-safe zip package". Unzip the archive to a folder on your hard disk (I use C:\php5) and create a copy of php.ini-recommended (or php.ini-production in recent PHP versions) called php.ini. There, add the following configuration setting:

cgi.force_redirect = 0

This is the minimum setting you need to change to make PHP work with IIS. You may also want to use cgi.fix_pathinfo = 1, fastcgi.impersonate = 1, and set extension_dir appropriately.

Then it's time to install IIS. You need at least the "Business" version of Windows 7, but the currently available beta 1 is Windows 7 Ultimate anyway. Go to Start/Control Panel/Programs/Turn Windows Features on or off and check on the Internet Information Services entry. Activate the World Wide Web Services/Application Development Features/CGI node and also Web Management Tools/IIS Management Console (the latter not shown in the figure).
Now, start the IIS Management Console; just open up the start menu, enter inetmgr and hit Enter. There, navigate to the Sites/Default Web Site/Handler Mappings node and double-click on the "Handler Mappings" entry.

As a result of this, the Actions panel on the right hand side changes. You now see an option called Add Module Mapping. Clicking on it opens up a dialog which you fill out as you can see in the following figure (you may need to adapt the path used to your local system).

If you do not see the FastCgiModule entry, you probably forgot to check the CGI node when installing IIS. Otherwise, close the Add Module Mapping dialog by clicking on OK. You need to confirm that you want to create a FastCGI application; click Yes.




Finally, create a .php script and put it in the root folder of the IIS site (by default C:\Inetpub\wwwroot; note that you may need additional rights to write into that directory), e.g. phpinfo.php with a simple phpinfo() call in it. Call this script using http://localhost/phpinfo.php, and you are done!

Put following code in phpinfo.php file


and finally since you are going to control this over the internet you need to bind your PHP web page with the port that you are going to forward. to do that go to controlpanel<<administrative tools<<IIS manager. on the left pane expand site and click bindings on right pane.Enter the port and IP of  the PC you are forwarding


To be Continued............

Wednesday, February 15, 2012

Spying on cordless phones


Most of the people in my neighborhood still using pretty old stuff. its very easy to capture the audio if you tune into one of these frequencies.

46.610 MHz
46.630 MHz
46.670 MHz
46.710 MHz
46.730 MHz
46.770 MHz
46.830 MHz
46.870 MHz
46.930 MHz
46.970 MHz

Thursday, February 2, 2012

Tuesday, January 31, 2012

streaming your scanner

i was trying to find a way to stream my scanner audio feed for 2 days. finally found a simple way.

  • first forward your port of the router (use the ip of the pc that you are running the media server on)
  • download broadwave audio streaming software
  • select the line in and connect your scanner
it's better to assign a domain name by using  http://www.no-ip.com/ so that they will track your ip.

here is no ip settings. port number is the port used by broadwave software
                               
snapshot of  broadwave software
                            
click here to listen