Mohd Shahzrie in MATLAB Answers
上次活动时间: 2021-12-5

% Store the channel ID for the sensors channel. channelID = 1517893; % Provide the ThingSpeak alerts API key. All alerts API keys start with TAK. alertApiKey = 'TAKQXKX7Xxxxxxxxxxx'; % 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("Weather Monitoring System Update"); % Read the recent data. temperatureData = thingSpeakRead(channelID,'NumDays',1,'Fields',1); humidityData = thingSpeakRead(channelID,'NumDays',1,'Fields',2); % Check to make sure the data was read correctly from the channel. if temperatureData > 27 & humidityData < 80 fprintf("Sunny day \n") alertBody = "The temperature is above 27°C while the humidity is below 75% which indicates that today is probably gonna be a sunny day."; elseif temperatureData < 27 & humidityData > 80 fprintf("Rainy day \n") alertBody = "The temperature is below 27°C while the humidity is above 75% which indicates that rain is likely to be coming."; elseif temperatureData < 27 & humidityData < 80 fprintf("Forecast \n") alertBody = "The temperature is below 27°C while the humidity is below 75% which indicates that there's a high chance of the weather being overcast"; elseif temperatureData > 27 & humidityData > 80 fprintf("Sunshower \n") alertBody = "The temperature is above 27°C while the humidity is above 75% which indicates that there will probably be a rare weather occurence which is sunshower"; else alertBody = "No data read for today's weather." end % Catch errors so the MATLAB code does not disable a TimeControl if it fails try webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); catch someException fprintf("Failed to send alert: %s\n", someException.message); end
Dale Lamb in MATLAB Answers
上次活动时间: 2020-3-25

I was able to send a ThingTweet from my Laptop to my Twitter account, and I see the message in my Twitter profile page, but I would like an email notification. Would there be any reason the ThingTweet message was prevented from providing the email notification?

关于 ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.