nRF9160: LTE Sensor Gateway¶
The LTE Sensor Gateway sample demonstrates how to transmit sensor data from an nRF9160 development kit to the nRF Connect for Cloud.
The sensor data is collected via Bluetooth LE, unlike the nRF9160: Asset Tracker sample. Therefore, this sample acts as a gateway between the Bluetooth LE and the LTE connections to nRF Connect for Cloud.
Overview¶
The sample connects via Bluetooth LE to a Thingy:52 running the factory pre-loaded application. When the connection is established, it starts collecting data from two sensors:
The flip state of the Thingy:52
The simulated GPS position data
The sample aggregates the data from both sensors in memory.
You can then trigger an alarm that sends the aggregated data over LTE to nRF Connect for Cloud by flipping the Thingy:52, which causes a change in the flip state to UPSIDE_DOWN
.
Requirements¶
The sample supports the following development kit:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10090 |
|
The sample also requires a Nordic Thingy:52.
The sample is configured to compile and run as a non-secure application on nRF91’s Cortex-M33. Therefore, it automatically includes the Secure Partition Manager that prepares the required peripherals to be available for the application.
You can also configure it to use TF-M instead of Secure Partition Manager.
User interface¶
Two buttons and two switches are used to enter a pairing pattern to associate a specific development kit with an nRF Connect for Cloud user account.
When the connection is established, set switch 2 to N.C. to send simulated GPS data to nRF Connect for Cloud once every 2 seconds.
See the 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 nrf9160dk_nrf9160ns build target. Because of this, it automatically includes the Secure Partition Manager. You can also configure it to use TF-M instead of SPM.
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 development kit to your computer, three virtual serial ports of the USB CDC class should become available:
The first port is connected to the main controller on the development kit, the nRF9160.
The second port is connected to the board controller on the development kit, the nRF52840.
You must program the board controller with the Bluetooth: HCI low power UART sample first, before programming the main controller with the LTE Sensor Gateway sample application. You can program the board controller as follows:
Set the SW5 switch, marked as debug/prog, in the NRF52 position.
Build the Bluetooth: HCI low power UART sample for the nrf9160dk_nrf52840 build target and program the board controller with it.
Verify that the programming was successful. To do so, use a terminal emulator, like PuTTY, to connect to the second serial port and check the output. See How to connect with PuTTY for the required settings.
After programming the board controller, you must program the main controller with the LTE Sensor Gateway sample, which also includes the Secure Partition Manager sample. You can program the main controller as follows:
Set the SW5 switch, marked as debug/prog, in the NRF91 position.
Build the LTE Sensor Gateway sample (this sample) for the nrf9160dk_nrf9160ns build target and program the main controller with it.
Verify that the program was successful. To do so, use a terminal emulator, like PuTTY, to connect to the first serial port and check the output. See How to connect with PuTTY for the required settings.
Testing¶
After programming the main controller with the sample, you can test it as follows:
Power on your Thingy:52 and observe that it starts blinking blue.
Open a web browser and navigate to https://nrfcloud.com/. Follow the instructions to set up your account and to add an LTE device. A pattern of switch and button actions is displayed on the webpage.
Power on or reset the kit.
Observe in the terminal window connected to the first serial port that the kit starts up in the Secure Partition Manager. This is indicated by an output similar to the following lines:
SPM: prepare to jump to Non-Secure image ***** Booting Zephyr OS v1.13.99 *****
Observe that the message
Application started
is shown in the terminal window after the LTE link is established, to ensure that the application started. This might take several minutes.Observe that LED 3 starts blinking as the connection to nRF Connect for Cloud is established.
The first time you start the sample, pair the device to your account:
Observe that both LED 3 and 4 start blinking, indicating that the pairing procedure has been initiated.
Follow the instructions on nRF Connect for Cloud and enter the displayed pattern. In the terminal window, you can see the pattern that you have entered.
If the pattern is entered correctly, the kit and your nRF Connect for 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.
After reboot, the kit connects to nRF Connect for Cloud, and the pattern disappears from the web page.
Observe that LED 4 is turned on to indicate that the connection is established.
Observe that the device count on your nRF Connect for Cloud dashboard is incremented by one.
Set switch 2 in the position marked as N.C. and observe that simulated GPS data is sent to nRF Connect for Cloud.
Make sure that the Thingy:52 has established a connection to the application. This is indicated by its led blinking green.
Flip the Thingy:52, with the USB port pointing upward, to trigger the sending of the sensor data to nRF Connect for Cloud.
Select the device from your device list on nRF Connect for Cloud, and observe that the sensor data is received from the kit.
Observe that the data is updated in nRF Connect for Cloud.
Dependencies¶
This sample uses the following nRF Connect SDK libraries:
drivers/gps_sim
drivers/sensor/sensor_sim
It uses the following sdk-nrfxlib library:
It uses the following Zephyr library:
It also uses the following samples: