Part 2: Creating Individual Diagrams with MATLAB Visualization

By | 1. June 2019

Individual graphical displays can be generated using predefined examples or generically, assuming basic knowledge of programming with MATLAB.

In principle, the data is read in using readAPIKey, ChannelID and FieldID, then edited if necessary and finally visualized with the plot command, for example.

Click on the “Save and Run” button to execute the code and generate the output in the “MATLAB Plot Output” area. Any error messages are displayed in the “Output from last evaluation” area. In the “Display Settings” area, you can specify whether the visualization should be displayed in the private or public area, or not at all.

Under Apps -> All Apps -> MATLAB Visualizations all visualizations are listed and can be managed from here.

In the following I present a few examples, which I find quite informative. I also provide the MATLAB source code, in which only the variables readAPIKey, ChannelID and FieldID have to be adapted.

A step-by-step guide can be found below.

Weight of the last 3 days

This diagram shows the superimposed daily weight curves of the last 3 days.

On traditional days when the bees are collecting honey it is especially nice to see at which time the bee flight begins and ends, how the weight decreases in the morning and increases again in the course of the day, how the weight is higher in the evening than in the morning, and how the weight slowly decreases again at night. The intensity of these phases is, of course, strongly dependent on the weather and the conditions of the nectar sources. On days without nectar sources the consumption can be observed.

Daily weight change

Most beekeepers are interested in how much honey their diligent bees have collected. A simple bar chart shows the daily weight gain or loss.

Remarks on the algorithm

One can discuss how best to determine the displayed values. In this Matlab code, a weight is calculated for each day and the difference to the weight of the previous day (derivation) is displayed as a bar.

The exciting question is which is the best method to determine the weight of a day:

  • Perhaps the simplest method is a maximum selection. However, this is very susceptible to outliers – they are 100% effective.
  • The mean value or median of the measured values of a day seems to be more suitable at first glance. However, since the weight of the bees flying out can amount to 1 kg, this effect falsifies the weight value clearly, above all if the bee’s flight from day to day is different in intensity and duration due to weather conditions.
  • The most plausible results are obtained by evaluating the time period after the bee flight ends in the evening. With a measuring interval of 15 minutes, the last 10 measured values can be used and the mean value can be calculated.

The total weight change is determined using the sum of the daily values.

Outdoor temperature and weight today

This display is suitable for detecting desired and unwanted (tempearature drift!) correlations between temperature and weight.

The correlation between temperature and honey yield flight is obvious and interesting to follow.

If, however, a contrary correlation between temperature and weight can be observed on days without bee flight, then an undesirable, possibly uncompensated falsification of the measured weight by the temperature is probably present. If this occurs despite activated and calibrated temperature compensation, the temperature sensor may be installed in an unfavourable position for this purpose.

Outdoor temperature and weight (long-term)

The display of outside temperature and weight over a longer period of time, e.g. over two months, also provides interesting insights.

The honey yield phases and honey yield gaps or periods of bad weather are clearly visible.

Min/Max temperature and weight

In this diagram, the daily maximum and minimum temperature values and the maximum weight value are plotted over a longer period of time. In a way, this is a simplified and clearer representation of the long-term representation described above.

Step-by-step instructions

How to create an individual visualization in ThingSpeak based on one of the templates listed above:

  1. Press the “MATLAB Visualization” button.
  2. Select template “Custom (no starter code)
  3. Copying code from the attachments into it
  4. Enter your individual ChannelID, readAPIKey and FieldIDs (see right under Channel Info)
  5. Press the “Save and Run” button and observe whether the graphic is structured as desired, note the error message if necessary.
  6. Modify at will to display what you want to see
  7. Publish plot: Activate “Create a public URL”, select “Add/Edit view on a channel” and place a tick at “Public View”.

Now the plot should appear on your public ThingSpeak Channel.

Translated 19.10.2019 by JK

Print Friendly, PDF & Email

3 thoughts on “Part 2: Creating Individual Diagrams with MATLAB Visualization

  1. aseufert

    super Anleitung mit sehr guten Beispielen. gute Arbeit.
    Hätte aber noch eine Frage:
    Hast du eine Idee wie man im Beispiel “Gewicht der letzten 3 Tage”
    für die x-ACHSE alle 3h eine Achsenbeschriftung bekommt?
    Der folgende zusätzlocje code funktioniert nicht:

    xlim([0 24]);

    für die Y-Achse funktioniert diese Schema für die X-Achse leider nicht.
    Es kommt eine Fehlermeldung das ein zweikomplement erwartet wird… ?

    1. Johannes Post author

      Füge folgenden Code ein:

      tstart = datetime(year(timeStamps_Day3(1)),...
      tend = datetime(year(timeStamps_Day1(1)),...


Leave a Reply

Your email address will not be published. Required fields are marked *