4:51 pm

June 16, 2016

Hello Everyone!
I am trying to write a matlab analysis file to calculate the days of battery life remaining on a esp8266 based on the slope of the decreasing battery readings and extrapolate how many days of power are left. I have the code all written and tested (works great!), however displaying a single number or string result in my channel has proved to be a huge pain.
Are any of the following possible to display the information?
- Use thingSpeakWrite to write (string or number) to the status field?
- Use thingSpeakWrite to write to a field, but have the raw text displayed, not interpreted as a number and be graphed?
- Channel the matlab analysis text output to a channel or visualization?
- A visualization that only displays one number? or string?
Does anyone have any example code to do any of these things, as of now im not sure any are possible based on the documentation I have read.
Thanks For your help!
Briscoe
11:43 pm


Gold
October 12, 2015

Hi Briscoe,
If this is of any help ... I hope it is near your last question
1- Apps / MATLAB Visualizations + Green button "New" (create a new visualization) (no analysis no plugin)
2- Custom (no starter code) + Green button "Create" (near page bottom) (so you get a blank box without templates/examples)
3- MATLAB Code box (copy/paste the blue code below) + Green button "Save and Run"
See results in below MATLAB Plot Output box & Output box. I hope you have your results in a field(s) of your channel(s).
Maybe this can be a start point
% ---------------------------------------------
% ---------------------------------------------
% http://www.mathworks.com/help/matlab/ref/annotationtextbox-properties.html
% ---------------------------------------------
currentTemp = thingSpeakRead(58826,'Field',1) % 58826 my public channel
currentHume = thingSpeakRead(58826,'Field',2) % 58826
str={[num2str(currentHume) '%'],[num2str(currentTemp) '°C']};
% --------------------------------------------- izquier
annotation('textbox',[0.0 0.01 0.35 0.99],...
'BackgroundColor','0 1 0',...
'FaceAlpha',0.15,...
'Color','0 1 1',...
'LineWidth',2,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom',...
'LineStyle',':',...
'String',str,...
'FontSize',38); %45
% --------------------------------------------- medio
annotation('textbox',[0.36 0.01 0.19 0.99],...
'BackgroundColor','1 0 1',...
'FaceAlpha',0.15,...
'Color','0 0 1',...
'LineWidth',2,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom',...
'LineStyle',':',...
'String',[num2str(currentHume) '%'],...
'FontSize',20); %25
% --------------------------------------------- ajobadere
annotation('textbox',[0.56 0.01 0.43 0.65],...
'FontName','FixedWidth',...
'BackgroundColor','.2 .3 .5',... % 0 1 1
'FaceAlpha',0.95,...
'LineWidth',2,...
'HorizontalAlignment','right',...
'VerticalAlignment','top',...
'LineStyle',':',...
'Color','.51 .50 1',...
'String',[num2str(currentTemp) '°C'],...
'FontSize',43); %30
% --------------------------------------------- arridere
annotation('textbox',[0.56 0.67 0.43 0.33],...
'FontName','FixedWidth',...
'BackgroundColor','1 1 0',...
'FaceAlpha',0.35,...
'LineWidth',2,...
'HorizontalAlignment','left',...
'VerticalAlignment','middle',...
'LineStyle',':',...
'Color','1 0 1',...
'String',['Otra Cosa'],...
'FontSize',20); %15
% ---------------------------------------------
% ---------------------------------------------
Good luck
Most Users Ever Online: 114
Currently Online:
18 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 261
Vinod: 196
piajola: 85
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 5703
Moderators: 0
Admins: 2
Forum Stats:
Groups: 4
Forums: 17
Topics: 1313
Posts: 4565
Newest Members:
celinabw2, FitoSprayscroma, LunnonGor, lancevl16, bernicenk60, veronicadq18Administrators: Hans: 387, lee: 457