hello good I have problems receiving mail from thingspeak,
I receive data from a temp sensor and I have configured a reaction for when it exceeds 28 degrees send an email and it does not arrive
alert_body = 'SENSOR DE TEMPERATURA ISSCHILE';
alert_subject = 'Temperatura Elevada';
alert_api_key = 'TAK************';
alert_url= "https://api.thingspeak.com/alerts/send";
jsonmessage = sprintf(['{"subject": "%s", "body": "%s"}'], alert_subject,alert_body);
options = weboptions("HeaderFields", {'Thingspeak-Alerts-API-Key', alert_api_key; 'Content-Type','application/json'});
%result = webwrite(alert_url, jsonmessage, options);

댓글 수: 6

Rohit Anand
Rohit Anand 2020년 7월 14일
  1. You should never share your API keys on a public platform.
  2. I have noticed that you have commented out the last line of your code. Please uncomment and then try running the script. It should work just fine.
Antonio Palma
Antonio Palma 2020년 7월 14일
thanks, I already generated a new API code for security, the code works well but I don't get emails
Antonio Palma
Antonio Palma 2020년 7월 14일
configure this reaction to send the mail but they do not arrive
Name:React 1
Condition Type:Numeric
Test Frequency:On data insertion
Last Ran:2020-07-14 12:16
Channel:Sensor
Condition:Field 1 (Temperatura) is greater than or equal to 28
MATLAB Analysis:Sensor TEMP
Run:Each time the condition is met
Created:2020-07-14 12:12 pm
Antonio Palma
Antonio Palma 2020년 7월 14일
I ran it and I get this error
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 396)
The server returned the status 429 with message "Too Many Requests" in response to the request to URL https://api.thingspeak.com/alerts/send.
Error in readContentFromWebService (line 46)
byteArray = copyContentToByteArray(connection);
Error in webwrite (line 139)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
Error in Sensor TEMP (line 10)
result = webwrite(alert_url, jsonmessage, options);
Rohit Anand
Rohit Anand 2020년 7월 14일
You are making your thingspeak requests too quickly. Bulk requests should not be any less than 15 seconds apart, and if your bulk request is large then you might have to wait extra time.
Check out this answer for reference...
This looks similar to your issue.
Is the email is being sent from a loop? Try using pause() function to produce delay in between the requests.
Vinod
Vinod 2020년 7월 14일
The error message explicitly points to the problem "The server returned the status 429 with message "Too Many Requests" in response to the request to URL https://api.thingspeak.com/alerts/send." Please refer to the documentation of the API.

댓글을 달려면 로그인하십시오.

답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2020년 7월 14일

편집:

2020년 7월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by