OK. I'm glad I've got the remote thing figured out on paper at least. Now that I look into the Arduino side of the project things change.
There are so many different boards, I dont know which to choose or what makes them unique or different.
What I'm trying to impliment/need
Arduino Board
Ethernet Shield
X10 Controller wired directly to the Arduino via one of the many ways I have read to do that.
Optional relays for other misc outputs I could want someday.
RF for Ceiling Fan provided by factory remote OR relay board if I have to.
RF for garage door provided by 315mhz module (is this called a shield as well?) (what I don't know with regards to the FM module, is if it will be powerful enough to reach my gate from where I physically place the Arduino. I was going to use my old Cat5/phone cables and install a separate transmitters near the gate and connect it to the Arduino.)
What do I need to buy to start playing with this and make sure I have the expandability/correct flavor of Arduino?[/list]
Well, since you are starting out not completely understanding the full scope, start with an Arduino Mega2560 which will have the most peripherals and IO. Once you nail it down, you can go with a smaller arduino for the final application. Or, in the reverse, start with an Uno and work on implementing one feature at a time and perfect your control methodology and then move on to the next. At that point, you will fully understand your requirements. If you are like me, you are going to be working on one feature at a time with alot of experimenting to get each one to work properly. For me, at least, trying to jump right in from the big picture and do everything at once gets confusing especially when you don't understand what 'everything' is. Break your project down into its individual bits and pieces and get each on working as you want first, then how to tie it all together will be much clearer.
If you use cat5 cable to place your remote at a distance, you will need a differential driver. Digital signals do not do well over distance. That's really not a big deal though. You just connect a driver such as a MAX491 for example on one end to convert your single-ended signal into a differential signal, and another on the other end to convert the differential signal into a single-ended one. (Trust me, that isn't as complicated as I just made it sound.) If the positions of the arduino and gate receiver are relatively fixed, you can also investigate uni-directional antennas such as a yagi which you point directly at the receiver. Of course that only works if you have unobstructed line-of-sight.
By the way, you can use the differential driver to do anything over long distances, such as having an actuator some distance from the controller. I suspect that for home automation, you will be using them alot. It will save you alot of headaches trying to troubleshoot something that worked on the bench, but didn't work when installed if you go into it knowing that. LVDS is another term for this. Again, it is not as complicated as it sounds. The ICs do all the work for you and you just focus on the digital signals.
Here is a page that explains differential driving without appearing more complex than it really is:
Typically the datasheets make these things look intimidating, but they aren't really. The most important thing is to match your impedence on either side. A cat5 cable is designed for 100ohm impedence. On the differential transmission side, you split this as 50 ohm for each line. At the receive side, you place a 100 ohm resistor across the pair. You drive one twisted pair for each differential signal. D is the data you want to send, and R is the data you want to receive.
I could then put these in/near my small home (I'm betting they will be in range) and wire to my gates/gerage door and control them with one 315mhz transmitter on the Arduino. It would just depend on which code it broadcasts, right? Just want to conform I'm on the right track before I start buying stuff.
Its either that or I play with the remote relays that are on different channels, but I think different code would be better/more reliable. Wouldn't I need a bunch of different channel transmitters if I had different channel remote relays?
The "transmitter" should just be thought of as a wire. What you put into it, comes out of the receiver. That's all. The channels, house codes, and all the rest of that comes from the encoder on these remotes. But, since you are using the arduino, YOU are the encoder and have complete control over all of that. So, no... you would use only one 315Mhz module for all 315Mhz remotes, one 350MHz module for all 350Mhz remotes, etc... Your code handles the channels, housecodes, etc...
The rfswitch library I link you to handles all of that. You send whatever you want over the RF module.
There is nothing locking the actual radio module to specific channels, etc... all of that is done in the encoder. Check out the datasheets for a PT2262 attached. Nearly all of these remotes use this or some clone of this.
Ohh. Thank you. That means that rotating codes could be a possibility if I learned how to use that IC to it's potential?
Can I play with the transmitters with just a computer for the moment, or do I need the Arduino right now too? I've got multiple computers with serial ports. What I cant seem to find is the equivalent of the library or an app that can tell the transmitter what to do. Windows, Linux. I dont care.
Incredible! Possibilities are limited only by ones imagination and programming abilities.
I was under the impression that channel was a slight change in frequency? I read the RC-Switch manual and missed that part.
I am not aware of any software on the computer that allows you to play with these modules. If you are handy with visual basic, you could progran something, I'm sure. But easier to just create a sketch, include that RF-Switch library, connect the data line to one of your pins on the arduino, and play with the examples included in that library. I just noticed that it is missing a nice example for setting commands from the serial port. I could write an example up for you, but I am probably not going to have time to do it this weekend. It would be useful to me in future project as well, so I will do it as soon as I have the time. In the meantime, I suggest just playing around with it.
You won't be using that encoder IC, but the datasheet helps explain how the protocol works. The RC-Switch library is meant to emulate that IC.
OK. I found a 350mhz Serial RF transmitter in a remote I had for the lights. I De-soldered it from the button board and it's free to use. It has three pins. VCC, GND, SIGnal. I've got an Arduino Uno, loaded the IDE, and can blink some LEDs.
Where do I go from here?
I imagine what I need to do is hook the button side of the remote to the Arduino and capture a couple codes so I know what to transmit with the transmitter. THEN hook the transmitter up and try transmitting.
How do I do that? Where do I go? I need some direction. Thanks!
Take the line on the remote that was original connected to the signal pin on the module. Connect that line into your arduino and use the RCSwitch library example to read the codes when you push a button. You can remove it when done.
After you have all the codes, you connect the signal pin on your module to the Arduino, power it, send those codes you figured out using the RCswitch library.
There are examples in there that you can use to get the codes and to play with sending them.
I loaded the library and opened the receive simple example to play with. When I uploaded the program the L LED remains solid. I get no response from anything.
If I revert back to the blinking LED program the L LED will blink indicating all is well along with my LED that I plugged in.
The LED doesn't always blink. Do you have the module wired up already? If so, the library is meant to output to the serial port. So, you have to open the Serial Monitor in Arduino.
Yeah I know I have to have serial monitor open. I though a little program together that would write hello world 100 times then stop, and it worked. So I know that serial monitor is working.
At this point I think I'd like to somehow test that pin 2 can read anything with RCSwitch receive running.
ok, so you are using the RCswitch library with no modifications and have the data pin of the module connected to pin 2 on the Arduino?
You could connect an LED to this as well that will flicker when data is being received by the module. To check this with the Arduino, try a little sketch like this:
oh, and make sure that you have the ground on the transmitter connected to the ground on the arduino. Otherwise, a high or low may not be valid voltage levels.
I am using the example code with no modifications. I did play around with pins other than pin 0 (pin 2) just for fun.
If I run this code (which I found online)
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}
I see just
0
0
0
0
0
0
many times.
then when I hook up the remote and press a button I do see it change, like
1
0
1
1
1
0
I suspect that's because it is generally not a good idea to do a serial print in the middle of an interrupt. So, the pin is working and the interrupt is working. Try my code with the remote connected. It is similar to the code you already tried, but uses an interrupt instead. It may freeze up, but if you get some stuff flowing, at least you know the remote is able to trigger an interrupt.