AD_pi_G4U
Posts: 4
Joined: Sun Jul 24, 2016 7:57 pm

Raspberry pi 3 Internal Wi-fi Connect In Ad-Hoc Mode

Sun Jul 24, 2016 9:02 pm

Usually the out of the box Rpi3 does not connect to the internet through its
internal Wi-Fi Module as it is un configured and the network/interfaces file is
unedited

This method provides an ease to connect the Rpi-3' internal wifi to connect to an
Access Point in range in Ad-hoc mode ,it has been tested and works well on my Rpi3
also works with Ad-Hoc n/w on a External Wifi Router or Hotspot Access Point Setup
via a mobile phone.

to do this i have used "iwconfig" command on terminal

Step 1:
From root terminal :
when rpi3 internal wifi is up & wifi Router is also up and in range

type "sudo iwlist wlan0 scan "

it will reveal normally:

wlan0 Scan completed :
Cell 01 - Address: xx:xx:xx:xx:xx:xx
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=36/70 Signal level=-74 dBm
Encryption key:off
ESSID:"YOUR WIFI ROUTER ESSID"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
11 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Ad-Hoc
Extra:tsf=0000000000000000
Extra: Last beacon: 23050ms ago
IE: Unknown: 000A353830305F5870726573
IE: Unknown: 010882840B0C12161824
IE: Unknown: 030101
IE: Unknown: 06020000
IE: Unknown: 32043048606C

"NOTE DOWN" or Copy the "cell id: XX:XX:XX:XX" this the AP used later
also note or copy ESSID"YOUR WIFI ROUTER ESSID"


Step 2:
Type in command line:

"iwconfig wlan0"

this will reveal the following:

wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Cell: Not-Associated Tx-Power=1496 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on

Here we check the values of: cell (AP),mode ,ESSID ..

To establish connection in Ad-Hoc Mode the the variables (Noted Above) should be configured

Step 3:
Make sure the Wifi Router or Access point or mobile wifi access point (Device broadcasting the web network) is active in range and configured in Ad-Hoc Mode.

type
$iwconfig wlan0 essid xxxxxx //"or your desired ESSID"
$iwconfig wlan0 mode Ad-Hoc //"default"
$iwconfig wlan0 ap XX:XX:XX:XX:XX //" AP mac address of router(taken from earlier)

Do "$iwconfig wlan0" again twice to check the data variable values have changed or not.

normally:

$iwconfig wlan0

wlan0 IEEE 802.11bgn ESSID:"5800_Xpres"
Mode:Ad-Hoc Frequency:2.412 GHz Cell: 5C:57:C8:45:18:68
Tx-Power=1496 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on



Finally :To Activate wifi connection type : " sudo dhclient wlan0" to connect
and : "dhclient -x" to STOP the dhclient process, and end the wif Ad-Hoc Mode connection.

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Raspberry pi 3 Internal Wi-fi Connect In Ad-Hoc Mode

Mon Jul 25, 2016 1:31 pm

Adhoc mode is designed for peer-to-peer communication, eg. Pi to Pi.
Setting an AP to adhoc mode (assuming it offers the option!) seems a bit contrived when you can get the Pi's wifi interface to connect in client mode by simply entering wifi network details in /etc/wpa_supplicant/wpa_supplicant.conf (or using the GUI)

I *think* there is even a way to drop the wifi config bit in the FAT (boot) partition, so that the Pi will connect on first boot.
[EDIT. Ah yes, on top of it, wrong section. Delete my post if you want, I can't do that myself anymore.]
Last edited by epoch1970 on Mon Jul 25, 2016 1:41 pm, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “General discussion”