Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoT_Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
robert.sharp
IoT_Project
Commits
250bdc6c
Commit
250bdc6c
authored
Jan 11, 2022
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload Matlab Analysis Code
parent
42c82d24
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
MatlabAnalysis.txt
ExtraCode/MatlabAnalysis.txt
+44
-0
No files found.
ExtraCode/MatlabAnalysis.txt
0 → 100644
View file @
250bdc6c
% Store the channel ID for the moisture sensor channel.
channelID = 1563035;
% Provide the ThingSpeak alerts API key. All alerts API keys start with TAK.
alertApiKey = 'TAK66YQB9950YAY8WB7NM';
% 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("Air Pollution information");
% Read the recent data.
pollData = thingSpeakRead(channelID,'NumDays',30,'Fields',1);
% Check to make sure the data was read correctly from the channel.
if isempty(pollData)
alertBody = ' No data read from sensor. ';
else
% Get the most recent point in the array of moisture data.
lastValue = pollData(end);
% Set the outgoing message
if (lastValue>=50 & lastValue < 150)
alertBody = ' Warning: pollution in your area is above a normal level. ';
try
webwrite(alertUrl, "body", alertBody, "subject", alertSubject, options);
catch someException
fprintf("Failed to send alert%s\n",someException.message);
end
end
if (lastValue > 150)
alertBody = ' Warning: pollution in your area is above a toxic level. ';
try
webwrite(alertUrl, "body", alertBody, "subject", alertSubject, options);
catch someException
fprintf("Failed to send alert%s\n",someException.message);
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment