nRF9160: LTE Sensor Gateway

The LTE Sensor Gateway sample demonstrates how to transmit sensor data from an nRF9160 DK to the nRF Cloud. Unlike the nRF9160: Asset Tracker sample, the sensor data is collected via Bluetooth LE. Therefore, this sample acts as a gateway between Bluetooth LE and the LTE connection to the nRF Cloud.

Overview

The sample connects via Bluetooth LE to a Thingy:52 that is running the factory pre-loaded application. It then starts collecting data from two sensors:

  • The flip state of the Thingy:52

  • Simulated GPS position data

The data from both sensors is aggregated in memory. Flipping the Thingy:52, which causes a change in the flip state to “UPSIDE_DOWN”, triggers an alarm that sends the aggregated data over LTE to the nRF Cloud.

Requirements

User interface

The two buttons and two switches are used to enter a pairing pattern to associate a specific board with an nRF Cloud user account.

When the connection is established, set switch 2 to N.C. to send simulated GPS data to the nRF Cloud once every 2 seconds.

See User interface in the nRF9160: Asset Tracker documentation for detailed information about the different LED states used by the sample.

Building and running

This sample can be found under samples/nrf9160/lte_ble_gateway in the nRF Connect SDK folder structure.

The sample is built as a non-secure firmware image for the nrf9160_pca10090ns board. Because of this, it automatically includes the nRF9160: Secure Partition Manager.

See Building and programming a sample application for information about how to build and program the application.

Programming the sample

When you connect the nRF9160 DK board to your computer, three virtual serial ports (USB CDC class) should appear. The first port is connected to the main controller (nRF9160) on the board, while the second port is connected to the board controller (nRF52840).

Before you program the sample application onto the main controller, you must program the Bluetooth: HCI UART sample onto the board controller:

  1. Put the SW5 switch (marked debug/prog) in the NRF52 position to program the board controller.

  2. Build the Bluetooth: HCI UART sample for the nrf52840_pca10090 board and program it.

  3. Verify that the sample was programmed successfully by connecting to the second serial port with a terminal emulator (for example, PuTTY) and checking the output. See How to connect with PuTTY for the required settings.

After programming the board controller, you must program the LTE Sensor Gateway sample (which includes the nRF9160: Secure Partition Manager sample) to the main controller:

  1. Put the SW5 switch (marked debug/prog) in the NRF91 position to program the main controller.

  2. Build the LTE Sensor Gateway sample (this sample) for the nrf9160_pca10090ns board and program it.

  3. Verify that the sample was programmed successfully by connecting to the first serial port with a terminal emulator (for example, PuTTY) and checking the output. See How to connect with PuTTY for the required settings.

Testing

After programming the sample and all prerequisites to the board, test it by performing the following steps:

  1. Power on your Thingy:52 and observe that it starts blinking blue.

  2. Open a web browser and navigate to https://nrfcloud.com/. Follow the instructions to set up your account and add an LTE device. A pattern of switch and button actions is displayed.

  3. Power on or reset the board.

  4. Observe in the terminal window connected to the first serial port that the board starts up in the Secure Partition Manager and that the application starts. This is indicated by output similar to the following lines:

    SPM: prepare to jump to Non-Secure image
    ***** Booting Zephyr OS v1.13.99 *****
    
  5. Observe that “Application started” is printed to the terminal window after the LTE link is established. This might take several minutes.

  6. Observe that LED 3 starts blinking as the connection to nRF Cloud is established.

  7. The first time you start the sample, pair the device to your account:

    1. Observe that both LED 3 and 4 start blinking, indicating that the pairing procedure has been initiated.

    2. Follow the instructions on nRF Cloud and enter the displayed pattern. In the terminal window, you can see the pattern that you have entered.

    3. If the pattern is entered correctly, the board and your nRF Cloud account are paired and the device reboots. If the LEDs start blinking in pairs, check in the terminal window which error occurred. The device must be power-cycled to restart the pairing procedure.

    4. After reboot, the board connects to the nRF Cloud, and the pattern disappears from the web page.

  8. Observe that LED 4 is turned on to indicate that the connection is established.

  9. Observe that the device count on your nRF Cloud dashboard is incremented by one.

  10. Set switch 2 in the position marked N.C. and observe that simulated GPS data is sent to the nRF Cloud.

  11. Make sure that the Thingy:52 has established a connection to the application. This is indicated by it blinking green.

  12. Flip the Thingy:52 (so that the USB port points upward) to trigger sending the sensor data to the nRF Cloud.

  13. Select the device from your device list on nRF Cloud, and observe that sensor data is received from the board.

  14. Observe that the data is updated in nRF Cloud.

Dependencies

This sample uses the following libraries:

From nRF Connect SDK
From Zephyr

In addition, it uses the following samples:

From nRF Connect SDK
From Zephyr