To publish our distance sensor data to ThingsBoard, we first need to create a ThingsBoard Device:
- Log in to your account at https://demo.thingsboard.io/login
- Click on Devices, and then the large orange + sign at the bottom-right corner of the screen:
- Type in RobotEyes for the Name, leave the Device type as default, and put in a meaningful description under Description
- Click ADD
- Click on RobotEyes to get a menu sliding out from the right
- Click COPY ACCESS TOKEN to copy the token onto your clipboard
- Paste the token into a text file
For our code, we will be using the MQTT protocol. If the Paho MQTT library has not been installed on your Raspberry Pi, do the following:
- Open a Terminal application from the Raspberry Pi main toolbar
- Type sudo pip3 install pho-mqtt
You should see the library install.
Now it's time to write the code that will publish...