I am trying to analyse the heating in my house, in which I have 12 thermostats. I am keen to understand better the relationship of heating in each room between the set point and how often and how long the thermostat has to call for heat to get the room to a specific temperature, or heat the room by 1 degree
To start off, I was hoping to be able to plot the temperature of a thermostat in degrees as a line, vs the setpoint of the thermostats as a step line, vs whether the stat is calling for heat, as a bar chart of either zero or one.
My first issue is getting the temp and set point on the same graph with the set point being a stepped line, ie not a sloping line between points. Is this possible, or do I need to generate the missing values, as the channel only records values when it changes.
Then, how would I change the "On" or "Off" values on the heating field to a 0 or 1 to then plot, and can I do line vs column on the same chart?
I am hoping this would be a useful example for others once I can get this working, and then I keen to learn from others what they do. ie I would love to calculate the number of hours per day that each room is calling for heat (and the total) and plot vs outside temperature / humidity / wind etc.
"I was hoping to be able to plot the temperature of a thermostat in degrees as a line, vs the setpoint of the thermostats as a step line"
Yes it is possible to create a step line type visualization using the MATLAB Visualizations app and the MATLAB visualization function 'stairs'. For more information and examples, please see the following documentation page: http://www.mathworks.com/help/matlab/ref/stairs.html
"how would I change the "On" or "Off" values on the heating field to a 0 or 1"
One method of achieving this task is writing to the Channel's "status" field ('on' or 'off') or to one of the other 7 channel fields (0 or 1). For more information on how to update a Channel feed, see the following documentation page: https://thingspeak.com/docs/channels#update_feed
"can I do line vs column on the same chart"
Yes it is possible to overlay different forms of visualizations on the same plot or figure. Again, using the MATLAB Visualization app, the following MATLAB Code will produce a bar chart with a line chart overlaid on top.
% Retain current plot when adding new plots.
Note that the '%' symbol is used to add comments to MATLAB code (http://www.mathworks.com/help/matlab/matlab_prog/comments.html)
1. bar: http://www.mathworks.com/help/matlab/ref/bar.html
2. hold: http://www.mathworks.com/help/matlab/ref/hold.html
3. plot: http://www.mathworks.com/help/matlab/ref/plot.html
Thanks for all this. It took me a while to realise I could just enter the matlab code as I would the thingspeak functions, as thats not clear in the documentation.
However I get an error when using the stairs function of Input arguments must be numeric. I guess it doesnt like the date values?
This is the code.
readChannelID = 64586;
fieldID1 = 1;
fieldID2 = 2;
[data1, time1] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumDays',5);
[data2, time2] = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumDays',5);
Also, if I use thingSpeakPlot(time2, data2) I get a proper chart, but it doesnt plot the values if I use plot(time2, data2). Is there a known reason for this, do the functions behave differently??
"However I get an error when using the stairs function of Input arguments must be numeric. I guess it doesnt like the date values?"
Yes, that is correct. According to the 'stairs' documentation, the X and Y input arguments must be numeric values of type "Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical" (http://www.mathworks.com/help/matlab/ref/stairs.html?searchHighlight=stairs#inputarg_X)
With additional MATLAB Code, it is possible to convert the MATLAB DateTime object returned by the MATLAB function 'thingSpeakRead' to a numeric value, and have the X or Y Axes label formatted to display a date string.
It is possible to convert a DateTime object to a numeric value using the MATLAB Function 'datenum'
Once the figure is plotted, it is possible to change the formatting of the X or Y Axes label using the MATLAB Function 'datetick'
Note that the MATLAB function accepts a 'dateformat' string as the second argument. Please refer to the the documentation section for more information:
[data, time] = thingSpeakRead(id, 'Field', field, 'NumPoints', 5);
"I use thingSpeakPlot(time2, data2) I get a proper chart, but it doesnt plot the values if I use plot(time2, data2)"
The interactive ThingSpeak plotting functions such as 'thingSpeakPlot' are incompatible with the static MATLAB plots such as 'plot' or 'stairs' and cannot be combined. Please refer to the 'Troubleshooting' section of the documentation: https://thingspeak.com/docs/troubleshooting
Thanks. Its taken a while, as using datenum on the time argument for my first data set worked, but it was the second I wanted to plot as stairs and this still didnt work.
The first has many more data points than the second, hence wanting to plot the second as stairs, and I assumed that this would work.
However in the end I had to read the original 2nd series, use the matlab analysis to clean up and remove all the nulls from that series and write to a new channel. Reading that channel in to the visualisation for the step line on top of the line plot from the original channel works well.
Now to work out how to do the On/Off conversion which I think I will also have to clean up and then write to a new channel as well as converting to 0,1
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Administrators: Hans, lee