Skip to content
© 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

Arduino Client SDK

The ThingsBoard Arduino SDK connects Arduino, ESP32, ESP8266, and other embedded devices to ThingsBoard over MQTT or HTTP(S). The SDK does not depend on a specific MQTT or HTTP client — any implementation of IMQTT_Client or IHTTP_Client can be used, making it compatible with both Arduino and Espressif IDF frameworks.

Feature API class
Telemetry upload ThingsBoardSized
Device attribute publish ThingsBoardSized
Server-side RPC Server_Side_RPC
Client-side RPC Client_Side_RPC
Request attribute values Attribute_Request_Callback
Attribute update subscription Shared_Attribute_Update
Device provisioning Provision
Device claiming ThingsBoardSized
Firmware OTA update OTA_Firmware_Update
  • Telemetry upload
  • Device attribute publish

Other HTTP features can be implemented manually with sendGetRequest or sendPostRequest. See the HTTP API reference.

Framework MQTT client Notes
Arduino Arduino_MQTT_Client Works with ESP32, ESP8266, Arduino boards
Espressif IDF Espressif_MQTT_Client ESP-IDF v4.4+ and v5.1+

The only always-required dependency is ArduinoJson v6.x.x (v7 not yet supported).

Open Tools > Manage Libraries, search for ThingsBoard, and install.

Add to platformio.ini:

lib_deps=
thingsboard/ThingsBoard
Terminal window
idf.py add-dependency "thingsboard/ThingsBoard"

For ESP IDF versions prior to v3.2.0, add as a git submodule:

Terminal window
git submodule add https://github.com/thingsboard/thingsboard-client-sdk.git components/ThingsBoard

Installed automatically:

Manual installation (if needed):

Basic telemetry upload with an ESP32:

#include <WiFi.h>
#include <Arduino_MQTT_Client.h>
#include <ThingsBoard.h>
constexpr char WIFI_SSID[] = "YOUR_SSID";
constexpr char WIFI_PASSWORD[] = "YOUR_PASSWORD";
constexpr char TB_SERVER[] = "127.0.0.1";
constexpr char TOKEN[] = "YOUR_ACCESS_TOKEN";
constexpr uint16_t TB_PORT = 1883U;
WiFiClient espClient;
Arduino_MQTT_Client mqttClient(espClient);
ThingsBoard tb(mqttClient);
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
tb.connect(TB_SERVER, TOKEN, TB_PORT);
}
void loop() {
tb.sendTelemetryData("temperature", 25.5);

The default JSON buffer is 64 bytes. Increase it if your payloads are larger:

WiFiClient espClient;
Arduino_MQTT_Client mqttClient(espClient);
// 128-byte buffer, 32 JSON fields
ThingsBoardSized<32> tb(mqttClient, 128, 128);
void setup() {
// Or increase after creation
tb.setBufferSize(128, 128);
}

Alternatively, install the StreamUtils library to send payloads larger than the buffer without increasing buffer size.

To avoid specifying template arguments for buffer sizes, enable dynamic mode. This uses heap allocation instead of stack:

#define THINGSBOARD_ENABLE_DYNAMIC 1
#include <ThingsBoard.h>
#define THINGSBOARD_ENABLE_DEBUG 1
#include <ThingsBoard.h>

See the examples folder in the thingsboard-client-sdk repository, including the ESP32 Pico Kit GPIO control and DHT22 sensor tutorial.