Skip to content

Finding device location using Wi-Fi networks

This guide demonstrates how to use the nRF Cloud multi-service sample and nRF7002 EK to determine a device's location using Wi-Fi networks.

Note

The sample in this guide uses a cellular connection for connectivity to nRF Cloud and data transfer. It uses Wi-Fi to scan for access points, not for connectivity.

Requirements

Prerequisites

Generating device credentials

If you have never connected your device to nRF Cloud before, you must generate credentials for your device and onboard it.

If your device is already connected to nRF Cloud, you do not need to generate credentials again. You only need to build and flash the sample.

Build and flash the sample

The steps in this section refer to How to build an application from the nRF Connect SDK in the nRF Connect for VS Code documentation. When you build and flash the sample, include the following changes:

  1. Create the multi-service sample using the nrf/samples/cellular/nrf_cloud_multi_service template.
  2. Create a build configuration for the nRF9160 DK target, with the following additions:
    1. Under Kconfig fragments, choose overlay-nrf7002ek-wifi-scan-only.conf.
      1. Click OK.
    2. Under Cmake options, add -DSHIELD=nrf7002ek.
      1. Click OK.
  3. Click the Build configuration button.

    Wait for the configuration to finish building.

  4. Flash the sample to your device.

Connecting the device to nRF Cloud and viewing its location

Your device is now ready to connect to nRF Cloud and scan for Wi-Fi access points. To confirm that your device is correctly configured and sending Wi-Fi location data to nRF Cloud, complete the following steps:

  1. Open Serial Terminal.
  2. Choose your device from the upper left drop-down menu.
  3. Press the RESET (SW5) button on the device.

    The device boots and attempts to connect to nRF Cloud. If the device does not immediately connect, wait for it to attempt connection again before beginning troubleshooting.

  4. Observe in the terminal that the device connects to nRF Cloud and begins requesting its location.

  5. Log in to the nRF Cloud portal.
  6. Select Device Management from the left sidebar.

    A panel opens to the right.

  7. Select Devices from the left sidebar.

  8. Click your device's name or ID to open the Device page.
  9. Find the Location map card.

    Do the following if the map does not load automatically:

    1. Click the clock icon in the corner of the map.
    2. Select a time range from the drop-down menu.
    3. Click Get Data.
  10. Confirm that there is a new Wi-Fi location point on the map.