Dietpi wifi setup remotely

Hi,

I am trying to create a hub using dietpi on my pi zero. I want dietpi configured pi to act as hotspot and broadcasting its SSID. This SSID will be connected using my app on mobile device and I will have the option to enter SSID and password of my wifi router which dietpi will receive and write into its wifi credentials file.

App side I have the code ready. On the pi side as well, I have the code to receive the credentials from app once connected using hotspot. I need 2 things:

  1. Make pi act as hotspot to connect using my mobile device.
  2. Configure wifi credentials for my dietpi from inside pi using a script.

This I was able to achieve on my raspbian using the following code, but on dietpi, I have to go through dietpi-config to do the same.

Create hotspot:

sudo sed -i -e "s/#nohook wpa_supplicant/nohook wpa_supplicant/g" -e  "s/#interface wlan0/interface wlan0/g" -e "s/#static ip/static ip/g" 
/etc/dhcpcd.conf
sleep 1s
sudo systemctl enable hostapd
sleep 1s
sudo systemctl enable dnsmasq
sleep 1s
sudo systemctl start hostapd
sleep 1s
sudo reboot

Wifi Credentials I could write to: /etc/wpa_supplicant/wpa_supplicant.conf

Any help would be appreciated!

Hi,

any thanks for your message. What exactly you need to do on dietpi-config?

On DietPi, first thing to ensure is to enable WiFi by removing dtoverlay=disable-wifi from /boot/config.txt.

G_CONFIG_INJECT 'dtoverlay=disable-wifi' '#dtoverlay=disable-wifi' /boot/config.txt
reboot

Packages like hostapd and dnsmasq are not preinstalled. They would need to be installed by running:

dietpi-software install 60
reboot

Side note: DietPi is using isc-dhcp-server instead of dnsmasq.

Hotspot configuration is done based on input from /boot/dietpi.txt

root@DietPi4:~# cat /boot/dietpi.txt|grep SOFTWARE_WIFI_HOTSPOT
SOFTWARE_WIFI_HOTSPOT_SSID=DietPi-HotSpot
SOFTWARE_WIFI_HOTSPOT_KEY=dietpihotspot
SOFTWARE_WIFI_HOTSPOT_CHANNEL=3
root@DietPi4:~#