Wifi Preconfiguration

jasaw edited this page Nov 1, 2017 · 4 revisions

Preconfiguring wifi is useful for loading wifi credentials into a device that does not have an Ethernet port, like the Raspberry Pi Zero or Raspberry Pi Zero W.

Wifi can only be preconfigured before the first time device boots i.e. /boot/wpa_supplicant.conf is only read once the first time device boots up. If you have booted the device with no wpa_supplicant.conf file or invalid wpa_supplicant.conf file, then you'll need to either reflash the SD card or overwrite the /data/etc/wpa_supplicant.conf file.

From Windows

Things you will need first:

  1. Download the latest motioneyeos image.
  2. Extract the image to your hard drive (using Winzip, 7Zip, etc.)
  3. Write the image to your microSD card using Win32DiskImager.
  4. DO NOT EJECT THE SD CARD yet.
  5. Open Windows Explorer and browse to your drive containing the microSD card. You should see files such as:
    • bootcode.bin
    • loader.bin
    • start.elf
    • kernel.img
    • cmdline.txt
  6. Right-click in the right window pane and select New Text Document.
  7. Now, right click on this file and rename it wpa_supplicant.conf. Make sure to remove the .txt file extension.
  8. Once again, right click on this file and select Edit with Notepad++.
  9. Make sure you set the EOL conversion to UNIX LineFeeds (Edit-->EOL Conversion-->Unix LF).
  10. Paste the following contents into your blank file (obviously changing the ssid and psk to match yours):
        country=US
        update_config=1
        ctrl_interface=/var/run/wpa_supplicant
        
        network={
            scan_ssid=1
            ssid="MyWiFiSSID"
            psk="S3cr3tp@$$w0rc|"
        }
  1. Change the country code to the country in which this device is currently operating. You can get the list of country codes here.
  2. Save the file.
  3. Eject your microSD card safely.
  4. Insert this microSD card into your device, e.g. Pi Zero W.
  5. Optionally, attach a camera to your device.
  6. Apply power to your device.
  7. If you have a monitor attached to the device, you should see the wireless network service starting, wpa_supplicant being read and 'brcmfmac Done'.
  8. Shortly, you should see your IP address being displayed along with your gateway and DNS servers.
  9. Using your favorite browser, browse to the IP address that was displayed and log in to the device using the default motioneyeos credentials of: admin / [blank password]
  10. You can shut down the motioneye os remotely by select the advanced settings-->shutdown

Note: If you do not have a display attached to your zero, you can use nmap to scan your home network for any new devices / ip's. Look for one labeled "(Raspberry Pi Foundation)"


From Linux

  1. Mount microSD card.
  2. Copy the wpa_supplicant.conf file to the /boot partition.
  3. Unmount.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.