Friday, June 5, 2015

Home Automation with a Raspberry Pi, IFTTT, and an Air Purifier

Finding the right air purifier

I wanted to get an air purifier since my Hello Sense sleep tracker would tell me that the air quality in my room was not the greatest. I also didn't want an air purifier that I would have to remember to turn on and turn off throughout the night. I began searching online for what "smart" air purifiers existed, and the only one I found was the Holmes Smart WeMo air purifier. Not only was it a bit expensive at $200, but I was not particularly fond of the way it looked.

My next thought was to get any standard air purifier and use a WeMo Switch to power the air purifier on or off. But after doing a bit of research, it seems most air purifiers will not turn back on automatically or remember your settings when powered.

Finally I concluded that my best bet was to get an air purifier that can be remote controlled, and then use an IR blaster to control it. After searching and comparing models, I ended up buying the Hoover Air Purifier 600 for $120. It was big enough to handle my room, uses HEPA filters, automatic fan speed, includes a remote control, and has good Amazon reviews.

Building the IR blaster

So now I had the air purifier. Next I needed a way of controlling it. Abandoned in a drawer somewhere I had a Rapsberry Pi (RPi), which is essentally just a small computer powered by smartphone-level components. With just a bit of googling, you can find tons of documentation on making your own IR blaster. Since I was too lazy to buy specific components, and I did not want to leave the setup on a breadboard, I bought this IR LED Kit from SparkFun.

One mistake I did was solder the IR diode right onto the board. If I could go back I would make it long enough so that I can bend it in different directions. After soldering the IR Kit together, I soldered a wire from the VCC pad to the 3v3 pin on the RPi. Another wire from the CTL pad to GPIO pin 22. And then the last wire from the GND pad to any GND pin. The following image will help show the pin layout:

Setting up LIRC

After hooking everything up, the hardware part was done. All that is left is the software. I installed Raspbian as the OS for my RPi. We will use LIRC in order to interface with the blaster. You can download it with the following shell command:

sudo apt-get install lirc

Next we will edit the file /boot/config.txt and add in the following line at the very end:


I used my HP MCE Tranceiver in order to record the control keys from the air purifier. The configuration below should be placed in /etc/lirc/lircd.conf :

# To find out how to get a proper configuration file please read:
# /usr/share/doc/lirc/README.Debian
begin remote
  name  hoover
  bits           16
  eps            30
  aeps          100
  header       9434  4662
  one           600  1773
  zero          600   606
  ptrail        586
  repeat       9402  2341
  pre_data_bits   16
  pre_data       0x42BD
  gap          111626
  toggle_bit_mask 0x0
      begin codes
          KEY_POWER                0x50AF
          KEY_SPEED                0x10EF
          KEY_TIME                 0xB04F
          KEY_T                    0x42BD609F
      end codes
end remote

The file /etc/lirc/hardware.conf should look like so:

# /etc/lirc/hardware.conf 
# Arguments which will be used when launching lircd 

#Don't start lircmd even if there seems to be a good config file #START_LIRCMD=false 

#Don't start irexec, even if a good config file seems to exist. 

#Try to load appropriate kernel modules LOAD_MODULES=true 
# Run "lircd --driver=help" for a list of supported drivers. 
# usually /dev/lirc0 is the correct setting for systems using udev 

#MODULES="lirc_dev mceusb" 

# Default configuration files for your hardware if any 

Make sure lirc is started with sudo service lirc start. You can test to see if it works by using a digital camera pointing at the IR diode and notice it blinks with the command irsend SEND_ONCE hoover "KEY_POWER". Note that your cellphone camera may NOT capture the IR blinking. My iPhone 6 did not.

Not working?

To debug the diode not blinking, enter the following shell commands in order to permanently turn the pin on which should keep the IR diode visible:

# Enable pin 22
echo "22" > /sys/class/gpio/export
# Set direction to out
echo "out" > /sys/class/gpio/gpio22/direction
# Set value to one
echo "1" > /sys/class/gpio/gpio22/value

If it is still not on, I would use a multimeter to check that 3.3V is reaching the board. Use the AC mode of the multimeter to check the voltage spiking when sending commands to the CTL pin. Also, you can short the VCC and CTL pins together to turn on the diode and verify you soldered the board correctly. If it still does not work, check that you put the diode in the right direction and the transistor is inserted correctly.

Bash script with Dropbox

After having the hardware working and configured on the Raspberry Pi, we now need to create a script that can be run every 5 minutes with a cron job. This script will scan a Dropbox directory for a file that will tell it to either turn on or off.

There is a Dropbox script called Dropbox Uploader available on Github thanks to Andrea Fabrizi. Download the file in your /opt directory:

sudo wget -O /opt/dropbox

Next you will download the script I created in the /opt directory as well, available on my Github. With your /opt directory having both files, remember to make them executable with the chmod +x FILE_NAME command. When you first execute the script sh /opt/dropbox it will run through the steps you need to connect it to your Dropbox account. I decided to make a directory called Home_Automation in my home directory /home/pi/ that will by used for syncing. You can edit my script to change the directory name and what the files will be called.

My script can be called with on or off as arguments to control the air purifier. If you do not pass any arguments to it, it will look for the files called air_purifier_on.txt or air_purifier_off.txt to also turn the air purifier on or off respectively inside the directory called Home_Automation. My script also turns off the UV light and sets the fan speed to automatic. I turn off the UV light because the bright blue LED on top to show the UV light is powered happens to bother me while I sleep. You can remove that line from my script if you wish. I mapped the UV control key to KEY_T.

Now we will set the cron job to run my script every 5 minutes with the command crontab -e and the following two lines:


*/5 * * * * cd /home/pi && sh /opt/ >> /var/log/automation.log 2>&1

The first line sets the PATH to /opt so that our scripts can be found. The second line moves you to the home directory /home/pi, then it executes my script which will first call the Dropbox script to sync the Home_Automation folder and then check to see if the unique files are in there before deleting them. Then it transfer any text output to the file /var/log/automation.log

Dropbox with IFTTT

In order to automate the air purifier, I will be using Dropbox along with IFTTT. IFTTT will create a file in a specific folder within Dropbox at times you wish, and then the RPi script will continuously sync with this Dropbox folder looking for unique files.

If you have not heard of IFTTT, it stands for "IF This Then That", which allows the communication of different kinds of home automation products. I created one recipe to create the file air_purifier_on at 10:00pm, and then a file called air_purifier_off at 7:30am inside the Dropbox directory /Apps/RaspberryPi_dp/Home_Automation. This is assuming when you ran the Dropbox script for the first time, and followed the instructions, you set it to use its own app directory called Home_Automation.

And that was it! Now my Hoover air purifier automatically turns on and off. It looks kind of hacky, but it is hiding underneath my bed with direct line of sight to the air purifier in front of my bed. If you want to make it even cleaner, you can buy an IR repeater and sneak the long wired IR diode to anywhere you want. Just make sure it points directly to the front of the air purifier.


So I kept getting this anxiety that I might be sitting on the side of my bed blocking the IR blaster and the air purifier would not turn on. I had an IR repeater that was broken, so I decided to rip the diode cable and just solder it onto where the current diode is on the board (in parallel). Then I placed the diode in the corner of my bed discretely and I am much happier with its professional look compared to a circuit board taped to the side of my bed.

I also created a php file on my web server that I can call in order to toggle the air purifier. The code is pretty simple: 


$pass = $_GET['pass'];

if($pass != 'my_super_secret_pass') {
} else {
  $output=shell_exec("ssh pi@ '/opt/ on'");
  echo "<script>window.close();</script>";


All this does is grab the password from the address argument. If it is correct, it will ssh into my RPi and execute my script to turn the air purifier on and then close the page window/tab. If the password is wrong, it will redirect you to Google. The reason for the SSH part is because my web server is on a different machine from my RPi. In order to make the SSH smooth, I also made sure to transfer my RSA keys. If you are hosting your web server on the RPi as well, you can remove the SSH part.

Next I have Launcher which I use to have shortcuts on my Notification Center. I added a new Web Launcher which would go to and use the Hoover logo. Now I can easily press a button on my iPhone or iPad to turn on the air purifier if I need to. And just in case, I made my script send KEY_TIME once in order to place a one hour timer by default since I cannot know if the air purifier is on by accident.


  1. I am using logitech harmony hub to have same solution as yours. a bit more expansive (not much if you buy second hand one), but easier for end user like me. just need to teach the harmony hub and trigger via ifttt

    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training


  2. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

    Home Automation in Chennai
    smart home in Chennai
    Home security in Chennai
    Burglar alarm in Chennai
    Door sensors Chennai

  3. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. cancello scorrevole fai da te

  4. Coway AP-1512HH Air Purifier. Similarly as with most air purifiers, the Coway AP-1512HH is structured with the particular motivation behind disposing of allergens a coway ap-1512hh filter

  5. Nowadays it is really important to get connected with clients and keep them in their touch. Moreover, providing proper information on time to increase brand value. Mobile texting service USA may help your business to engage with your clients by sending texts.

  6. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Best air purifier under 10,000 rupees in India

  7. the Commission did highlight that ozone also enters into human dwellings from outdoor air, the so-called ambient air. This may elevate the actual ozone concentration above 50 ppb when an air purifier is being operated. Strangely again, there is no legislation in the US Consumer Safety Products Act about the 50 ppb ozone limit. best air purifier under 20000

  8. Thanks for the valuable information and insights you have so provided here.

    192.168 l 254

  9. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. cheap sandblaster

  10. One of the top wellbeing concerns incorporates indoor air contaminations. Utilizing an entire house air purifier is one approach to address the issue of indoor air poisons.air filter

  11. These electrical home appliances have formed the mainstay of our lives and it would not be out of place that our lives revolve around these home appliances since they tend to help us in our daily chores thereby saving both time and energy.Washer Repair in Los Angeles

  12. Find out about air purifiers and locate a protected, compelling unit that is directly for your needs with this air purifier purchasing guide. dehumidifier price in india

  13. Another significant factor to think about when performing upkeep on your air conditioner is cleaning or potentially supplanting air channels.Airco installatie

  14. Our services are available in all cities of Minneapolis and its surroundings. We are having years of experience which enabled our customers and clients to trust our services. best washing machine in India

  15. It is additionally a decent advance to take when you face an issues with your AC repair, you don't depend entirely on specialist, rather you put your push to look through the tips and ask anybody master right now handle this sort of issue without anyone else. Airco Limburg

  16. Very interesting and informative post, thanks for your hard work and keep going. Compare air purifier rates, specifications, review and ratings.

  17. This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! Air Conditioner Installation Toronto

  18. I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. automazioni per cancelli scorrevoli

  19. Great survey, I'm sure you're getting a great response. Best HVAC Oshawa

  20. Window units. Great for small room spaces. They come in different unit sizes according to the size of your room. Air Conditioner Installation Toronto

  21. Central air. This type of HVAC can be expensive but in the long run it's the favorite for overall temperature regulation and comfort level. Many potential home buyers will want this feature, so it's also a great investment. They are also very energy efficient. Air Conditioner Installation Toronto

  22. Not a single second went without leaving me in utter surprise.
    visual automation testing

  23. This blog had a to a great degree solid effect on me.
    hjc helmets

  24. I will invite all my friends to your blog, you really got a great blog.~-;*” Air Purifiers

  25. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. electronic air cleaner

  26. Volatile Organic Compounds (VOCs) are found in a wide variety of common household products: paints, varnishes, cleaning supplies, disinfectants, glues and adhesives, and even new carpet and building supplies. home air purifier

  27. I got a Hoover Air Purifier 600 for only $100 and it is a good deal in my opinion. What model of Raspberry Pi did you used on this project? Get the latest updates and guides of this casual running game on official website subway surfers! Also check gacha life pc by lunime.

  28. Have you been thinking about a room air conditioner rather than a focal air conditioner yet aren't sure what you ought to be searching for? manutenção de ar condicionado

  29. This also calls for attention to the matter that you have to take good care of the air conditioner and undertake periodic maintenance, so that your machine continues to work in the best condition for a long time.

  30. The higher the BTU of an air conditioner, the more powerful it is at cooling. But it also increases the cost of the air conditioner. Normally, hvac replacement boise the BTU of an air conditioner required for cooling a room is calculated by multiplying the square foot area of the room by 35.

  31. Looking great work dear, I really appreciate to you on this quality work. Nice post. we also provide Air purifier for large room USA. for more information visit our website.

  32. very good work friend i like this post.

  33. Know what is digital marketing in hindi, and digital marketing meaning in hindi
    here. Read complete blog for more details. digital marketing hindi

  34. Get to know trp meaning, trp meaning in hindi, trp full form and many others terms about trp
    here. trp full form

  35. This will guarantee exact temperature control and working cycle. Airco

  36. Thank you so much for this amazing blog, really great blog. Visit Ogen Infosystem, here you will get creative website designing and website development services in Delhi at an affordable price and also get digital marketing service in Noida.
    Best Website Designing Company in India

  37. If you are looking for the best b2b data companies then we are providing you the best database or business directory.

  38. Thank you so much for this article and for sharing the information.
    Nice article.

  39. Thank you so much for this article and for sharing the information.
    Nice article.
    best smart tv in india

  40. Enjoy delicious cakes and grilling recipes. Buy best microwave ovens and save money. Must read review

  41. Very informative article. Here is some information on

    Best AC in India

  42. simple, educative and informative article thanks publisher for sharing this wonderful article i have bookmarked this.
    Best high back gaming chair

  43. I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. 안전놀이터

  44. Get affordable and faster webhosting on hostgator via hostgator coupon code india. Register now to get faster webpage loading.

  45. Great article with detailed information. I'll definietly share this article with my friend. Cheers!!

    Best Kitchen Chimney In India

  46. Great article. Keep posting such kind of info on your
    site. I'm really impressed by your site.
    Hey there, You have performed an excellent job.
    I will certainly digg it and in my view suggest to my friends.
    I am confident they’ll be benefited from this website.


  47. Really informative and educative article thanks publisher for sharing this wonderful info with us i have shared this article on my blog Best window ac under 25000 and whatsaup

  48. I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site. Read my article: Main Ratan Panel chart

    Baccarat vivant, noir, orge, nouvelle expérience.

  50. Greetings! Very helpful advice in this particular post! It is the little changes which will make the largest changes. Thanks a lot for sharing!

    Click here to chceck my blog :: 오피사이트

  51. really informative and educative article thanks publisher for sharing this wonderful information with us i have bookmakred this blog for future post
    gossip mouth

  52. Very good written article. It will be supportive to anyone who utilizes it, including me. Keep doing what you are doing ? can’r wait to read more posts.
    very nice article. 카지노사이트

  53. This is an informative blog. If you are Looking for Plumber that will improve your Home. Feel free to visit Wills Plumbing Adelaide to know more about our services.

  54. One thing is one of the most widespread incentives for using your card is a cash-back or maybe rebate supply. Generally, you will get 1-5 back on various expenditures. Depending on the cards, you may get 1 again on most purchases, and 5 back on acquisitions made in convenience stores, gasoline stations, grocery stores along with ‘member merchants’.


  55. Your article has answered the question I was wondering about! I would like to write a thesis on this subject, but I would like you to give your opinion once :D카지노슬롯

  56. My programmer is trying to convince me to move to .net from 토토사이트. I have always disliked the idea because of the expenses. But he's tryiong none the less.

  57. Extremely decent blog and articles. I am realy extremely glad to visit your blog. Presently I am discovered which I really need. I check your blog regular and attempt to take in something from your blog. Much obliged to you and sitting tight for your new post.메이저사이트모음

  58. I accidentally searched and visited your site. I still saw several posts during my visit, but the text was neat and readable. I will quote this post and post it on my blog. Would you like to visit my blog later? keonha cai

  59. While looking for articles on these topics, I came across this article on the site here. As I read your article, I felt like an expert in this field. I have several articles on these topics posted on my site. Could you please visit my homepage? 토토사이트모음

  60. It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that. 메이저토토사이트

  61. I came to this site with the introduction of a friend around me and I was very impressed when I found your writing. I'll come back often after bookmarking! casino trực tuyến

  62. Este blog é muito informativo Estou feliz em postar minha opinião neste blog. Acabou sendo muito útil para mim e tenho certeza para todos os comentaristas aqui! Este é um bom artigo. Estou feliz por ter encontrado este ótimo site. Obrigado ao time.
    Boa leitura!! Eu definitivamente amei cada parte disso e também
    Eu marquei o blog para verificar o que há de novo. Aqui está meu site. Visite meu site e envie-nos seus comentários. ajude meu site 카지노사이트

  63. Looking at this article, I miss the time when I didn't wear a mask. 오공슬롯 Hopefully this corona will end soon. My blog is a blog that mainly posts pictures of daily life before Corona and landscapes at that time. If you want to remember that time again, please visit us.

  64. Hey there
    Nice post, Thanks for sharing

    Try - Zinzo - Online Grocery Shopping app to get groceries at lowest prices


  65. Birbal is a cloud-based video interview software. The key feature of this tool is that it merges with AI to provide predictive analytics. This lets you get the true sense of a candidates.

    video interview platform
    video interview software

  66. I’m thinking some of my readers might find a bit of this interesting. Do you mind if I post a clip from this and link back? Thanks 먹튀검증

  67. I have always disliked the idea because of the costs. Is usually able to answer customer questions.


  68. hire react developer to develop intuitive, performance-optimized, and conversion-generating apps that will be the pioneers in the market.

  69. Since there is a lot of good information, I will visit this blog often and read. I hope your business thrives. 토토사이트

  70. I m surprised to hear such an amazing article. I ll visit often. Thank you always. 먹튀보증업체

  71. It’s really a great and helpful piece of info. I’m glad that you shared this helpful info with us. Please keep us up 안전한놀이터

  72. I read this post completely about the comparison of hottest and previous technologies, it’s remarkable article. 보증업체

  73. Playing world777 fantasy cricket games can help you focus on something other than your negative thoughts. Concentrate on putting your cricket knowledge to good use in order to assemble the finest team possible!


  74. Launch your NFT Marketplace and attract millions of NFT enthusiasts and artists to put their NFTs on display with our White Label NFT Platform. With over 5+ years of experience in Whitelabel NFT Marketplace Development, we help you develop a customizable platform that enables easy and secure NFT trading. Hence, our White Label NFT Marketplace Development Company guarantees to provide you with a platform through which creators can easily transfer their assets into NFTs, collect and transfer them without any arbitrators in absolute transparency.
    nft ideas
    White label nft marketplace
    White label nft marketplace development


  75. Thank you for your post, I look for such an article for a long time, today I find it finally. this post gives me lots of advice it is very useful for me.
    Serumswap Clone Software

  76. Your Blog is very nice.
    Wish to see much more like this. Thanks for sharing your information!!!!
    Wazirx Clone App

  77. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up. You might also like coin stars near me

  78. I was looking for another article by chance and found your article 룰렛 I am writing on this topic, so I think it will help a lot. I leave my blog address below. Please visit once.

  79. Great Article, it is really informative and innovative. app to check bvn details

  80. Thanks for sharing helpful blog.
    Our Intelligent Video Analytics Solutions use artificial intelligence and machine learning to identify and remove particles in the video, identify each object using a professional Deep Convolutional Neural network, and classify each object for innovative surveillance analysis, such as search and filtration notifying, and aggregation of data and visualization.

  81. I see the article has a great deal of investment in content and science. I took the time to read them and found them quite interesting. You can check out adidas product tester

  82. Take your web & mobile app development to the next level with our high-quality, low-cost services!react agency

  83. It's the same topic, but I was surprised that it was so different from my opinion. I hope you feel the same after seeing the writings I have written. 안전놀이터

  84. I’m very pleased to discover this site. I want to to thank you for ones time for this particularly wonderful read!! I definitely savored every part of it and i also have you saved as a favorite to see new information on your blog. 메이저토토사이트

  85. The future is cross-chain and you can do that now a token bridge. A cross-chain bridge let's you launch your token on multiple blockchains and allow users send your tokens between chains. Launch your token on any EVM blockchain with our cross-chain bridge.
    Build a cross chain bridge

  86. Build futuristic and human-centric apps to increase user retention and conversion at the most affordable price with CronJ's react js development services!

  87. Why should you employ ReactJS engineers from a reputable firm? Learn the answer and why it's critical to choose wisely for a positive development experience!
    hire react developer

  88. I was impressed by your writing. Your writing is impressive. I want to write like you.스포츠토토사이트 I hope you can read my post and let me know what to modify. My writing is in I would like you to visit my blog.

  89. BlockchainX's expert developers have answers for you with state of the art Erc20 token generator. Give your Dapps the power of ethereum erc20 token development company based and integrate secured crypto payment systems.

  90. Interior decorating has grown 11% in the last five years and will continue to grow as more people are working outside the home and acquiring more money. If you are constantly being asked for your interior design ideas, this could be an incredible opportunity for you. All you need to do is make a few decisions and love to create beautiful home interiors. home decor accessories

  91. Great article. your blog is easily understandable and give complete information. thank you for sharing information.
    Web Development