Contenido principal

Resultados de

I want to control the level my water tank with a esp8266 and Thingspeak.
I can see the level in Thingspeak. This is working.
Now I want to send 2 emails :
  1. One daily email with the actual level
  2. Alarm email when level is below a setpoint.
How can I incorporate the value from a channel in the email ?
What I have now for the daily email , but with errors :
alert_body = 'huidig peil regenput';
channelID = ..........;
% Provide the ThingSpeak alerts API key. All alerts API keys start with TAK.
alertApiKey = 'TAK...............';
% Set the address for the HTTTP call
alertUrl="https://api.thingspeak.com/alerts/send";
% webwrite uses weboptions to add required headers. Alerts needs a ThingSpeak-Alerts-API-Key header.
options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey ]);
% Set the email subject.
alertSubject = sprintf("Niveau regenput " );
% Read the recent data.
peil = thingSpeakRead(channelID,'Fields',1);
% Check to make sure the data was read correctly from the channel.
% Set the outgoing message
webwrite(alertUrl , "body", alertBody, "subject", alertSubject,'Fields',peil);
% Catch errors so the MATLAB code does not disable a TimeControl if it fails
try
webwrite(alertUrl , "body", alert_body, "subject", alertSubject, options);
catch someException
fprintf("Failed to send alert: %s\n", someException.message);
end
The errors I receive :
Unrecognized function or variable 'alert_Body'.
Error in Read Channel to Trigger Email 1 (line 24)
webwrite(alertUrl , "body", alert_Body, "subject", alertSubject,"Fields",peil);
Manny thanks in advance
I am remotely monitoring solar energy. My monitors shut off at night to conserve battery power, ending data being sent to ThingSpeak, which is fine. I do want to be alerted quickly though during the day when data should be coming in. How can I do this? ReAct doesn't have any way to limit when actions will happen and TimeControl doesn't seem to be able to only perform during certain hours either. I've looked for examples where Matlab analysis might perform a task between certain hours but can't seem to find anything. FWIW, an email would be the preferred method of alert.
Joseph
Joseph
Última actividad el 15 de Mayo de 2023

Up until yesterday (May 6, 2023), time controls were working fine in regards to running my Analysis code recurring at specified intervals. Now they will no run more than once? I’ve tried creating new time controls but no luck. I have to manually run the code to get updated results.

Martin
Martin
Última actividad el 19 de Sept. de 2022

Help us please, we need to send email after measurement from sonde (GSM report) is under limit for three days.
"React" on the limit, is non for three days under limit., and time control is days or weeks runner.
I propose trigger on time control but what is the code?
????
% Read the recent data.
moistureData = thingSpeakRead(channelID,'NumDays',3,'Fields',1); {is that right, that I read last three days measurement (3000x)?}
% Check to make sure the data was read correctly from the channel.
if isempty(moistureData)
alertBody = ' No data read from plant. ';
else
%{need if
% moistureData is for three days under limit from sonde then send
% email}
span = max(moistureData) - min(moistureData);
dryValue = span;
% Get the most recent point in the array of moisture data.
lastValue = moistureData(end);
% Set the outgoing message
if (lastValue<=dryValue)
alertBody = ' I need water! ';
elseif (lastValue>dryValue)
alertBody = ' No water needed. ';
end
really thanks so much