4

I have managed to get two pi 3 to connect to each other through Ethernet port. Now, I want to know if I can do the same with WIFI or do I need to do anything special to have 2 PIs talking to each other over WIFI. These PIs are not going to be part of a LAN or any Network. They are only going to talk to each other through WIFI. I have looked at the other questions and I am not sure if they are asking the same thing as I am.

  • 2
    It is a bit more complicated as you have to set one up as an access point and create a subnet that the second pi will connect to (the last part is much the same as with ethernet). The usual way to do that is with hostapd, which takes some reading ;) You may instead be able to do this ad hoc but I believe that is still more complicated and not necessary for this. – goldilocks Mar 29 '17 at 14:55
  • I second what @goldilocks wrote. It works very well when you set up an access point specifically for the Pi network. If properly subnetted to your main LAN they can also have Internet access for software updates etc. And your Pis can all talk to each other. In my case I also added WiFi adapters to my PCs on the main LAN so they can also have access to piNet, so I can use remote desktop and FileZilla with them. – SDsolar Mar 29 '17 at 19:53
2

Thank you for posting comments and replies. I have found the working solution and manage to get my PIs talking to each other through WIFI ad-hoc connection as follows.

=Make sure to backup /etc/network/interfaces like sudo cp /etc/network/interfaces /etc/network/interfaces-orig

=Then, edit the file sudo nano /etc/network/interfaces

=Make sure you have the following in the interfaces file and everything else commented out. Side note: don't include the comment with arrow and dashes <-- I added that to point out what you should do and not do.

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
 address 192.168.1.2    <--You can choose your own address
 netmask 255.255.255.0  <--This needs to be exactly as you see it.
 wireless-channel 1     <--You can choose your own channel. I think it's range is 1-13
 wireless-essid rpinet  <--You can name essid whatever you want.
 wireless-mode ad-hoc   <--This needs to be exactly as you see it.

=As I said in the last step, make sure to comment out everything else. Then, save your new interface file.

=Then, you need to stop or disable dhcp service. This is an important step or your ad-hoc connection may not work. Stop service like so sudo systemctl stop dhcpcd.service

=Lastly, reboot your PIs. At boot, it should establish ad-hoc connection automatically.

=Once it boots up, all the PIs should say wlan0: associated with YOUR-ESSID and you should be able to PING your other PI(s). :)

VERY IMPORTANT NOTE

All those PIs you want to communicate through ad-hoc connection MUST have EXACTLY the same settings except for their IP addresses in their interfaces file or it won't work.

That is all.

0

It is a bit more complicated as you have to set one up as an access point and create a subnet that the second pi will connect to (the last part is much the same as with ethernet). The usual way to do that is with hostapd, which takes some reading ;) You may instead be able to do this ad hoc but I believe that is still more complicated and not necessary for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.