chris_
Posts: 2
Joined: Thu Mar 27, 2014 3:59 pm

Help for beginner

Thu Mar 27, 2014 4:28 pm

Hi There,

I'm a new to the whole Raspberry Pi scene and discovered them primarily whilst looking for a way to stream media from my nas drive to my TV over the network. I use the RASPBMC which works amazingly well. Having now played with the Raspberry PI I can't help but want more!

I've been toying with a project for a few months prior to thinking of using a Raspberry PI to assist but this would be the perfect starting point to complete one of my projects with something I assume won't be too complicated.

Here is what I'm trying to achieve:

I simply want two raspberry pi's to be able to talk to each other over the network and the input from one PI to be detected on the other. I basically want one raspberry pi to have a switch connected to it when I then press the button the the other raspberry pi relays the button command.

I'm trying to build a wireless handbrake peripheral to my racing simulator. So when I pull the handbrake and the contacts meet it will relay the connection to another raspberry pi that will be soldered to the 'B' button on my Thrustmaster TX racing wheel therefor allowing me to simulate a realistic handbrake rather than pressing a button whilst playing the game.

I need a list of hardware as I assume I'd need some additional hardware to the PI and also what programming language I'd require and if someone could set me on the right path to learning it that would be great.

Thanks a bunch.

Chris

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Help for beginner

Thu Mar 27, 2014 10:16 pm

It's certainly possible, and there are a half dozen ways at least to accomplish this. you have more questions to answer:
How do you want the two RasPis to communicate? HTTP POST procedure? SSH remote command? Raw sockets? Something else?

You can program it in any language you like. C, Python, Javascript, a shell script, or just about anything else you like.

The switch part will be easy. Enable the internal pull-up resistor on a GPIO pin, and wire the handbrake switch between it and a ground pin, so that pressing the switch connects the GPIO to ground. Your program will then check the pin periodically (10 or 20 times per second is probably sufficient) and act on it.

chris_
Posts: 2
Joined: Thu Mar 27, 2014 3:59 pm

Re: Help for beginner

Fri Mar 28, 2014 9:44 am

Thanks for your reply. In response as to how do I want the two RasPi's to communicate I'm not really sure at this stage. I'm happy to take suggestions as to the most reliable source. My long term goal for the project is to have two led lights coming off of both of the Pi's one red and one green. When the two Pi's are able to talk to each other the network the led goes green. Until then it remains red. I guess this would be done via a constant ping and have both of the Pi's on static IP's?

My programming experience is next to nothing so I honestly have no idea as to the best way to have the Pi's communicate. All I know is the way I envisage it working is having an Ethernet cable running from a switch to both of the Pi's so there will be no cabling from Pi to Pi and all communication is to be done via the network.


Thanks for your help.
Chris

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Help for beginner

Fri Mar 28, 2014 1:36 pm

chris_ wrote:Thanks for your reply. In response as to how do I want the two RasPi's to communicate I'm not really sure at this stage. I'm happy to take suggestions as to the most reliable source. My long term goal for the project is to have two led lights coming off of both of the Pi's one red and one green. When the two Pi's are able to talk to each other the network the led goes green. Until then it remains red. I guess this would be done via a constant ping and have both of the Pi's on static IP's?

My programming experience is next to nothing so I honestly have no idea as to the best way to have the Pi's communicate. All I know is the way I envisage it working is having an Ethernet cable running from a switch to both of the Pi's so there will be no cabling from Pi to Pi and all communication is to be done via the network.


Thanks for your help.
Chris
For something like that, you might want to establish an SSH session between the two. Have a program on one open up an SSH client to log into the other one and execute a program on the other to listen to commands passed to it. Then when the handbrake is pulled, pass an "on" command, and when it's released pass an "off" command. A similar but simpler method would be to forego the listening program entirely (and thereby lose the status lights) and simply pass the gpio command directly through SSH, either through an established and static connection, or by passing the command at the SSH "command line."

Return to “Beginners”