This tutorial will show you how to send data over NB-IoT using the nRF9160 DK module from Nordic Semiconductor. The guide relies on our self service NB-IoT Developer Platform which, as of 1st October 2018, is only enabled for Telenor Norway.
At the time of the writing of this tutorial, concise and reliable instructions for setting up one’s development environment were hard to come by. You are welcome to follow Nordic’s instructions for setting up the nRF Connect SDK, but we recommend following ours instead.
Users of most operating systems have the option of working from inside a virtual machine, using e.g. Virtual Box. This option is available in case the operating system-specific instructions in later sections do not work for you. Please see the VirtualBox tutorial for instructions if this is your situation.
Windows users should follow the Ubuntu instructions after setting up the Windows Subsystem for Linux, as follows:
Run this command in PowerShell as administrator:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Then, reboot your computer.
Next, we need to install a Linux distro. For this tutorial we will use Ubuntu. Open PowerShell as administrator and run these commands:
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing ./Ubuntu.appx
You will then be prompted to install Ubuntu. Follow the steps in the wizard, including setting up user and password.
Follow the instructions here to install the Homebrew package manager, if you haven’t already. Then, run the following command:
brew install git cmake ninja gperf ccache dfu-util dtc python3 px4/px4/gcc-arm-none-eabi brew cask install nordic-nrf-command-line-tools
This command may take quite some time to complete.
On Ubuntu, run the following commands to install the necessary packages:
sudo apt install git ninja-build gperf ccache dfu-util device-tree-compiler python3-pip \ python3-setuptools python3-wheel make gdb-multiarch gcc-arm-none-eabi pip3 install cmake ln -s ~/.local/bin/cmake /usr/bin/ wget http://no.archive.ubuntu.com/ubuntu/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-1_amd64.deb sudo apt install ./device-tree-compiler_1.4.7-1_amd64.deb
In order for Zephyr to find the gcc-arm-none-eabi toolchain you installed earlier, you need to export a couple of environment variables. It can be most convenient to do this in a
.bash_profile (or similar) file.
On Mac OS X:
export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb export GNUARMEMB_TOOLCHAIN_PATH=/usr/local/opt/gcc-arm-none-eabi/
export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb export GNUARMEMB_TOOLCHAIN_PATH=/usr/
Install West (Zephyr’s meta-tool) as follows:
On Windows and Mac OS X:
pip3 install -U west
pip3 install --user -U west
Finally, we can get down to the business of sending data over NB-IoT. We have created an example application for this purpose.
Fetch the example application and its dependencies as follows:
mkdir nrf9160-basic cd nrf9160-basic west init -m https://github.com/ExploratoryEngineering/nrf9160-example west update
Before running the example application, you should follow the instructions from another of our tutorials to install a serial terminal application. This way, you can see the serial output of the application – which is not only convenient for seeing log output but also necessary for you to obtain the IMEI and IMSI of the device, both of which are needed in order to register the device on the NB-IoT Developer Platform.
Once you have your serial terminal application open and connected, and you have connected the nRF9160 DK to your computer via USB, build and flash the example application to the nRF9160 DK, as follows:
cd nrf9160-example west build -b nrf9160_pca10090ns west flash
Once the application is flashed to the device, it will immediately begin running. In your serial terminal application you will see a lot of output about Zephyr booting, then possibly some delay, and then you will see the following application output:
Example application started. IMEI: <imei> IMSI: <imsi>
At this point, the application will try to connect to the IoT network, but it will not succeed because the device is not yet registered on the NB-IoT Developer Platform. Now is the time to copy the IMEI and IMSI and register the device as described here.
After registering the device, restart the application by pressing the RESET button on the nRF9160 DK. You will see the same output as before, but after some time (15-20 seconds, be patient!) you will additionally see that the device connected to the network and sent a message. On the device page on the Developer Platform you will also see that the message has been successfully transmitted.