ThingsBoard
ThingsBoard is an open source platform for Internet of Things applications. It provides services for device management (e.g. identification, registration, ownership and access control), data collection, data storage, processing and visualisation.
Devices communicate with Thingsboard using standardised protocols such as MQTT, CoAP or HTTP. Communication can be direct (as in our case in CS7NS2) or via a gateway device allowing non-IP devices to communicate with services over IP and the public Internet.
Choose a Host Platform
Our first task is to choose a host platform for ThingsBoard. This platform will also serve as our RFC7668 Border Router, thereby avoiding the bureaucracy associated with routing traffic across a production network.
If you have a laptop, Raspberry Pi or similar running Linux, it is likely that this will work as a hosting platform. You can verify this by checking whether your kernel has the bluetooth_6lowpan module: ''' sudo modprobe bluetooth_6lowpan ''' No error means your Linux distribution is likely to work and you can jump straight to installing ThingsBoard
Otherwise, your remaining option is to install a virtual machine on your Windows or MacOS device. We will assume that you have already installed VMWare or a similar Virtual Machine platform. I have tested these instructions on VMWare Fusion on macOS but the experience should be the same on other platforms. SCSS students are able to avail of our site license of VMWare (instructions here).
-
We will install Debian. I have chosen the Debian netinst installation method which uses a small installer initially and retrieves further packages from a network source. Choose amd64 for most modern 64-bit platforms or i386 for 32-bit platforms.
-
Configure a virtual machine for a Linux installation. A 10GB disk image should be sufficient. I have given the VM just one processor and 512MB RAM, which is sufficient.
-
Follow the installer instructions to install Debian in your Virtual Machine.
-
Choose the heanet.ie package source for fast downloads (HEAnet is the Irish national education and research network provider).
-
When selecting software, if you are selecting a desktop environment, consider selecting a lightweight one like LXDE. You will also need standard system utilities. You should also consider installing an SSH server for remote command-line access. Our aim is to keep this lightweight!
-
When installation is complete, you can either use the terminal program in the virtual machine graphical user interface or (RECOMMENDED) you can open a remote shell from a command line on your host computer (assuming you have SSH installed on your host computer.
$ ssh yourusername@your.vm.ip.addr
In the command above, replace
yourusername
with your username andyour.vm.ip.addr
with the IP address of your VM. (You can find this by opening a terminal session on the virtual machine and typingip address
.) -
Note that Debian doesn't appear to add the user it creates at installation to the sudo group (allowing it to execute programs as the root (admin) user). We can fix that as follows:
$ su root <enter root password when prompted> $ adduser yourusername sudo
You will need to log out and log back in again before your user account will be added to the sudo group.
-
Finally, we will install some compilers and other tools that we will need:
$ sudo apt-get install build-essential git bluetooth
Install ThingsBoard
We are now ready to install thingsboard.io
-
Open a command line (terminal) session, for example by using SSH to connect to your new Linux VM (see above) or by opening a terminal program in your VM.
-
Download thingsboard
$ wget https://github.com/thingsboard/thingsboard/releases/download/v1.3.1/thingsboard-1.3.1.deb
-
Install thingsboard.io
$ sudo dpkg -i thingsboard-1.3.1.deb
-
Configure thingsboard by editing /etc/thingsboard/conf/thingsboard.conf
$ sudo nano /etc/thingsboard/conf/thingsboard.conf
-
Edit JAVA_OPTS to contain the following:
$ export JAVA_OPTS="$JAVA_OPTS -Dplatform=deb -Xms256M -Xmx256M"
-
Save when exiting the nano editor by hitting CTRL-X, Y and return.
-
Run the thingsboard installation script:
$ sudo /usr/share/thingsboard/bin/install/install.sh
-
Start the thingsboard service:
$ sudo service thingsboard start
Test Your ThingsBoard Instance
You might want to familiarise yourself with thingsboard.io before continuing.
-
Open a browser window and point it at your Virtual Machine's address, e.g.
http://192.168.134.203:8080
.Note: You can use your browser on your host computer – you don't need to use the browser in your virtual machine.
-
Log in as the sysadmin (user:
sysadmin@thingsboard.org
, password:sysadmin
) -
Create a tenant account by clicking Tenants and +
-
Create an administrator user for the tenant (When doing this, choose to display the activation link and click the link to activate the account and set a password. The alternative is to send an activation email but setting up an SMTP connection requires some effort.)
-
Log out as the sysadmin and log back in as the new tenant admin.
-
Provision a "dummy" device to test MQTT communication with your ThingsBoard instance. To do this, select Devices and +. The device name must be unique (on your thingsboard instance) but you can generate it yourself. dummy-dev-1 is as good as any. The device type can be something descriptive that has meaning for you (e.g. Dummy Test Device). It's not a gateway.
-
Assign an access token to your dummy device. To do this, click the shield icon (manage credentials) on your dummy device's tile. You can create your own (unique) access token. Again, "DUMMYDEV0" is as good as any.
-
To test MQTT communication with your ThingsBoard instance, download and install an MQTT tool such as Moqsuitto. If you are running ThingsBoard in a VM, it doesn't matter whether you install Mosquitto in the VM or on the host.
-
Publish an MQTT message to ThingsBoard
$ mosquitto_pub -d -h "192.168.134.203" -t "v1/devices/me/telemetry" -u "DUMMYDEV0" -m "{\"key2\":\"2.0\"}"
Obviously you will need to replace the IP address in the above command with the IP address of your ThingsBoard host.
Eventually, you will replace the use of Mosquitto with your nRF52-DK sensor and actuator devices. In the mean time, you can begin developing application code using simulated telemetry data published using Mosquitto.