NetBot? IRC controlled air freshner

The idea struck me when my wife always complained about the house stinking when she got off of work. Well, my geek side kicked in and I can freshen the house from any computer connected to the internet via IRC (internet chat relay).

NOTE: I know the circuitry is bad; and the op amp isn’t needed. I wanted to use what I had lying around. The only thing I’m concerned with is that it works.

The complete build took me about 5 hours, and the code took 20min.

Figure 1-1

Figure 1-1

I went to the local walmart and bought a $7 Glade Sense and Spray. (Figure 1-1)

The next step was to rip it apart and find the pins for the push button that triggered it to spray. The pin needed is labeled R18 or R29 something like that. (Figure 1-2)

Figure 1-2

Figure 1-2

Next build a circuit to read an arduino pin and trigger it to spray. I used a relay to “close” the circuit/ act as the push button for the Glade’s circuit board. The relay is powered with a NPN transistor that was suposed to read the HIGH value from the arduino, but the value wasn’t a high enough voltage to trigger the NPN; I used an Op Amp to increase the voltage from the arduino to trigger the NPN to power the relay to turn the Glade…Spray on. Wow, that was a mouth full… It is a simple circuit.

EDIT::: The op amp isn’t needed. I found out I had the transistor and relay set up wrong thanks to BenF from the arduino forum:::(Figure 1-3)

Figure 1-3

Figure 1-3

Now for the code. First the Arduino Sketch. I’m using an ArduinoBT board.

int buffByte = 0;
int cntrlPin = 13;
void setup() {
    Serial.begin(115200); //BT requires baud 115200
    pinMode(cntrlPin, OUTPUT);
    digitalWrite(cntrlPin, LOW);
}

void loop() {
    if (Serial.available() > 0) {
        buffByte = Serial.read();
        //ASCII 65 is equal to "A"
        if (buffByte == 65) {
            digitalWrite(cntrlPin, HIGH);
            delay(100);
            digitalWrite(cntrlPin, LOW);
        }
    }
}

Now for the IRC bot. Written in Python 2.6 I’m not going to explain what goes on here, its pretty self explainotory

import serial, socket, time, string, os
os.system("color 0a")

#My bluetooth COM port for the Arduino is COM9
#found in device manager
s = serial.Serial('COM9', baudrate=115200)

chan = 'BotTestz'
ircsite = 'irc.freenode.net'
port = 6667

irc = socket.socket()
irc.connect((ircsite, port))
print irc.recv(1024)
n = 'NetBotV1'
irc.send('NICK %s\r\n' % n)
irc.send("USER Ohlook itsnotmy blahh :Realname\r\n")
time.sleep(4)
irc.send("JOIN #%s\r\n" % chan)

readbuffer = ''
while True:
    readbuffer = irc.recv(1024)
    temp = string.split(readbuffer, "\n")
    Check = readbuffer.split(":")
    print readbuffer

    #if pinged, respond with PONG
    if "PING" in readbuffer:
        irc.send("PONG :%s" % Check[1])

    #Write ASCII char 65 to the COM port
    #if smellGood command was sent
    if "^smellGood" in readbuffer:
        s.write("A")
About these ads

About Tech B.

I am currently employed as a tech support rep for Frontier DSL internet and Dail-Up service. If you live on the East Coast and have Frontier or the old Verizon, you may have spoken with me at one point. I do side jobs programming and building things for people. I know Python better than any language in my toolbox. I can also develop Android Apps, which are Java based. Other languages include C , VB/VB.NET, some C#, PBASIC, Batch, Javascript, and some PHP. I love microcontrollers and interfacing with the outside world. I am currently working with Arduinos, which are amazing. Also I can work with the Basic Stamp family of microcontrollers; future development includes FPGA and embedded Linux. I was going to school, but have financial issues at the moment that are keeping me from the books. I plan on going back in the next couple semesters and finishing up my Associates in IT, then perusing a BS in computer science.
This entry was posted in Uncategorized. Bookmark the permalink.

23 Responses to NetBot? IRC controlled air freshner

  1. Opa & Grandma says:

    We don’t understand a word you have written, but we are very proud and fascinated with your results. Keep up the good work. You have certainly found your future.
    Stay in touch

    • Jeremy Cook says:

      Lol, well at least they can use the internet. I’m guessing your family is Greek?

      Anyway, I’ve used air fresheners for all kinds of stuff and am learning Python, so nice hack! Really was trying to figure out if there is a way to bypass the 30 min lockout without using an Arduino etc…

      • Tech B. says:

        Greek? Where did you get that idea lol?

        Yeah, just patch into the “spray” button and you can use the Arduino to “press” it. Set up your own timing system or do like I did and connect it to an IRC channel lol.

  2. Pingback: Air freshener hacking - Hack a Day

  3. Pingback: Air freshener hacking | Video Game News, reviews, and information.

  4. john says:

    awesome keep up the great work….you made hackaday!

  5. vcarte says:

    love that you care about what i am complaining about. lol. didn’t expect you to do anything about it. you have such awesome ways of solving problems and having fun doing it. love you!!!

  6. Joel says:

    very nice build. Add a web cam and you have a instant ambush. Although they can be dangerous all on there own, http://joelchrisman.blogspot.com/2010/07/killer-air-freshener_07.html

  7. Kapace says:

    Really cool! Its amazing what you can accomplish with an Arduino, Python and some magic!

  8. Jonathan says:

    haha, cool. I did something similar a couple months back, creating a scent-based eXtreme Feedback Device for Continuous Integration builds. At least YOU got around to posting about it. :)

  9. JD says:

    Keep it up man… it will all payoff one day…

  10. Dave says:

    Very cool work and awesome that your family is loving what you’re doing. Thanks for sharing–cheers!

  11. blech says:

    that guy is right… just add a webcam and replace the spary with the spray used by police force… :))

    excuse my bad english :D

  12. gary says:

    any idea how to over ride the motion based controls on the Glade Sense & Spray Motion Sensor?thanks

    • Tech B. says:

      The simplest way would be to cover the IR LEDs with some electrical tape or paint them directly to prevent them from working. Then the only way to trigger it is either push the button or the patched wire I use for the trigger.

  13. There are remote controlled air fresheners on the market. I imagine that you could hook up one of these remote controls to your iPhone or something to remotely control the air freshening in your house, much like you can control your security system with some apps. I suppose someone will read this comment and make a million dollars.

    That said, I applaud your effort. This is awesome.

  14. Pingback: Scent-based Build Status Indicator « 3amPhoneCall

  15. michael says:

    please can someone help me with any material or writeup i can use to write on a some work on the topic “software in the implementation of indoor air freshening” thanks alot..

  16. Pingback: Hacking glade sensor spray | insideout_blog

  17. Pingback: portfolio 2011 » Week 1: Pavlov’s Dog

  18. Greg says:

    I am in desperate need of bypassing the lockout feature this air freshener has that only allows it to spray by motion detect for 30 minutes, Its for a Halloween project I’m making. Do you know how I could do this? Is there any way to email you? Thanks

    • Tech B. says:

      I haven’t worked with the air-freshner in a while now, and honestly don’t know where it is at this point. If I knew what you where trying to do, I might be able to help you come up with another way of doing it?

  19. It’s a pity you don’t have a donate button! I’d definitely donate to this excellent blog! I guess for now i’ll settle
    for book-marking and adding your RSS feed to my Google account.
    I look forward to new updates and will talk about
    this site with my Facebook group. Talk soon!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s