Risultati per
% Sample data from channels
channel1Data = 2226948; % Your data for channel 1
% Threshold values for each alert level
threshold1 = 100;
threshold2 = 200;
threshold3 = 300;
% Initialize alert level to 0 (no alert)
alertLevel = 0;
% Check thresholds and determine alert level
if channel1Data >= threshold1 && channel1Data <= threshold2
    alertLevel = 1; % Yellow Alert
elseif channel1Data >= threshold2 && channel1Data <= threshold3
    alertLevel = 2; % Orange Alert
elseif channel1Data >= threshold3
    alertLevel = 3; % Red Alert
end
% Define alert message based on alert level
if alertLevel == 1
    alertMessage = 'Threshold exceeded for channel 1!';
elseif alertLevel == 2
    alertMessage = 'Threshold exceeded for channel 2!';
elseif alertLevel == 3
    alertMessage = 'Threshold exceeded for channel 3!';
else
    alertMessage = 'No alert for channel 1.';
end
% Call SMS integration function with the alert message
sendMessage('+639319217695', alertMessage);
function sendMessage(number, message)
    % Replace with your SMS service API endpoint and API key
    apiUrl = 'https://api.semaphore.co/api/v4/messages';
    apiKey = '-----';
    % Compose the message payload
    payload = struct('apikey', apiKey, 'number', number, 'message', message);
    try
        % Send the SMS using the SMS service API
        response = webwrite(apiUrl, payload);
        % Process the response as needed
        disp('SMS sent successfully');
    catch
        disp('Error sending SMS');
    end
end
