Jonas Meier in MATLAB Answers
Última actividad el 23 de Feb. de 2024

Dear all, once per month I want to send an email with selected data from thingspeak. TimeControl only offers up to weekly but not monthly. Do you have Tipps?
guy caluwaerts in Discussions
Última actividad el 21 de Dic. de 2023

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 : One daily email with the actual level 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 Send email with the value of a channel MATLAB is case sensitive. alert_body is not equal to alert_Body Be careful with daily emails, you are limited to 800 yearly alert emails. (but there are enough for one per day or more) Your code example shows how to put a channel value in the email. 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); This will make the subject equal to the value from field 1 Hi Christopher, I did the notification and don't receive no errors anymore. Unfortunately I also don't receive the emails in my mailbox. % 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); % Set the outgoing message try webwrite(alertUrl , "body", alertBody, "subject", alertSubject,'Fields',peil); end Check your junk folder and make sure you arent blocking thingspeak.com at your email server. You can also take the try ..end.. syntax off, and remove the semicolon on the webwrite line to test and make sure the command was sent. What do you mean with junk folder ? When I do save and run I receive 2 messages. MATLAB code ran successfully. Failed to send alert: The server returned the status 401 with message "" in response to the request to URL https://api.thingspeak.com/alerts/send. 401 means unauthorized. Check your alerts api key. By junk folder i menat for email, but its clear its not sending. I copy past het API key again but no result. does the api key begin with TAK? yes. I use the alertapikey alertApiKey = 'TAKMAxjn5Ad1TrzrNWH'; I also renewed already the key, but no result. You are forgetting the options when you webwrite. Thats why its 401 unauthorized. No key included with the requiest. webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); webwrite(alertUrl , "body", alertBody, "subject", alertSubject, peil, options); doesn't work webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); Was sending an email once, but without the value of channel 1 Afterwards I received the message when I run the app : "Failed to send alert: Each postName must be given a corresponding postValue." where can I find the documentation about sending information by email ? All the examples I can find only describe the software for the arduino or esp8266/32 https://www.mathworks.com/help/thingspeak/alerts-api.html and https://www.mathworks.com/help/thingspeak/sendalert.html I reccomend you start with the example code and try to modify it one part at a a time. This example is independant of the devece. I would start here. https://www.mathworks.com/help/thingspeak/analyze-channel-data-to-send-email.html My soil moisture cannel doesnt have good data anymore, but you can tie it to the traffic 38629 or weather 12397 channels at ThingSpeak for testing. In the example, you can add the moisture data to the alert body variable to bet information sent to you. I started from these exemples and could send emails but after I tried to include to value of channel 1, I don't receive emails anymore and receive error messages when I run the timecontrol app without to make any changes. I still struggle with my originale question how to include the value of a channel in the body of the email. Christopher, I followed this example. You only send an email with text. I want to send text + the last value from channel 1. What is working for the moment: 1. sending text with : alertBody = 'huidig peil regenput :'; 2. Sending value of channel 1 : alertBody = thingSpeakRead(channelID,'Field',1); What is not working is the combination of both. It must be something like this, but this syntax is not accepted : alertBody = ('huidig peil regenput :' ,thingSpeakRead(channelID,'Field',1)); try seperating the actions. bob = thingSpeakRead(channelID,'Field',1)); % assumes data is numeric, otherwise use 'outputformat','timetable' alertBody = "The value of my field is " + bob; email timecontrol
vladimir gershman in MATLAB Answers
Última actividad el 7 de Nov. de 2023

Hi, TimeControl App allows sending email on a givent interval. Can i send email as soon as i see a change in my data channel? for example if a voltage is exceeded, can i send out email right away?
Danielle Honigstein in MATLAB Answers
Última actividad el 27 de Abr. de 2023

Hi all, I have configured React to send an email when I receive data to my channel. My channel recieves data occasionally from an Android app, once every 15 minutes for the space of some hours. Usually this works fine, but occasionally I do not recieve an email. I see that the app sent the data to the channel correctly and received a reply. The React shows that the code sending the email was run without errors (showing the green checkmark and showing last run 1 minute ago). As it was 15 minutes since the last request, it shouldn't cause the 429 error (too many requests). How can I find what the problem was? The email was not received. Thanks, Danielle
Nicolás Duque Suarez in MATLAB Answers
Última actividad el 17 de Sept. de 2020

Hello everybody, I'm currently usng Thingspeak to log Temperature, pressure and humidity data form some sensors. I want to send an email to my dad when the average of the last 10 of these values are above certain thresholds, but i haven't been able to find how to send them through the MATLAB Analysis app, because I understand that the alert utilty can only send the info to the email account that owns the channel. IS there any way to do what i want possible? Thanks in advance, Nicolás.
Benjamin Cortez in MATLAB Answers
Última actividad el 14 de Ag. de 2020

Hey, just a simple question that I cant find the answer :( How do I break lines in MATLAB emails?? I tried with <br> and \n. This is an screenshot of what I'm talking about And the String is: alertBody = "El sistema de monitoreo no ha obtenido ningun dato del Arduino en los ultimos 10 minutos.<br> Se recomienda verificar el dispositivo para su correcto funcionamiento.<br><br>\n\n\n1. Verifique que el Arduino esté con corriente<br>2. Verifique que la conexión Ethernet esté correcta y las luces esten encendidas.<br>3. Si ninguna de estas opciones solucionó el problema, presione el botón rojo ubicado en el Arduino<br>Canal de Información: https://thingspeak.com/channels/970650"; I appreciate any help, thanks and have a nice day!
Dale Lamb in MATLAB Answers
Última actividad el 25 de Mzo. de 2020

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?
Mei Sing Wang in MATLAB Answers
Última actividad el 9 de Mzo. de 2020

I follow the instruction in https://www.mathworks.com/help/thingspeak/analyze-channel-data-to-send-email.html?s_eid=EML_16314 However it shows that Failed to send alert: Unrecognized function or variable 'alertBody'. Anyone know why it does not recognized 'alertBody'? Below is my code: channelID = 995250; alertApiKey = 'MY_ALERTS_API_KEY'; alertUrl="https://api.thingspeak.com/alerts/send"; options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey ]); alertSubject = sprintf("Surrounding temperature and humidity"); moistureData = thingSpeakRead(channelID,'NumDays',30,'Fields',1); if isempty(moistureData) alertBody = ' No data read from surrounding. '; while humidity < 60 or temperature > 32: alertBody = sprintf(" The weather is too hot! ", "The temperature is %0.2f",temp) ; end end try webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); catch someException fprintf("Failed to send alert: %s\n", someException.message); end

Acerca de 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.