Lorenzo Scavarda in Discussions
上次活动时间: 2023-7-24

Good morning, I am working on a smart garden project with an Arduino MKR WIFI 1010 and I am using Thingspeak as dashboard for monitoring some quantities (e.g. temperature, humidity, moisture, etc.). However, I would like to add a widget in order to change the state of my relay connected to the waterpump, for example if the variable "waterpump_state" is 0 turn off the pump, otherwise turning on. Do you think is it possible to implement it on Thingspeak? Among the predefined widget I have not found any useful in this sense. Thanks in advance, Lorenzo widget to control a Relay Totally possible. You can build the button in a private plugin, using the plugins app. Here is sample javascript. function loadXMLDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { // Typical action to be performed when the document is ready: document.getElementById("demo").innerHTML = xhttp.responseText; } }; xhttp.open("GET", "https://api.thingspeak.com/update?api_key=Y0A92ZT5UMPKK3N1&field1=36&field2=255&field3=250&field4=254&field5=0&field6=3600&field7=0&field8=9", true); xhttp.send(); } function loadXMLDocOff() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { // Typical action to be performed when the document is ready: document.getElementById("demo").innerHTML = xhttp.responseText; } }; xhttp.open("GET", "https://api.thingspeak.com/update?api_key=Y0A92ZT5UMPKK3N1&field1=0&field2=0&field3=0&field4=20&field5=0&field6=3600&field7=0&field8=9", true); xhttp.send(); } </script> with this very simple html section <html> <head> <!-- NOTE: This plugin will not be visible on public views of a channel. If you intend to make your channel public, consider using the MATLAB Visualization App to create your visualizations. --> </head> <body> <div id="demo"></div> <div id="button"><button type="button" onclick="loadXMLDoc()">Lights On</button> </div> <div id="offbutton"><button type="button" onclick="loadXMLDocOff()">Lights Off</button> </div> </body> </html> smart garden arduino waterpump

关于 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.