Friday 8 April 2011

The Arduino Doorbell - Part 2 Software!

Firstly, here is the final Arduino code that I am using, its as best to perfect as I can get at present with only one real hiccup.

int ledPin = 13; // LED connected to digital pin 13
int potPin = 0; // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 1000;

void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600); // open serial port at 9600 baud
digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
// (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
val = analogRead(potPin);
if (val < 200) { // if the circuit is completed
// (for me, it generally drops from 1023 to ~ 15 when 'ringing')
if (millis()-time > debounce) {
Serial.println("ON");
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // ...wait for 2 seconds
digitalWrite(ledPin, LOW); // and turns the LED off
time = millis();
}
}
}

I cannot take credit for this code please see this post http://rooreynolds.com/2008/05/14/hacking-the-doorbell/ for the original code, I have just modified aspects to suit my needs.

What this will do is when the button is pushed, it will light the test LED and send the "ON" text via the arduino to your pc's com port.



Now the hardest part! I have yet to find anyone who has done this hardware setup with a windows machine and wanting to use growl/prowl, the closest I could find was this post http://www.grantgibson.co.uk/blog/index.php/2009/03/29/putting-doorbell-online/as this guy is using a windows machine but is using a web function as a notification.

So now I have a base to use in ActivePerl as my listen and trigger code, now I wanted to run the command C:\Program Files\Growl for Windows\Growlnotify "There is someone at the door" as a dos command instead of the 'http://your action here' command.

Here is my Perl code:

use Win32::SerialPort;
use LWP::Simple;
my $port = Win32::SerialPort->new ("COM3");
$port->databits(8);
$port->baudrate(19200);
$port->parity("none");
$port->stopbits(1);

my $count = 0;

while (1) {
my $char = $port->lookfor();

if ($char) {
$char = substr $char, 0, 2;
print " Doorbell status: " . $char . " \n";
if ($char eq "ON") {
print "Doorbell is on \n";
system 'C:\growlnotify "There is someone at the Door"';
}
}
sleep(1);
}

Note: I have removed the bottom part of Grant's code as it wasnt needed for this application, then I changed the http line, to the system command, however this is the first time consuming problem, the command will not run from a folder that has a space in the name i.e Program Files therefore I had to copy the growlnotify.exe to the root directory and run it directly from C:\.

The text following the growlnotify command can be changed to anything you wish.

Note 2: Dont try and run the perl code with the arduino software open, as you will get an error as the com port is in use by the arduino software.

Note 3: Perl when installed doesnt tell you this but you need to reboot the machine in order to set the path variable to enable perl to run directly from any command line, test by using the command c:\perl -v this should return details about the perl version, if it doesnt you will need to do some troubleshooting.

Then all that needs doing is to set up growl and prowl, this will involve buying the prowl app, setting an API key, and modifing your growl settings all of which are fairly easy and there is plenty of info on the web.

That should be about it, set your hardware up, flash with code, set up perl, run perl doorbell.pl from your command line and push the button!



69 comments:

  1. led deck lights very nice blog you have written dear author i like your blog about led technology so carry on dear for further improvement

    ReplyDelete
  2. train horn Horns have a great importance on rail road crossings and railway station. Most of the train horns work similarly which basically the horn is oscillating, and create sound wave. very nice blog i have found here to read and to get information about horns so i would like to thank you for sharing it with us

    ReplyDelete
  3. Sean
    Any chance you wold be willing to make on of these for me? I'm willing to pay for the service and parts

    ReplyDelete
  4. Thanks for sharing. I don't have any experience with perl ,but maybe it's time to learn :)

    reading your elaborated post, I have but one question:
    will the growl/prowl solution work over the web as well, or only in the homegroup network?

    Thanks :-)

    ReplyDelete
    Replies
    1. I am replying to my own question in order to let the other interested readers that it actually does work over the internet, which is great!

      Thanks :)

      Delete
  5. These look great shining up from my handrails up stairs. Great subdued light effects

    ReplyDelete
  6. I agree with you that doorbell is good for our security purpose. Thanks for sharing this great post.

    Reliable Chimes

    ReplyDelete
  7. This is a amazing inspiring composition.I am gorgeous plenty pleased among your salubrious process.You put truly really cooperative info.limo rental Jersey City

    ReplyDelete
  8. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.70s Costumes

    ReplyDelete
  9. The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface.onlinegevonden.com

    ReplyDelete
  10. The only exception is that we unfortunately have had to hold on to some related source code that uses proprietary code from 3-partys. However none of thus are essential, and binaries are made freely available for most of it. A list of non-released code is available at.recreation.tips

    ReplyDelete
  11. Once in Los Angeles he studied beneath the fabulous Stella Adler plus mood mime Jeff Corey. Hellos initial acting vacancy was active beside Steven Spielberg as the Pizza Human in E.T. Stretch in LA he continued to thing on TV moreover Movie. Today, he houses in Roseland Recent Jersey, acting besides filmmaking in the tri-commonwealth locale.Drug Possession Attorney West Palm Beach

    ReplyDelete
  12. Once I thought about things like: why such information is for free here? Because when you write a book then at least on selling a book you get a percentage. Thankfree prepaid credit cards

    ReplyDelete
  13. Higher efficiency means less energy consumption. Less energy consumption means lower costs and less pollution.native american drums

    ReplyDelete
  14. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.goose feathers

    ReplyDelete
  15. exactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very welexactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very wel exactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very welexactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very wel exactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very welexactly traditional; they include items like Asian-style vegetables and peanut sauce, but such crazy-quilt combos all somehow work very welred bow tie

    ReplyDelete
  16. I don't want to make this personal, but this is a thread so deeply flawed that it should be censored. But male enhancement products , you say? That might be a bit too much. Clear? I can recommend some wonderful English Comprehension courses that would help you.red bow tie

    ReplyDelete
  17. No any life in this world which would be safe from the period of declination in his life as every person in this world have to face some bitter experience in his life but the best one is the one who seeks positive lesson from his problems.compare conveyancing

    ReplyDelete
  18. Its like you read my mind! You seem to know so much about this,like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is great blog thisschwimmbadüberdachungen

    ReplyDelete
  19. The next time I read a blog, I hope that it doesn’t disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought you would have something interesting to say.conveyance fee

    ReplyDelete
  20. I read your excellent post. I really appreciate your post. Thanks a lot for share this interesting post.Honeymoon

    ReplyDelete
  21. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.Compare Money Transfer

    ReplyDelete
  22. That was bit funny conversation. I could get an interesting topic to read through this article. Thanks for the share about the scrambled eggs.penis enhancement spells

    ReplyDelete
  23. This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog.lawveritas.com

    ReplyDelete
  24. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.Janitorial cleaning companies

    ReplyDelete
  25. There are some factors that you will need to know before you start taking any penis enlargement pills. When you are taking the pill, you will need to ensure that you drink plenty of water.professional cleaning services

    ReplyDelete
  26. I’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people.web room booking

    ReplyDelete
  27. Its like you read my mind! You seem to know so much about this,like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is great blog this.escort paris

    ReplyDelete
  28. Traveling is not just about fun and looking for a moment will never be forgotten. But more to learn thank favors God has given us.Lipo battery

    ReplyDelete
  29. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to meconference room scheduling software

    ReplyDelete
  30. That's what makes you the best. You should keep publishing more articles and you will Such Become One of the best writers ever.Ryanair

    ReplyDelete
  31. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future.mortgage broker edmonton

    ReplyDelete
  32. I would say that when you allowed posting about a gold ira companies ,this means you have a great sense of gold ira investment especially through a gold and silver ira.calgary mortgage broker

    ReplyDelete
  33. he structure of every research paper is almost identical to an essay, but has more sections: cover, table of contents, abstract, introduction, body, conclusion. Click this structure of the research report to find more information!mortgage broker licence ontario

    ReplyDelete
  34. I'd like to thanks for that initiatives you get on paper this short article. My spouse and i look forward to more of your amazing blogs. for more info click here full swing

    ReplyDelete
  35. I cannot find it anywhere, and in case of affirmative case, I wonder how much faster could the iPhone charge and if that faster charging (even if not much) could not slowly damage the battery at lonf term. What is your view?custom tshirts

    ReplyDelete
  36. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. ring doorbell pro review

    ReplyDelete
  37. article published quite interesting to read & add new value to me airtel data plans

    ReplyDelete
  38. There are some factors that you will need to know before you start taking any penis enlargement pills. When you are taking the pill, you will need to ensure that you drink plenty of water.جي تي ار

    ReplyDelete
  39. Where I realized that parents are fallible, and that anger and stubbornness aren’t necessarily “faults” - that our anger and stubbornness can protect us and serve a purpose.Can you tell me how i remove slowly this.vintage clothes

    ReplyDelete
  40. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future.Retro clothes

    ReplyDelete
  41. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.oshawa real estate

    ReplyDelete
  42. Although I would be thrilled to take the first tour you described, it would be worth the trip to see the Mt. Desert gardens alone. If I could get away, I would definitely attend. Perhaps there will be another time.iphone batteries

    ReplyDelete
  43. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity.locksmiths dublin

    ReplyDelete
  44. Gurgaon divas have most beautiful,attractive and highly educated call girls. she gives 100% satisfactions with best service. Their hot & sexy young females across the city who are 24 hours ready to serve their erotic services for you!.Contact us for Call Girl in Gurgaon.peoria riverfront events

    ReplyDelete
  45. Gurgaon divas have most beautiful,attractive and highly educated call girls. she gives 100% satisfactions with best service. Their hot & sexy young females across the city who are 24 hours ready to serve their erotic services for you!.Contact us for Call Girl in Gurgaon.toronto real estate listings

    ReplyDelete
  46. This is just a single example of these bonus games. Titles such as Power Blackjack also offer gamers the option to gain generous awards. Land-based online semiautomatic casinos do not normally offer casino players these types of choices.a shop that sells it for $9/sq foot!!

    ReplyDelete
  47. Love this post! Cooking eggs always seems easy but it’s not as easy as it sounds. Maybe you could share your tips on perfect scrambled eggs.cement tile

    ReplyDelete
  48. Thank you for this great information, you write very well which i like very much. I am really impressed by your post.black and white tile

    ReplyDelete
  49. They hear directly from the market about pain points and needs, and they often have the relationships necessary to get buy twitter followers your message through when an impersonal public post or email would get lost in a sea of online activity.Wholesale hats

    ReplyDelete
  50. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.Handbags wholesale

    ReplyDelete
  51. They hear directly from the market about pain points and needs, and they often have the relationships necessary to get buy twitter followers your message through when an impersonal public post or email would get lost in a sea of online activity.hotels near lake como italy

    ReplyDelete
  52. I had something similar happen to me, we we're going into Dragon Soul with the guild, and after the first boss I notice I had tanked with my haunted herring all this time. No wonder I had problems keeping aggro! rent house panama

    ReplyDelete
  53. It is critical for you to know every one of the progressions to spare cash while renegotiating at less expensive financing costs. Before couple of years, individuals used to acknowledge the rates bear the cost of by the merchants because of lesser alternatives and were compelled to proceed with the same high rate till the end of the advance term.Murcia

    ReplyDelete
  54. This is just a single example of these bonus games. Titles such as Power Blackjack also offer gamers the option to gain generous awards. Land-based online semiautomatic casinos do not normally offer casino players these types of choices.pest control in new jersey

    ReplyDelete
  55. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.click here

    ReplyDelete
  56. Shen Tong is a sequential entrepreneur, writer/poet, angel investor, social activist, foodie, and a film buff. Being one of Newsweek’s People of the Year in 1989, Shen Tong was born in 1968, in Beijing.
    Shen Tong
    Shen Tong
    Shen Tong
    Shen Tong
    Shen Tong
    Shen Tong
    Shen Tong
    Shen Tong

    ReplyDelete
  57. I think this is an okay article. You make this data intriguing and locks in. You give perusers a considerable measure to consider and I value that sort of composing.
    Costa del Sol

    ReplyDelete


  58. I think this is an informative post and it is very useful and knowledgeable. Therefore, I would like to thank you for the efforts you have made in writing this article.minneapolis web developer

    ReplyDelete
  59. Gone are the old days when a knock at the door would be enough to alert homeowners about the presence of a visitor. The Liztek wireless doorbell comes in to save the day. This device is a convenient doorbell choice. With a range of up to 1000 feet, you are assured not to miss a single visitor. It's hassle-free as you just need to plug it into a power outlet and it begins to function.

    ReplyDelete
  60. Hello, Livewebtutors aims at providing the students with a one stop solution for all the academic related issues. The company has Livewebtutors is an online Assignment Help and assignment writing service offering expert assignment help. Hire Australian assignment writing expert.
    Workout clothing

    ReplyDelete

  61. Benefit utilizing your facts, the optimal recognized by themselves excellent. Benefit yet again designed relevant to delivering people personal unique personal computer system facts.
    Workout clothing

    ReplyDelete
  62. Benefit utilizing your facts, the optimal recognized by themselves excellent. Benefit yet again designed relevant to delivering people personal unique personal computer system facts.Social Media Management

    ReplyDelete
  63. Livewebtutors aims at providing the students with a one stop solution for all the academic related issues. The company has Livewebtutors is an online Assignment Help and assignment writing service offering expert assignment help. Hire Australian assignment writing expert.
    Social Media Management

    ReplyDelete
  64. 24*7 mobile truck repair in Atlanta.. Premium Truck and Trailer Repair LLC all the truck repair, trailer repair, services in Conley, Atlanta. Premium Truck and Trailer Repair LLC offers high quality and cost effective truck and trailer repair services. Our professional truck repair near me can fix your heavy duty truck and trailer for hassle free travel.


    ReplyDelete