kellenvmfd
Posts: 2
Joined: Wed Jan 04, 2017 8:20 am

Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 8:37 am

Hi guys, I'm new to this forum and pretty new to Raspberry Pi. I'm working on a project for a self-driving snowplow competition. In short, I have two posts controlling servos, each with a raspberry pi on them. The servos will have the picamera mounted on them, and using OpenCV, the servo will track the plow, keeping the plow in the center of the frame. The important information I need is the angle of the servo from each camera post. This angle will need to be sent to a 3rd raspberry pi on the snowplow itself, and these angles will be used to determine the position of the plow (law of cosines). On the snowplow, the raspberry pi will also be running OpenCV to do some obstacle detection.

I'm very new at all this. New to Python, new to OpenCV, new to Raspberry Pi. I am using Raspberry Pi 3 model Bs.

Here are my questions:

1: Is it possible to send data from two separate raspberry pis (an angle) to a 3rd raspberry pi with Wifi? OpenCV uses Python, so I need this to be done in Python (I think!)
2: If question one is possible, how long would the delay be?
3: Can I do all this stuff on the Raspberry Pi in the same program?! Currently, I just have OpenCV tracking a ball. Can I also get it to control a servo and send data wirelessly all in the same program?
4: I'll need all this to run without a display. Can I get it to all run at startup and get everything connected properly?

That's all my questions for now - my apologies if this is in the wrong spot on the forums.

Thank you!

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 2:37 pm

What data are you planning to send?

Mosquitto/MQTT is a reliable way to establish one-to-one, one-to-many, many-to-one and many-to-many comms. There's a well supported Eclipse/Paho python library for MQTT.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 4:33 pm

1: Is it possible to send data from two separate raspberry pis (an angle) to a 3rd raspberry pi with Wifi? OpenCV uses Python, so I need this to be done in Python (I think!)
2: If question one is possible, how long would the delay be?
3: Can I do all this stuff on the Raspberry Pi in the same program?! Currently, I just have OpenCV tracking a ball. Can I also get it to control a servo and send data wirelessly all in the same program?
4: I'll need all this to run without a display. Can I get it to all run at startup and get everything connected properly?
A1.
You could configure one RPi as a wireless hotspot/access-point and have the other 2, as wireless clients, connect to it. Once you have a WiFi connection you can use standard network tools to communicate over it. There are many python libraries that implement standard TCP protocols. @Dougie has given an example. I think WiFi signals only travel in straight lines.

A2.
Try it and see in your own working environment. Very short: tiny fractions of a second.

A3.
It is possible. Whether you can do it depends on your abilities and resilience.

A4.
Yes. (But it makes finding out what went wrong very difficult if you have no form of display or interaction.)

kellenvmfd
Posts: 2
Joined: Wed Jan 04, 2017 8:20 am

Re: Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 6:41 pm

DougieLawson wrote:What data are you planning to send?

Mosquitto/MQTT is a reliable way to establish one-to-one, one-to-many, many-to-one and many-to-many comms. There's a well supported Eclipse/Paho python library for MQTT.
I will look into this. The data I plan on sending is just a number - an angle. Specifically the angle of the servo I'm controlling. Should just be an integer. I will look into Mosquitto/MQTT. Thank you!
B.Goode wrote:
1: Is it possible to send data from two separate raspberry pis (an angle) to a 3rd raspberry pi with Wifi? OpenCV uses Python, so I need this to be done in Python (I think!)
2: If question one is possible, how long would the delay be?
3: Can I do all this stuff on the Raspberry Pi in the same program?! Currently, I just have OpenCV tracking a ball. Can I also get it to control a servo and send data wirelessly all in the same program?
4: I'll need all this to run without a display. Can I get it to all run at startup and get everything connected properly?
A1.
You could configure one RPi as a wireless hotspot/access-point and have the other 2, as wireless clients, connect to it. Once you have a WiFi connection you can use standard network tools to communicate over it. There are many python libraries that implement standard TCP protocols. @Dougie has given an example. I think WiFi signals only travel in straight lines.

A2.
Try it and see in your own working environment. Very short: tiny fractions of a second.

A3.
It is possible. Whether you can do it depends on your abilities and resilience.

A4.
Yes. (But it makes finding out what went wrong very difficult if you have no form of display or interaction.)
Thanks for this - I think the hardest part for me will be figuring out all about TCP protocols. I'll check out Dougie's example for sure. And it'll be short range, line-of-sight connections, so signal strength should not be an issue. The lack of a delay is good - I wasn't expecting that honestly! Thanks for the feedback, I really appreciate it.

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 7:19 pm

MQTT runs at layer5, so you don't have to worry about layer4, layer3 or layer2 comms.
http://www.tcpipguide.com/free/t_SessionLayerLayer5.htm

There's no socket programming needed, the library functions do all of that stuff for you.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: Connecting 3 Raspberry Pis with Wifi

Wed Jan 04, 2017 10:03 pm

Pi Wifi is 2.4 GHz, the same as microwave ovens etc. The communication might work in your test environment then fail intermittently in a competition among dozens of other more powerful Wifi devices. Should not be a problem out in an open field away from the other machines. Some Wifi devices can switch to 5 GHz because that is a cleaner bandwidth.

Return to “Beginners”