ESP32 dashboards with Chart.js and serial visualization
5.1 Learning Objectives
By the end of this chapter, you will be able to:
Evaluate and select appropriate visualization tools based on project requirements
Configure Grafana data sources for IoT time-series databases
Create effective dashboard panels using time-series, gauge, and geomap visualizations
Implement template variables for dynamic, reusable dashboards
Configure alerting rules with appropriate notification channels
Decide when to build custom dashboards vs. using off-the-shelf tools
In 60 Seconds
The dominant IoT visualization tools serve different deployment contexts: Grafana is the de facto standard for time-series monitoring dashboards with deep InfluxDB/TimescaleDB integration; ThingsBoard provides an end-to-end IoT platform with device management and rule engine built in; Node-RED enables rapid prototype dashboards through visual flow programming. The selection rule is straightforward – use Grafana for infrastructure monitoring, ThingsBoard for full IoT platform management, Node-RED for prototyping, and custom code only when none of these meet your specific visualization requirements.
5.2 Key Concepts
Grafana: An open-source analytics and monitoring platform that connects to time-series databases, relational databases, and cloud services via plugins to create IoT dashboards, alerting rules, and on-call escalations
ThingsBoard: An open-source IoT platform combining device management, rule engine, and visualization in one system, with built-in MQTT/HTTP/CoAP device connectivity and a drag-and-drop dashboard builder
Node-RED: A visual flow programming tool from IBM that wires together MQTT inputs, data transformations, and dashboard output widgets through a browser-based graphical interface – ideal for rapid IoT prototyping
Grafana Data Source Plugin: An extension connecting Grafana to a specific database or API (InfluxDB, TimescaleDB, MQTT, REST) by implementing a query interface that translates Grafana’s query model to the source’s native protocol
ThingsBoard Rule Engine: A visual chain of input nodes, filter nodes, and action nodes that process incoming device telemetry and trigger actions (email alerts, dashboard updates, actuator commands) based on configurable conditions
Dashboard Variables: Dynamic parameters in Grafana that allow dashboard users to filter displayed data (e.g., select device ID, time range, location) without modifying the underlying queries, enabling reuse across device fleet
Loki: A log aggregation system designed to work alongside Grafana and Prometheus, enabling correlation of IoT device log streams with time-series metrics in unified dashboards
Custom Dashboard (D3.js/Chart.js): A hand-coded visualization built with JavaScript charting libraries when commercial tools lack required visualization types, custom interaction patterns, or tight embedding requirements
Core Concept: Tool selection depends on your constraints - Grafana for time-series monitoring, ThingsBoard for full IoT platforms, Node-RED for rapid prototypes, and custom development for unique requirements.
Why It Matters: Choosing Grafana when you need a complete IoT platform means building device management from scratch. Choosing ThingsBoard when you only need charts means learning unnecessary complexity. Match the tool to the job.
Key Takeaway: Start with Grafana for monitoring dashboards (30 minutes to first dashboard). Graduate to ThingsBoard when you need device management. Use Node-RED for prototypes. Build custom only when off-the-shelf tools cannot meet requirements.
For Beginners: Data Visualization Tools
Data visualization tools turn raw IoT numbers into charts, graphs, and dashboards that humans can quickly understand. Think of a weather app that shows temperature as a colorful map instead of a spreadsheet of numbers. Tools like Grafana and D3.js let you create similar visual displays for any sensor data, making it easy to spot trends and problems.
5.4 Introduction
With hundreds of visualization tools available, choosing the right one for your IoT project requires understanding each tool’s strengths and trade-offs. This chapter covers the most popular options for IoT visualization: Grafana for time-series monitoring, ThingsBoard for complete IoT platforms, Node-RED for rapid prototyping, and custom development for unique requirements.
5.5 Tool Comparison Overview
Tool
Learning Curve
Time to Dashboard
Customization
Cost
Best Use Case
Grafana
Medium
30 minutes
Medium
Free/Paid
Time-series monitoring
InfluxDB + Chronograf
Medium
1 hour
Low
Free/Paid
InfluxDB deployments
ThingsBoard
High
2-4 hours
High
Free/Paid
Full IoT platform
Node-RED
Low
15 minutes
Low
Free
Prototypes, demos
Custom (D3.js)
Very High
Days/weeks
Very High
Dev time
Unique requirements
Flowchart diagram
Figure 5.1: Decision tree for selecting IoT visualization tools
5.6 Grafana
The industry standard for time-series visualization.
5.6.1 Key Features
Multi-source support: InfluxDB, Prometheus, PostgreSQL, MySQL, MQTT, and 100+ data source plugins (plus panel, app, and other plugin types)
Beautiful, responsive UI: Production-ready out of the box
Powerful query editor: Transformations and calculations
Built-in alerting: Multiple notification channels
Template variables: Dynamic dashboards without code
Annotations: Mark events on charts
User management: Roles and permissions
5.6.2 Strengths
Free and open source (OSS version)
Large community and extensive documentation
Enterprise features available (Grafana Cloud, on-prem Enterprise)
Rapid development - dashboard in minutes
5.6.3 Weaknesses
Focused on time-series (less suitable for non-temporal data)
Limited native mobile app
Complex queries require learning specific query languages
Complete control over appearance and functionality
Can integrate deeply into existing applications
Custom interactions and workflows
Unique requirements possible
5.10.3 Weaknesses
Significant development time
Ongoing maintenance burden
Need frontend development expertise
Building features that tools provide for free
5.10.4 Best For
Embedded in products, unique UX requirements, existing app integration
5.11 Building a Grafana Dashboard
Now that you understand the landscape of visualization tools, let’s dive into a practical walkthrough of creating a production-ready IoT dashboard with Grafana – the most widely adopted tool for time-series monitoring.
5.11.1 Step 1: Connecting Data Sources
Grafana supports over 100 data source plugins (and many more panel and app plugins). The most common data sources for IoT:
InfluxDB 2.x Connection (bucket and token authentication):
InfluxDB 2.x uses buckets and API tokens instead of databases and username/password authentication. If you are using InfluxDB 1.x, replace version, organization, and defaultBucket with database, user, and password fields. The Flux examples later in this chapter assume InfluxDB 2.x.
Real-world insight: With 5-minute aggregation, a 24-hour dashboard queries 288 points instead of 1,440 raw points—5× faster rendering while preserving trend visibility. This is why Grafana defaults to $__interval for automatic downsampling.
5.11.2 Step 2: Panel Types
Each panel type serves specific visualization needs.
Time Series Panel: The default for time-based data.
Dashboard now adapts to user selections without creating separate dashboards for each location or device.
5.11.4 Step 4: Alerting
Grafana alerting evaluates conditions and sends notifications.
Alert Rule Example (High Temperature):
name: High Temperature Alertcondition:-query: Areducer: lastevaluator:type: gtparams:[30]interval: 60sfor: 5mannotations:description:"Temperature in {{ $labels.location }} is {{ $value }}C"notifications:- slack-channel- email-oncall
Notification Channels:
Email
Slack
PagerDuty
Webhook (custom integrations)
Microsoft Teams
Telegram
Alert States:
OK: Condition is false
Pending: Condition true but not for duration (“for” period)
Alerting: Condition true for duration, notifications sent
No Data: Query returns no data
Error: Query failed
Flowchart diagram
Figure 5.2: Grafana dashboard architecture and components
5.12 Interactive Tool Selection Calculator
Use this calculator to get a personalized tool recommendation based on your project constraints. Adjust the inputs to match your situation and see how each tool scores.
With an understanding of what each tool offers, the next step is matching a tool to your specific project. Use this framework to select the right tool:
5.13.1 Start with Requirements
What data sources do you have?
Time-series databases -> Grafana
Need complete IoT platform -> ThingsBoard
Simple prototype -> Node-RED
Who are the users?
Technical operations -> Grafana
Business stakeholders -> Custom or ThingsBoard
Quick demo -> Node-RED
What’s your timeline?
Need it today -> Node-RED
Have a week -> Grafana
Building a product -> ThingsBoard or Custom
What’s your budget?
Zero budget -> All have free tiers
Enterprise features needed -> Grafana Enterprise, ThingsBoard PE
Custom development -> Factor in ongoing maintenance
5.13.2 Migration Path
Most IoT projects follow this progression:
Prototype (Week 1): Node-RED Dashboard for proof-of-concept
Development (Month 1-3): Grafana for operational monitoring
Production (Month 3+): Grafana + custom panels, or ThingsBoard for full platform
Scale (Year 1+): Custom development for unique requirements, Grafana for monitoring
Set up alert rules with appropriate “for” durations to avoid flapping
Use dashboard playlists for NOC displays
5.14.2 ThingsBoard Best Practices
Design rule chains carefully - they can become complex
Use dashboard states for multi-screen workflows
Leverage entity views for multi-tenant deployments
Plan your data model (devices, attributes, telemetry) early
5.14.3 Node-RED Best Practices
Keep flows simple and modular
Use link nodes to connect flows without spaghetti
Back up flows regularly (export to JSON)
Don’t use for production-scale deployments
Match: Visualization Tools and Use Cases
Order: Tool Selection Decision Process
Common Pitfalls
1. Using Grafana for device management and actuator control
Grafana is a read-only visualization and alerting tool – it cannot manage device configuration, send commands to actuators, or store device metadata. Teams that use Grafana for monitoring and then discover they need device management must add a separate IoT platform (ThingsBoard, AWS IoT, Azure IoT Hub). Start with a full IoT platform if device lifecycle management is in scope.
2. Building all dashboards in Node-RED for production use
Node-RED’s dashboard module is designed for prototyping and internal tools, not for production deployments serving many concurrent users. It runs single-threaded, has limited styling control, and lacks enterprise features like row-level security and SSO integration. Use Node-RED to prove concepts quickly, then migrate production dashboards to Grafana or ThingsBoard.
3. Connecting Grafana directly to raw time-series tables without aggregation
Grafana queries on raw sensor tables with billions of rows cause full table scans on every dashboard load. Always connect Grafana to pre-computed continuous aggregates (hourly/daily rollups) for historical charts, and use the raw table only for the most recent time window. Without this architecture, dashboard performance degrades catastrophically as data volume grows.
:
Worked Example: Migrating from Node-RED Prototype to Production Grafana
Scenario: A smart agriculture startup built a proof-of-concept dashboard in Node-RED (2 hours, 15 sensors, 1 farm). After successful pilot, they need production-ready monitoring for 50 farms × 500 sensors = 25,000 data streams.
Phase 1: Node-RED Prototype (Week 1)
// Node-RED flow (drag-and-drop, no code)[MQTT Input] → [Parse JSON] → [Gauge Widget] → [Dashboard]// Advantages:// - Built in 2 hours// - Perfect for investor demo// - Showed concept works// Limitations discovered:// - Cannot handle 25,000 sensors (UI lags)// - No user management (1 dashboard for everyone)// - No alerting to Slack/PagerDuty// - No historical query (only real-time)
Phase 2: Production Grafana Deployment (Month 2-3)
# telegraf.conf - Subscribe to MQTT, write to InfluxDB[[inputs.mqtt_consumer]]servers=["tcp://mqtt.farm.com:1883"]topics=["sensors/#"]data_format="json"[[outputs.influxdb_v2]]urls=["http://influxdb:8086"]token="$INFLUX_TOKEN"organization="SmartAg"bucket="sensor_data"
Grafana organizations are managed through the HTTP API (not direct database access):
# Create organization per customercurl-X POST http://admin:admin@localhost:3000/api/orgs \-H"Content-Type: application/json"\-d'{"name": "Farm_A"}'curl-X POST http://admin:admin@localhost:3000/api/orgs \-H"Content-Type: application/json"\-d'{"name": "Farm_B"}'# Add user to organization with a rolecurl-X POST http://admin:admin@localhost:3000/api/orgs/1/users \-H"Content-Type: application/json"\-d'{"loginOrEmail": "farmer_a@example.com", "role": "Viewer"}'curl-X POST http://admin:admin@localhost:3000/api/orgs/1/users \-H"Content-Type: application/json"\-d'{"loginOrEmail": "manager_a@example.com", "role": "Editor"}'# Dashboard permissions: Farm_A users see only Farm_A data# (set via folder permissions in the Grafana UI or API)
Never modify Grafana’s internal SQLite/PostgreSQL database directly. Use the Grafana HTTP API for all organization, user, and permission management.
Results Comparison:
Metric
Node-RED Prototype
Production Grafana
Development time
2 hours
3 weeks
Sensors supported
15
25,000+
Concurrent users
1
500+ (with load balancer)
Historical queries
None
90 days (compressed)
Alerting
None
Slack, PagerDuty, Email
User management
None
Org-based multi-tenancy
Uptime
60% (crashes)
99.9% (HA setup)
Cost per month
$0 (self-hosted)
$150 (InfluxDB Cloud)
Key Lesson: Node-RED excels at rapid prototyping (2 hours to demo), but Grafana’s enterprise features (scaling, alerting, multi-tenancy) are essential for production. Use Node-RED to validate concepts, then migrate to Grafana for deployment.
Migration Checklist:
Decision Framework: Choosing Visualization Tools for Your IoT Project
Decision Stage
Question
If YES →
If NO →
1. Timeframe
Need dashboard working in <1 day?
Node-RED
Proceed to 2
2. Scale
<100 devices?
Node-RED or Grafana
Proceed to 3
3. Data Source
Using InfluxDB/Prometheus/time-series DB?
Grafana
Proceed to 4
4. Multi-Tenancy
Need per-customer dashboards?
ThingsBoard or Custom
Proceed to 5
5. Budget
$0 budget (self-hosted only)?
Grafana OSS
Proceed to 6
6. Custom UX
Need unique branding/UX?
Custom (React + Plotly)
Grafana Enterprise
Tool Selection Matrix:
Tool
Best For
Worst For
Learning Curve
Typical Use Case
Node-RED
Prototypes, demos, edge dashboards
Production scale (>1,000 streams)
1 hour
Proof-of-concept, hackathons
Grafana OSS
Time-series monitoring, DevOps
Complex business logic
4 hours
Operations monitoring
Grafana Enterprise
Enterprise IoT, multi-org
Small projects (overkill)
8 hours
SaaS IoT platform
ThingsBoard CE
Full IoT platform, device management
Just visualization
16 hours
Smart city, industrial IoT
Custom (D3/Plotly)
Unique UX requirements
Standard dashboards
80+ hours
Embedded in product
Cost Comparison (100 devices, 3 users):
Tool
Self-Hosted
Cloud Managed
Annual Cost
Node-RED
Free
N/A
$0
Grafana OSS
Free
Grafana Cloud: $49/mo
$588
ThingsBoard CE
Free
ThingsBoard Cloud: $100/mo
$1,200
Custom Dev
Free
AWS hosting: $50/mo
$15,000 (dev time)
Migration Path (Real-World Progression):
Phase 1: Prototype (Week 1) → Node-RED (2 hours to first dashboard)
Common Mistake: Choosing Tools Based on Features, Not Constraints
The Mistake: A startup selects ThingsBoard for their IoT dashboard because it has “the most features” (device management, rule engine, widgets), ignoring that their team has zero Java experience and their 2-week deadline makes the 16-hour learning curve impossible.
Week 2: Still struggling with rule engine, no working dashboard
Demo day: Show incomplete prototype, lose investor confidence
Result: Project delayed 6 weeks, lost funding opportunity
Right Choice: Node-RED
Day 1 (2 hours): Working dashboard with 5 sensors
Day 2-3: Polish UI, add features
Day 4-10: Integrate remaining sensors, test
Demo day: Polished, working prototype
Result: Funding secured, migrate to Grafana in Month 2
Decision Matrix: Constraints Over Features:
Your Constraint
Tool Choice
Reasoning
Timeline: <1 week
Node-RED
Fastest time-to-demo
Team: No web dev experience
Grafana
Point-and-click UI
Budget: $0
Grafana OSS or Node-RED
Self-hosted, free
Scale: >10,000 devices
Grafana Enterprise or Custom
Only options that scale
Unique UX required
Custom development
Off-the-shelf won’t match brand
Example Bad Decisions:
Bad Decision 1: Choosing ThingsBoard for a 10-device home automation project - Why Bad: 99% of features unused, massive overkill - Should Use: Node-RED (perfect fit for small scale)
Bad Decision 2: Choosing Node-RED for 5,000-device industrial monitoring - Why Bad: Won’t scale, no user management, no enterprise alerting - Should Use: Grafana Enterprise (built for scale)
Bad Decision 3: Building custom dashboard for standard time-series monitoring - Why Bad: 200+ dev hours to replicate what Grafana does out-of-box - Should Use: Grafana (solves 95% of requirements in 4 hours)
The Fix: Constraint-Based Selection:
Step 1: List YOUR Constraints
Timeline: 2 weeks
Team Skills: JavaScript (yes), Java (no), Python (yes)
Budget: $0 for first 3 months
Scale: 50 devices now, 500 in 6 months
Features Needed: Time-series charts, alerting to Slack
Features Nice-to-Have: Device management, mobile app
Practice: Hands-On Labs - Building dashboards with Chart.js and ESP32
Contrast with: Off-the-shelf tools (Grafana, ThingsBoard, quick setup) vs. custom development (D3.js, Plotly, maximum flexibility but higher complexity)
See Also
InfluxDB - Time-series database commonly paired with Grafana