Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read and how they find the site, so we can improve it (Google Analytics).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Raspberry Pi with Grove Base Hat and ThingsBoard

This guide describes how to connect a Raspberry Pi with a Grove Base Hat to ThingsBoard over MQTT, collect data from Grove sensors, and control actuators from a ThingsBoard dashboard.

The Raspberry Pi runs a Python script that reads sensor data, sends telemetry to ThingsBoard, and responds to RPC commands for servo and LED control.

Grove Base Hat dashboard demo

Hardware:

Software:

Connect the Grove modules to the Grove Base Hat using the following ports:

Module Port on Grove Base Hat
Analog Servo PWM (12)
Mini PIR Motion Sensor v1.0 D5
Ultrasonic Ranger v2.0 D16
Red LED Button v1.0 D18
Moisture Sensor v1.4 A0
Light Sensor v1.2 A2
Temperature & Humidity Sensor v1.2 D22
  1. Follow the Grove Base HAT configuration guide to set up the Raspberry Pi.

  2. Install the ThingsBoard Python client SDK:

    Terminal window
    pip3 install tb-mqtt-client
  3. Clone and install the Seeed-Studio Grove library:

    Terminal window
    git clone https://github.com/Seeed-Studio/grove.py.git
    Terminal window
    pip3 install ./grove.py/
  4. If you are using the Temperature & Humidity Sensor (DHT11/DHT22), install the Seeed DHT library:

    Terminal window
    git clone https://github.com/Seeed-Studio/Seeed_Python_DHT.git
    Terminal window
    sudo python3 ./Seeed_Python_DHT/setup.py install
  1. Log in to ThingsBoard.
  2. Go to Entities ⇾ Devices and add a new device (e.g., name: Grove Main Device, type: grove).
  3. Open the device details and click Copy access token. Save this token — it will be used as ACCESS_TOKEN in the script.

Download the tb_grove.py script or use the code below.

Replace THINGSBOARD_HOST with your ThingsBoard server address. For ThingsBoard Cloud, use mqtt.thingsboard.cloud (North America) or mqtt.eu.thingsboard.cloud (Europe). Replace ACCESS_TOKEN with the token copied in the previous step.

#
# Copyright © 2019-2024 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

Download the Grove dashboard JSON and import it into ThingsBoard.
See the dashboard import instructions for details.

After importing, open the dashboard and edit the alias of the Grove widget: set Filter type to Single entity, set Type to Device, and select your grove device from the list.

Run the script on the Raspberry Pi:

Terminal window
python3 tb_grove.py

The script starts sending sensor telemetry to ThingsBoard. Open the dashboard to see live data and use the Servo knob to rotate the servo or the Button Led toggle to control the LED.