Rasberry PI (RasPi) Zero WH turn to WiFi HotSpot
Actually my purpose is to connect a RasPi through WiFi network without a router. So I can access to the RasPi through a web browser (in a note PC or mobile) to manipulate it running a Python code. My RasPi become a WiFi Hotspot.
IMPORTANT: to avoid conflicts with connecting an existing WiFi setup such as a home network. Turn Wifi OFF. “No network connection” to start with. Which means you cannot remotely ssh to the RasPi. All configuration has to do with in the RasPi OS. Then access to the configured WiFi hotspot so you can ssh etc.
NOTE: It looks like you can set up “sudo raspi-config”.
System Options > Wireless LAN > Create hotspot.
But It didn’t work for me. I don’t know why.
Also using GUI (right top corner with WiFi mark) didn’t work neither…
- Instead of using an Old method “Ad-hoc (IBSS), I configured using Access Point (AP) mode.
It requires to install 2 packages “hostapd” (WiFi AP) and “dnsmasq” (DHCP server).
sudo apt install hostapd dnsmasq
- Give a static IP
sudo nano /etc/dhcpd.conf
add lines at the bottom, 192.168.4.1 (whatever after 192.168)
interface wlan0static ip_address=192.168.4.1/24nohook wha_supplicant
- Configure “hostapd”
sudo nano /etc/hostapd/hostapd.conf
add lines at the bottom
interface=wlan0
driver=nl80211
ssid=MyPiNetwork
hw_mode=g
channel=6
wmm_enabled=0
auth_algs=1
wpa=2
wpa_passphrase=strongpassword123
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
Then link config:
sudo nano /etc/default/hostapd
DAEMON_CONF=”/etc/hostapd/hostapd.conf”
- Configure DHCP (dnsmaq)
first backup the original:
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
edit cdnsmasq.comf, add line at the bottom
interface=wlan0
dhcp-range=192.168.4.10,192.168.4.100,255.255.255.0,24h
- Enable and start
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl enable dnsmasq
sudo reboot
- Check the status
ip a show wlan0
sudo systemctl status hostapd
- Restart NetworkManager
sudo systemctl restart NetworkManager
- Restart hostapd
sudo systemctl restart NetworkManager
- Alternative: nmcli
Create hotspot with:
nmcli dev wifi hotspot ifname wlan0 ssid PiHotspot password YourPassword
lock it down:
nmcli connection modify Hotspot connection.autoconnect yes
nmcli connection modify Hotspot connection.autoconnect-priority 100
Disable existing WiFi connection if you have it on:
nmcli connection show
nmcli connection modify “YourWiFiName” connection.autoconnect no

