IoT Dashboard Integration with ThingSpeak

 What I set out to do 

After finishing the Simulink model, the next phase was the IoT integration. The project title is an IoT-based wind energy monitoring system, so connecting the simulation to a real cloud dashboard was a deliverable, not optional. The goal is to get live turbine data transmitting from MATLAB to ThingSpeak and displaying on a dashboard that anyone could view remotely.

Why ThingSpeak

The first decision was choosing which IoT platform to use. Some of the options I considered were:
  • ThingSpeak (MathWorks) – built into the MATLAB ecosystem, free to use, no extra setup.
  • Grafana – more powerful, but requires a local server or paid hosting
  • AWS IoT Core – professional grade but too much for a simulation project.
ThingSpeak was the most sensible choice. It's made by MathWorks, the same company as MATLAB, so there's a built-in toolbox that handles the connection without any web programming. Since the entire project was already in MATLAB, adding an IoT link meant writing 15 lines of code rathat than getting involved with a completely new platform.

Setting up the ThingSpeak Channel

The channel was set up at thingspeak.com with six fields mapping directly to the MATLAB simulation outputs:
  • Field 1: Turbine 1 Power (W)
  • Field 2: Turbine 2 Power(W)
  • Field 3: Turbine 3 Power(W)
  • Field 4: Turbine 4 power(W)
  • Field 5: Total grid power(W)
  • Field 6: Stability Metric


The one-to-one mapping between MATLAB variables and ThingSpeak fields was deliberate. It meant the dashboard directly reflected the simulation output without any intermediate processing, making it easier to verify that what was transmitted matched what MATLAB calculated.

Writing the Transmission Script

The data transmission script (thingspeak_upload.m) runs a loop that:
  • Takes the base turbine power values (1.8, 2.3, 1.5, 2.6W)
  • Adds small Gaussian noise to simulate live wind fluctuation
  • Calculated the total grid power by summing all four turbines
  • Calculates the stability metric using the same gain factor of 12 as the Simulink model
  • Writes all six values to the ThingSpeak channel in a single call

A few decisions I made:

Why Gaussian noise? The same noise model was used in the multi-turbine MATLAB code. Using it here keeps the ThingSpeak data consistent with the simulation - the values fluctuate realistically around the base turbine outputs.

Why pause(20)? ThingSpeak's free tier enforces a minimum 15-second interval between writes. Setting it to 20 seconds gives a small buffer to prevent rate limit problems.

Why a Gain factor of 12? The stability metric sent to ThingSpeak uses the same calculation as the Simulink Gain block. This means the value on the dashboard (around 98.4 for nominal conditions) is directly comparable to what the Simulink model displays - an important consistency check across all three implementations.

Problems I ran into

Rate limit error - The first time I ran the ThingSpeak code, I got an error saying that the requests were too frequent. This was because I had initially set the pause to 16 seconds. Increasing it to 20 fixed it.

Fields format error -  The ThingSpeakWrite function showed an error about the Fields variable needing to be a numeric vector. I fixed it by changing {1,2,3,4,5,6} to [1,2,3,4,5,6]. Curly brackets create a cell array, and square brackets create numeric arrays and the function required numeric.

These were both fixed quite easily but deserved to be documented anyway, as they show the kind of debugging that happens in real IoT integration work.

What the Dashboard Shows

Once the script was running, the ThingSpeak channel updated every 20 seconds with live data from all six fields. The Total Grid Power field fluctuates around 8.2W as expected. The stability metric stays around 98.4, consistent with the Simulink model and MATLAB advanced analysis results.


Connecting Everything Together

One of the things this phase made me realise is how well the three implementations cross-validate each other:
  • MATLAB calculates: total = 8.2W, stability = 98.4
  • Simulink displays: 8.2W and 98.4 on its display blocks
  • ThingSpeak receives values around 8.2W and 98.4 every 20 seconds
All three agree. That consistency across three different tools - Code, block diagram and the IoT Dashboard - is the strongest evidence that the analytical approach is working.


Connection to Research Problems

The ThingSpeak dashboard directly addresses the third research problem – system inefficiency from uncoordinated operation. A live remote dashboard means operators no longer need to be physically present to monitor the farms. Any underperforming turbine shows up as a lower value in its individual chart, and the total grid power field gives instant visibility of total system performance.


































Comments

Popular posts from this blog

MATLAB Coding and Initial Data Analysis

Week 1: Project Overview

Advanced Multi-Turbine Analysis - Methodology and Differentiation from Existing Solutions