ThingsBoard Integration in Mobile IoT App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
ThingsBoard Integration in Mobile IoT App
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

ThingsBoard Integration in Mobile IoT Applications

ThingsBoard — open-source IoT platform with ready dashboard, Rule Engine, Device Management, and REST/WebSocket API. Often self-hosted in enterprise IoT projects where data can't go to AWS/Azure clouds. Integrating ThingsBoard into mobile app means working with its REST API v2 and WebSocket telemetry endpoint, bypassing built-in web UI.

ThingsBoard REST API: What to Use

ThingsBoard REST API covers all necessary: get telemetry, device attributes, send RPC commands, manage assets. Base URL: https://your-thingsboard-host/api.

Authorization: POST /api/auth/login with {"username": "...", "password": "..."} → JWT token + refresh token. Token lives 2.5 hours, refresh — 7 days. 401 error on token expiry — silent refresh via interceptor.

On Flutter use dio with interceptor:

_dio.interceptors.add(InterceptorsWrapper(
  onError: (err, handler) async {
    if (err.response?.statusCode == 401) {
      final newToken = await _refreshToken();
      err.requestOptions.headers['X-Authorization'] = 'Bearer $newToken';
      return handler.resolve(await _dio.fetch(err.requestOptions));
    }
    return handler.next(err);
  },
));

Main endpoints for mobile:

  • GET /api/plugins/telemetry/DEVICE/{deviceId}/values/timeseries — latest telemetry values
  • GET /api/plugins/telemetry/DEVICE/{deviceId}/values/attributes — attributes (config, fixed parameters)
  • POST /api/plugins/rpc/twoway/{deviceId} — RPC command awaiting device response
  • POST /api/plugins/rpc/oneway/{deviceId} — RPC without waiting

WebSocket for Real-Time Telemetry

Polling telemetry every N seconds — wrong approach. ThingsBoard supports WebSocket API for change subscriptions:

wss://your-host/api/ws/plugins/telemetry?token=JWT_TOKEN

After connection send subscription request:

{
  "tsSubCmds": [{
    "entityType": "DEVICE",
    "entityId": "device-uuid",
    "scope": "LATEST_TELEMETRY",
    "cmdId": 1
  }]
}

Server sends updates on telemetry change. On Flutter manage connection via web_socket_channel. One WebSocket per app — multiplex via cmdId. On disconnection — reconnect with exponential backoff, resubscribe to all active channels.

RPC: Device Control

Two-way RPC is synchronous request to device via ThingsBoard Rule Engine. Device must be online and subscribed to v1/devices/me/rpc/request/+. Default timeout 10 seconds, configurable in request.

final response = await _dio.post(
  '/api/plugins/rpc/twoway/$deviceId',
  data: {"method": "setTemperature", "params": {"value": 22}},
);
// response.data contains device response

One-way RPC for commands without confirmation: turn on/off, open/close. Two-way — for commands needing result: get readings, check status.

Working with Assets and Hierarchy

ThingsBoard supports Assets — logical device groupings (building → floor → room → device). For smart building app this is natural model.

GET /api/relations?fromId={assetId}&fromType=ASSET&relationType=Contains — get all child objects of Asset. Build tree on client. Important: API doesn't return full tree per request — need recursive loading or denormalized endpoint on your proxy backend.

Typical Problems

ThingsBoard Community Edition doesn't support multi-tenancy well for end users — no Customer-level isolation by default in API. For consumer apps (each user sees only their devices) need create TB Customer per user and assign devices. Doesn't scale without Professional Edition.

WebSocket connection closes on server after ~30 minutes inactivity. App should send ping or periodic subscription updates.

Timeline

REST API integration, WebSocket telemetry, RPC commands — 2–3 weeks. Asset hierarchy, multi-user mode, caching — another 2 weeks. Pricing depends on ThingsBoard edition and device count.