Arduino Remote Home #2

in #arduino6 years ago

As promised, lets dive in.

If you have read from the first post you know I said that the garage door was the reason for my home automation project. I would like to clarify a bit. I bought the house in 2000 and each time I did work to it, I left provisions for, “some day”, but was never really motivated to actually go through with it . So the garage door incident was the reason I actually got off my lazy behind and DID something.

Through the process of prepping, planning and imagining what home automation was, I came up with the idea of what the system architecture should look like. By that I mean a mental list of wants.

First, I wanted to be able to control, every controllable item in the house, garage and yard. There are some things that didn’t make the cut. For instance, the garbage disposer. Electrified door lock hardware was never on the list of thing to consider. For me a key works just fine. There are plenty of IOT devices now but when I started, not so much. In fact, I wanted to use as few of these gadgets as possible.

I wanted to be able to know what the current state of any given light fixture or a switched outlet was. In the Arduino sketch, I use four arrays to do this. The first one is the” point [ ]” array. My way of differentiating between “kitchen light” and “kitchen ceiling fan”. The second, is the “relay [ ] “ array. For each point I wished to control, I had to have a relay. So the description is the same, ie; “kitchen light”. Next the “onoff [ ]” array. I use this to keep track of the “point” status, either On or Off. The final array “ hidden[ ]” keeps track of the status of the control relays condition, powered on or off.
Now some of you may be saying, “ you don’t need relays, you can just....”. To which I answer with a concept I have learned through my search results on how to make this thing work. That is, regardless of what ever your working on, hardware, software, or whatever, always choose the direction you are most comfortable with. That which you understand or with minimal effort will understand. It will always produce the best results for you. Don’t let anyone tell you, “your doing it wrong” or “you could do it this way”. Believe me, you will know when your doing it wrong. You will find a way to over come what ever it is that is giving you grief. The acronym K.I.S.S., “keep it simple soldier” comes to mind. Keeping in mind that what is simple to me, may not be simple to you. The important thing is, what is simple to you. In my case, simple meant relays. My code, both in the Arduino sketch and the web page also had to be simple. Having Arduino's iterate through the “ onoff” and “hidden” arrays, to collect the I/O states seamed simple to me.

I also wanted to do this for the least amount of money. I have been fortunate to have collected, as my wife would say, “ a bunch of junk”. In the photo of my control hub the most expensive things I chose to buy were the battery back-up and the Wemo. Well those, and the Arduino boards. As an accumulator of junk, I benefited it two ways. The best is, there is no giant outlay of cash to get started. And the other is, I worked on what I could, instead of waiting for enough money to get started.

The next want, the system had to be reliable. To put it another way, if I had been out when my neighbor called about the garage door, I needed to know that clicking on my “user interface” garage door button, that the door would in-fact receive the signal to close, just as if I was pushing the button myself.

Most important to me, coming from a background where nearly every system had a back-up system, I want my house to have a certain redundancy and be impermeable from individual component failures. Which, we all should agree, are inevitable, given enough time. So if some small component broke or even catastrophic failure occurred, the lights would still be operable from the wall switch.

And although physical space is at a premium, I want the system to be expandable. I always have a poker in the fire, for what is coming next.

I thought those wants were reasonable. But as I got going I made it a much harder task than it needed to be. One of the advantages of working in a facility is the variety of jobs and people. So one day I got to talking with an IT guy about how I was going to do all these cool things, but I needed to learn this and that, etc etc. He knew I was in way over my head by the questions I was asking. So he calmly said “Ken, sounds like your trying to boil the ocean”. All my life I had never heard that phrase. But in that moment I realized what he was saying was absolutely dead on.

This is how I got so messed up. My system was going to have an Uno in the garage that would connect to a Mega in the basement via Rs-485. By reading up I learned that the other communication options would not work because of cable length. Then my Ubuntu server would connect to the mega via USB. All the data would then update the MSQL database. Which would then be sent along with the requested web page hosted on the server. My thinking got steered that way for two main reasons. One, I thought I wanted to serve multiple pages, one for each section of the home automation system. (HAS) from now on. I plan on adding solar to the house and thought it best to keep it and a few other items separate. Second, I was fearful of running out of program space in my Arduino sketch. Looking back, that was a completely unfounded fear. I had no idea as to how much memory I would need. Turns out that the current fully functioning sketch uses less that 40 kb. Thats a little over 15%, so there is plenty of space for the future. Based on the fact that I’m more than half way to monitoring and controlling all the plugs and lights. There is one other reason I thought I needed to go that route and that is that the Apache server has some security things I would need. Turns out, that is also un-true. Not the Apache part, the I needed part.

Note on video: After watching that myself, I wish to oplogize for the most visually un- ntresting video of all time. I promise that will not happen again.

Next post I‘ll get into the technicals of how things are wired. Both high and low voltage sides.

Coin Marketplace

STEEM 0.19
TRX 0.12
JST 0.028
BTC 65160.59
ETH 3545.92
USDT 1.00
SBD 2.43