to calculate the high and low temperatures and write to another channel | MATLAB IoT Analytics | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
to calculate the high and low temperatures and write to another channel
No permission to create posts
April 25, 2020
6:32 pm
Avatar
Prethorian
Madrid, Spain
New Member
Members
Forum Posts: 3
Member Since:
April 25, 2020
sp_UserOfflineSmall Offline

Buenos d铆as,

al crear un nuevo MATLAB y descomentar la l铆nea thingSpeakWrite(writeChannelID,maxTempF,'timestamp',timeMaxTemp,'WriteKey',writeAPIKey);

Me sale este error:

Maximum Temperature for the past 24 hours is =

26.9000

Minimum Temperature for the past 24 hours is =

11.8000

Note: To write data to another channel, assign the write channel ID
andAPI Key to 'writeChannelID' and 'writeAPIKey' variables. Also
uncomment the line of code containing 'thingSpeakWrite'
(remove '%' sign at the beginning of the line.)Error using Calcular altas y bajas temperaturas (line 54)
Incorrect write API key. Make sure the Channel ID and the corresponding write API key are correct.

驴D贸nde tengo el error?

Un saludo.

April 26, 2020
8:18 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Can you check your channel ID and API key? Be sure you are using the Write API key not the User API key, read key, MQTT api key, or alerts key. 馃檪

April 28, 2020
10:54 am
Avatar
Prethorian
Madrid, Spain
New Member
Members
Forum Posts: 3
Member Since:
April 25, 2020
sp_UserOfflineSmall Offline

Hola CSTAPELS,

he verificado lo que comentas y si pongo bien las ID, mira el c贸digo:

% Read temperature data from a ThingSpeak channel over the past 24 hours
% to calculate the high and low temperatures and write to another channel.

% Channel 12397 contains data from the MathWorks Weather Station, located
% in Natick, Massachusetts. The data is collected once every minute. Field
% 4 contains temperature data.

% Channel ID to read data from
readChannelID = 104****;
% Temperature Field ID
TemperatureFieldID = 1;

% Channel Read API Key
% If your channel is private, then enter the read API Key between the '' below:
readAPIKey = '';

% Read temperature data for the last 24 hours from the MathWorks weather
% station channel. Learn more about the thingSpeakRead function by going to
% the Documentation tab on the right side pane of this page.

[tempF,timeStamp] = thingSpeakRead(readChannelID,'Fields',TemperatureFieldID, ...
'numDays',1,'ReadKey',readAPIKey);

% Calculate the maximum and minimum temperatures
[maxTempF,maxTempIndex] = max(tempF);
[minTempF,minTempIndex] = min(tempF);

% Select the timestamps at which the maximum and minimum temperatures were measured
timeMaxTemp = timeStamp(maxTempIndex);
timeMinTemp = timeStamp(minTempIndex);

display(maxTempF,'Maximum Temperature for the past 24 hours is');
display(minTempF,'Minimum Temperature for the past 24 hours is');

fprintf(['Note: To write data to another channel, assign the write channel ID
',...
'andAPI Key to ''writeChannelID'' and ''writeAPIKey'' variables. Also
',...
'uncomment the line of code containing ''thingSpeakWrite''
',...
'(remove ''%%'' sign at the beginning of the line.)']);

% To store the maximum temperature, write it to a channel other than
% the one used for reading data. To write to a channel, assign the write
% channel ID to the 'writeChannelID' variable, and the write API Key to the
% 'writeAPIKey' variable below. Find the write API Key in the right side pane
% of this page.

% Replace the [] with channel ID to write data to:
writeChannelID = 8;
% Enter the Write API Key between the '' below:
writeAPIKey = 'KFKAM5WX********';

% Learn more about the thingSpeakWrite function by going to the Documentation tab on
% the right side pane of this page.

thingSpeakWrite(writeChannelID,maxTempF,'timestamp',timeMaxTemp,'WriteKey',writeAPIKey);

Me sigue mostrando el error:

Maximum Temperature for the past 24 hours is =
24.6000
Minimum Temperature for the past 24 hours is =
8.5000

Note: To write data to another channel, assign the write channel ID
andAPI Key to 'writeChannelID' and 'writeAPIKey' variables. Also
uncomment the line of code containing 'thingSpeakWrite'
(remove '%' sign at the beginning of the line.)Error using Calculate high and low temperatures 7 (line 54)
Incorrect write API key. Make sure the Channel ID and the corresponding write API key are correct.

April 28, 2020
4:43 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

I suspect the issue is
writeChannelID = 8;
if you have channel id 8, you must have gotten that channel back in 2016. My lowest channel is in the 200k range. Check the channel id.
Verifica tu ID de canal?

April 28, 2020
5:04 pm
Avatar
Prethorian
Madrid, Spain
New Member
Members
Forum Posts: 3
Member Since:
April 25, 2020
sp_UserOfflineSmall Offline

Perd贸n,

me he equivocado al poner el ID de canal, Una pregunta, dentro de MATLAB Analysis donde el c贸digo a la derecha hay una pesta帽a que pone "Nuevo canal" lo he creado y he colocado la APiWrite y ID de canal en el c贸digo y ahora si me deja guarda. 驴...? La pregunta es si no se puede publicar la temperatura max/min dentro del mismo canal donde se muestra la temperatura junto con el resto de datos de humedad etc...?

Un saludo

May 27, 2020
10:57 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline
Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

khanhNguyen_CT, susyburr, quijano__, meosuckhoe, briskpanda, Dejw0089

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457