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.
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
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.
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.