Saturday, December 25, 2010

Arduino Wireless Garage Door Opener

First off contain yourself, that is right Matt Emerson is posting a blog page... Doesn't happen often but I wanted to put this information out there to help anyone else who is trying to do something similar.

If you are interested in programming hardware check out Arduino

The entire idea behind this project was to have my garage door open wirelessly. So I have a transmitter and a reciever, and when the receiver gets a signal it simulates someone pushing the button by closing a relay, shorting the two wires to operate the garage door. (this garage door is OLD, I am talking REALLLY OLD!!!)

$25 - Nordic FOB
$20 - Nordic nRF24L01
$15 - RBBB (Ardunio Clone)
$4   - Sharp S101S02 Solid State Relay
$.50 - Misc. Transistor that came with Ardunio kit I bought.
$.20 - Misc. Resistor that came with Ardunio kit I bought.

    Random antennae that i had....
$65 - Just to prove that I could. Of course the Ardunio is capable of much more then I am using it for so I plan to expand it in the future, temperature, barometric pressure, and more reads... just haven't gotten to it yet.

 And now the code:

/* Pins:
 * Hardware SPI:
 * MISO -> 12
 * MOSI -> 11
 * SCK -> 13
 * Configurable:
 * CE -> 9
 * CSN -> 10
 byte data[4]; //set the data to be retreived from wireless module
 byte lastdata; // compare new data to last data
   //I am having a problem where the reciever keeps on reading "new" data in the form of a 'right' button press. but it is not new data, it is simply reading old
   // data over and over again... as evidence by the data[2] bit not changing... this data bit from the FOB is the number of button pushes since battery replacement
   // or at least it changes every button push, but does not change when faulty data is being read. So I store the last bit 2 and compare it to the new one, if
   // there is no change, toss the data out it is garbage.
 int timer = 0; // set the timer to prevent repeat button presses (bounce)
 int subtimer =0; // ser the subtimer to trigger the real timer (allows for reading of the buffer faster but only responding every so often to the fob presses)

void setup() {               
  pinMode(4, OUTPUT);  // This is the output connected to a transistor, connected to a solid state relay.
pinMode(2, OUTPUT);

  Mirf.csnPin = 10; //set the nordic CSN pin to 10
  Mirf.cePin = 9;   //ser the nordic CE  pin to 9
  Mirf.init();      //initialize the nordic

  byte rx_addr[5] = {0xE7, 0xE7, 0xE7, 0xE7, 0xE7};


  Mirf.configRegister(RF_SETUP, 0x07); //Data rate 1Mbit / 0dBm
  Mirf.configRegister(EN_AA, 0x00); //Disable auto acknowledge
  Mirf.payload = 4;  //bytes to be read = 2;  // channel used
//  Serial.begin(9600);     //used while developing
//   Serial.println("start"); //used while developing
   Mirf.flushRx();  // start with a clean buffer, I had issues without this occassionally.

void loop() {

        Mirf.getData(data);  // get data from the buffer
//        Serial.print(data[0]);  //used while developing
//        Serial.println(" ");
          if (data[2] != lastdata){  // check if the data[2] is the same as last time, if it is do nothing.... bad data
            lastdata = data[2];
              switch (data[0]) {
                    case 0x00:
                case 0x1D:
//                    Serial.println(timer); //used while developing up button
                case 0x1E:
//                    Serial.println("DOWN"); //used while developing
                case 0x17:
//                    Serial.println("LEFT"); //used while developing
                case 0x1B:
//                    Serial.println("RIGHT"); //used while developing
                case 0x0F:
//                    Serial.println("CENTER"); //used while developing
  // for ever 40 subtimer clicks, click one timer click
  // yes is is crude, yes it is wierd, yes I could have multiplied it out an done it with on timer
  // but you get a little crazy writing code some times....
  if (subtimer >=40) {
    timer = timer + 1; 
    subtimer = 0;   
  if (timer >= 100){ //don't allow timer to get greater then 100... if it gets too high will turn massivly negative
    timer =100;
  subtimer = subtimer + 1;
  // End of LOOP

void OpenDoor() {
  if (timer <= 34) { //If timer isn't ready yet, short pulse the LED, to at least let you know signal was recieved
      digitalWrite(2, HIGH); // This is used to light an LED on pin2 to make sure board is working
      timer = timer + 1;
      digitalWrite(2, LOW);    // This is used to light an LED on pin2 to make sure board is working
  if (timer >= 35) {  //time is ready and this will allow the garage door to operate
          timer = 0; //reset timers to allow for delay before next operation
                     // it will send multiple key presses for one physical press
          subtimer = 0;
//          Serial.println("start door");//used while developing
         digitalWrite(2, HIGH); //trigger LED on for long pulse to let you know signal recieved, door should be operating
          digitalWrite(4, HIGH); //trigger the transitor -> the solid state relay to closed (this simulates a button push of the garage door)
          digitalWrite(4, LOW); //turn off transistor after 2 second delay.
          digitalWrite(2, LOW); //turn off OPTIONAL LED for evauliting if board is working...
//          Serial.println("stop door");//used while developing

Please let me know if you see anything horribly wrong with my code or hardware, I am very much in unknown territory here.


Saturday, December 18, 2010

It is gearing up....

to be a busy week for me. I NEED to get Christmas gifts for my students. I've been putting it off, but maybe today after my tutoring session I'll brave the weather (it's raining :) and the Christmas shoppers and get a little something for them all.
This next week will definitely be a busy one for me. I've got one 1.5 hour session and two 2 hour sessions scheduled for Monday; three 2 hour sessions and one 1.5 hour session scheduled for Tuesday; one 30 minute, one 1.5 hour, and one 2 hour session for Wednesday; and one 1.5 hour and one 1 hour session on Thursday. Let's see...that's 19.5 hours in one week! And I might have a couple more hours to schedule, depending on what some of my students' plans are.

Well, I guess I should probably get ready for the day...I have already done my lesson plan for today. We're going to talk about African Elephants, Skateboarding, and the Food Pyramid. :) My student is interested in becoming healthier, so I thought we could talk about nutrition and ways to become more active. He's only in 2nd grade, so I hesitate to say he needs to "get into shape" but he thinks he does. Maybe I can help him shift his thoughts into making healthier eating choices and wanting to become more physically active. He definitely shouldn't be obsessed about the numbers on the scale, but if he could make some small changes now, he could be a healthier adult in the least, that's what I'm thinking.

Well, off to the shower for me. Oh, yeah. AND it has been 4 years since Matt and I got married. In some ways, it seems longer than that. In others, it feels like just yesterday. I remember my wedding day-it was a gorgeous December day in Virginia Beach, with the sun shining and about 60 degree weather. Couldn't have asked for a better day. And the ceremony and reception were perfect. Thanks, Matt, for deciding to spend your life with me. It has been one wild and crazy adventure, and I'm looking forward to the future with hope and anticipation. It is already so good, and I know it will only get better. I can't wait! Love you!!!


Monday, December 13, 2010

Oh the Weather Outside is...

oh, so very nice! :) It is so hard to believe that this is December, and Christmas is right around the corner. Looking at my sister's blog and the pictures of the snow makes me realize how much I'm enjoying the weather here! Matt's new work schedule has him working on Saturdays and having Sunday/Monday off. Except, for the last two Mondays, they've been doing special things at work and he's gone in to do things he wouldn't normally have an opportunity to do. So, Sunday was our weekend this week. We started out by priming some of the trim outside. Sitting up on the roof, just basking in the sunshine and looking up at the clear, blue sky...well, it was a little slice of heaven :) Then, we decided to go for a run down on the beach in Santa Monica. We ended up running from the pier, along the beach by the water, all the way to Muscle Beach in Venice. That was about 2 miles, then we walked back. My feet ended up being really sore. Big surprise, right? Especially since we were running in the sand. It was so nice, though. We had lunch in Brentwood, at a Fish Taco place. Yumm...grilled fish tacos...:)

On our way back, we decided to stop at our friends' the Masciale's house, and they were there! So were Vince's parents and sister, and we had a really nice visit. :) We headed home, and when we got here, it was dark. Jupiter was shining brightly, and I took some advice that I heard on the radio and got out the binoculars. I don't have a great pair, but I think I was able to see some of the Galilean moons of Jupiter. Of course, I was so shaky, it is hard to tell...

Well, that was our weekend. Matt got up early this morning to head to work, and I've been catching up on housework all day. I'm starting to make some headway, though :)

Well, back to it, I guess.

Oh yeah, I almost forgot. Look who I saw riding the Santa Monica Pier's Roller Coaster:

Santa sure looks like he's having fun! :)

Saturday, December 11, 2010

Two for Two

Ok, so I was going to post about Matt's birthday, and how successful I was at getting him the gifts he wanted, and post pictures of it. Then, I realized that that would be silly, since I only got pictures of him opening up the chocolate before my camera's battery died. So....I guess I will just tell you about his exciting gifts instead.

He really wanted an air compressor, so I got a great deal on a small one :) but what he really wanted was a hammer. Not just any hammer. A nice framing hammer with a nail starter on it. That's a little bit of magnet on the head, so you can lay the nail down, and start the nail without smashing your fingers. He's so in love with that thing. I'm glad I listened to him when he told me what he would like.

Oh, and I also got him a small rock tumbler. We always find cool rocks on our excursions, and the don't look nearly as good when we get them home. So, I thought the tumbler would be cool to polish them up a bit :) He's got some tumbling out in the garage as I write this.

I guess the most exciting news, at least for me, happened when I climbed on the scale this morning. I've been working out nearly consistently for about the past month, and it is FINALLY starting to pay off as far as numbers go. I've been noticing my energy level go up, as well as my clothes starting to fit better again. But, as I'm sure is true with most of us, the numbers on the scale hold a magical sway over me. My weight fluctuates, up a bit, down a bit, but for about a year now it hasn't gone below a certain number...Until this morning, that is!! I'm back, back again! Back to the 120's!!! Whew! I know that my journey is not over, has just begun. I don't want to obsess about my weight. I just want to be healthy, have tons of energy to do the things I want, and feel good about myself. I just think I could do all that and be the number on the scale I want as well, you know? I'm slowly making progress to my goal, which culminates with the trip to Belize in a month.

Wait a minute, a month? Man! I haven't even started getting ready for that! Shoot, better put another thing on my list of stuff to do :)

Well, let me get to it then. Cheerio!!!


I'll leave you with this image. On our hike a couple weeks ago, Matt and I stumbled across a truck that seemed to have a bit of trouble.  There was a tow line still attached, like they tried to pull it out. It's pretty well hidden, I must say. :) It's really rugged up there, I'm not sure how I would have felt about driving along the top of THAT mountain, and I've ridden across some pretty rugged country in my day!

Friday, December 10, 2010

I love it here

Ok, I won't lie. I've wanted to live in California since I was little. Ok, maybe more like since I was younger, like 14, when I came here with Marie and her kids. It was so nice and WARM in the summer, and so green! (That was up north near San Jose.) And, then we came down to San Diego to visit Aunt Stormy when I was 16 for Thanksgiving, and I was hooked. Did I ever admit it? No. Of course not. It is a pretty well-known fact how Idahoans are supposed to feel about California. All the Californians coming to Idaho are just ruining the state. There's no public land for you to do anything in California, you know. Everything is just private land, and no one will let you go on their property. They post "No Trespassing" signs everywhere. Right? Isn't that how it is??? Well, regardless, I've always wanted to live here. There must be SOME reason all these people want to live here, isn't there? Well, Matt and I have definitely gotten the opportunity to see some of the reasons why people love living here. And you know what? If you don't want to live here, fine! There's more than enough people, and that just means there's more for me to enjoy :)

Here's some reasons why I love it here:

Look! It's the Hollywood Sign! Matt and I went on a hike (that's right, a hike. On PUBLIC land. No "No Trespassing" signs in sight. They actually let you hike all over the mountains here. There's trails everywhere. And, yes, you have to share with other people. You won't be the only ones on the trail. But, honestly, who cares? My tax dollars are definitely put to good use here!)

Matt, overlooking the city of Los Angeles. Absolutely incredible. There's so many people living down there! :)

Ok, this picture was taken about 10 minutes from our house. We're looking down on the "Valley," the San Fernando Valley, that is. This is the valley where we live. That day, we actually hiked up high enough to see the ocean, which is behind that far ridge of mountains you see in the picture. Those are the Santa Monica Mountains; we are in the San Gabriel Mountains, part of the Angeles National Forest. All PUBLIC land, by the way :)

This is more of that hike. Gorgeous mountains, right outside our back door :)
 Ok, if you look really closely, you can se the ocean in this picture. It was a little foggy out on the water, but there's a little patch of it... :) we can actually see the ocean from close by our house! :) Oh, and a spectacular view of the San Fernando Valley, as well. What a gorgeous day, and a gorgeous hike!

Ok, this was  a different day, and up the coast a bit, at El Capitan State Beach. We went camping there in July with Matt's family. What, a State Beach? We don't have those in Idaho, that's for sure! The State Beach system in California is awesome! Matt and I are looking forward to riding our bicycles and staying at the campsites on the hiker/biker rate of a few bucks a night :) That will be  little bit in the future, tho. 

Gorgeous sunsets. I know, I know. We had these in Idaho, but I truly missed them in Virginia. It was hard to see the sunset for all the trees, and the flat land. You could go up on Mount Trashmore, I suppose....

Disneyland! We have Disneyland just about an hour away :) We've only been once, but I'm sure we'll go again. What fun! 
 And, last but not least, Palm trees. We definitely didn't have these growing up. And I must admit, the first one I ever saw was at a hotel Marie and I stayed at on our epic journey to CA when I was 14...and it scared me! It looked so foreign, and somehow sinister...ok, so it had been a long car ride, in that little Geo Metro with 3 kids, two bigger kids (I won't say adults.. hehehe) and only 4 seatbelts. I rode most of the way in the middle back with no seatbelt so Tansy would be protected...I guess I thought it would be ok for me to go flying through the windshield....

Anyways, that about it for my rant. I guess the moral of this story is...I love it here. I'm glad Matt got his job here and we were able to live my {secret} dream of living in California. Beautiful, sunny, southern California where it is slated to be 78 degrees on the 11th of December :) Can't wait for tomorrow. It's been a long time since I've felt like that every day. I think this place is good for my depression. Ok, I don't just think it is. I KNOW it is. (Didn't know I suffered from depression? Where have you been? :) Just kidding. Seriously, though, that was the reason I got out of the Navy early, depression. Evidently I suffer from cyclical bouts of depression, which have recurred throughout my life. My worst cycle happened while I was enlisted, and that shouldn't be a surprise. But I've had some minor cycles, even here. But, the extra sunshine in the winter is helping, and I'm looking forward to the Solstice when the days will start to get longer again. I've not been diagnosed with Seasonal Affective Disorder, but I suspect that the lack of sunshine in the winter contributes to my depression....anyways, what I'm trying to say is I'm feeling a lot better now than I have in a long time. Looking forward to the future. Not scared or anxious about what will happen next. It helps that we can literally go on a hike from our house up into the foothills of some amazing mountains, get some fresh air and exercise, and just feel good about things.

Well, guess I should quit stalling, get onto the next thing I need to do, which is exercise, then get ready to tutor 3 students this afternoon/evening. Thanks for listening (I mean reading) to my rant. :)


PS. So, I got my packages sent off for Christmas yesterday (cost me a lot more than I thought it would) and now I need to work on the presents for those a little closer to home. The ones I can deliver in person. Since there's still a couple weeks before Christmas, I have plenty of time. Plenty of time, I say! :P