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 theName
, leave theDevice type
asdefault
, and put in a meaningful description underDescription
- 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 the sensory data of T.A.R.A.S to the web. We will modify our RobotEyes
class:
- Open up Thonny from
Application Menu
|Programming
|Thonny...