{"id":1668,"date":"2018-05-09T18:32:20","date_gmt":"2018-05-09T18:32:20","guid":{"rendered":"http:\/\/easycoding.tn\/?page_id=1668"},"modified":"2020-06-05T17:11:14","modified_gmt":"2020-06-05T16:11:14","slug":"web-services","status":"publish","type":"page","link":"http:\/\/easycoding.tn\/index.php\/nodemcu\/tuniot-documentation\/iot\/web-services\/","title":{"rendered":"Web services"},"content":{"rendered":"<ul>\n<li><strong>MQTT Connect<\/strong>:<br \/>\nConnect to an MQTT broker. The server could be local or remote.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2072\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/MQTT_Connect.jpg\" alt=\"\" width=\"199\" height=\"95\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=v6pcccSWl5s\" target=\"_blank\" rel=\"noopener\">Communication between 2 ESP8266 boards with MQTT<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>MQTT Loop<\/strong>:<br \/>\nAllows to the client to process the incoming data. You should put it in the mail loop.&gt;<br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><\/li>\n<\/ul>\n<ul>\n<li><strong>MQTT Publish<\/strong>:<br \/>\nSend a message to the broker under the provided topic.\u00a0 The sent message in provided into a variable.<br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>MQTT Subscribe to a topic<\/strong>:<br \/>\nIt means that the client is asking the broker to send him a message of any client publishing messages under that topic.<br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=v6pcccSWl5s\" target=\"_blank\" rel=\"noopener\">Communication between 2 ESP8266 boards with MQTT<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Function MQTT connect to server<\/strong>:<br \/>\nThis function should be called when you use the MQTT operations. It will show you the connection status the the provided server.\u00a0 Once the board is connected, it is possible to subscribe to a topic.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2070\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/MQTT_Connect_Function.jpg\" alt=\"\" width=\"200\" height=\"59\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=v6pcccSWl5s\" target=\"_blank\" rel=\"noopener\">Communication between 2 ESP8266 boards with MQTT<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>MQTT callback function<\/strong>:<br \/>\nThis function should be called when you use the MQTT operations. IT is called when there is any incoming message to the client under any topic to which the client is subscribed. It is possible to retreive the topic and the message. These 2 last blocks should be called only inside the function.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-medium wp-image-2074\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/MQTT_CallBack-300x114.jpg\" alt=\"\" width=\"300\" height=\"114\" srcset=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/MQTT_CallBack-300x114.jpg 300w, http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/MQTT_CallBack.jpg 309w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=5j8-JFTMevo\">Basic MQTT operations<\/a><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=v6pcccSWl5s\" target=\"_blank\" rel=\"noopener\">Communication between 2 ESP8266 boards with MQTT<\/a><br \/>\nVidoe: <a href=\"https:\/\/www.youtube.com\/watch?v=_726HHhu_Ro\" target=\"_blank\" rel=\"noopener\">MQTT sensors network<\/a><\/li>\n<\/ul>\n<ul>\n<li><strong>Webservice IFTTT<\/strong>:<br \/>\nThis bloc will send a http request to the web service IFTTT. You need to specify the key, the event name and values. The values could be empty. With the IFTTT service, you can send an email, an SMS, Tweet, publish status on Facebook &#8230;\u00a0 You need to create an applet with the <span style=\"color: #ff6600;\"><strong>Webhooks<\/strong> <\/span>service. Follow one of these tutorials for more information.<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=FnKkeRoJ_ow&amp;index=31&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1\">Video tutorial<\/a>: Post status on Facebook.<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=znFMNzT_Gms&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1&amp;index=34\">Video tutorial<\/a>: Send an email with GMAIL.<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=iW1FKWCrH44&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1&amp;index=38\">Video tutorial<\/a>: Send an SMS<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>ADAFRUIT MQTT SETUP<\/strong>:<br \/>\nThis bloc should be called only once (in the setup part) if you want to communicate the board with the ADAFRUIT IO MQTT server. You need to specify the user name and the key. To have these information, you need to create an account. Keep the default port. For more example, watch one of these videos:<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=Eocgx_VVGVY&amp;index=36&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1\">Video tutorial<\/a>: Send information to the ADAFRUIT IO Server<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=-0zGTuDZLpg&amp;index=37&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1\">Video tutorial<\/a>: Get information from the ADAFRUIT IO Server<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>ADAFRUIT MQTT Publish<\/strong>:<br \/>\nThis bloc will allow you to publish any data to the specified feed. The bloc returns true if the date was sent successfully, otherwise, it will be false.<br \/>\nReturn type: <span style=\"color: #00ff00;\"><strong>Boolean<\/strong><\/span>.<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=Eocgx_VVGVY&amp;index=36&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1\">Video tutorial<\/a>: Send information to the ADAFRUIT IO Server<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>ADAFRUIT MQTT Is connected<\/strong>:<br \/>\nReturn true is it is connected to the io.adafruit.com site. Otherwise, it will be false<br \/>\nReturn type: <span style=\"color: #00ff00;\"><strong>Boolean<\/strong><\/span>.<br \/>\n<a href=\"https:\/\/www.youtube.com\/watch?v=Eocgx_VVGVY&amp;index=36&amp;list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1\">Video tutorial<\/a>: Send information to the ADAFRUIT IO Server.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Cayenne Connect<\/strong>:<br \/>\nConnects to the Cayenne IOT platform. You need to have an account on the platform. To connect to the server, you need to give the username, the password and the client ID that you will find on your account.<br \/>\nIf the debug mode check box is checked, you will see debugging information on the serial monitor (connection state, a received message &#8230;)\u00a0 You should call this block only once in the setup when you want to connect to the Cayenne platform.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2077\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/Cayenne_Connect.jpg\" alt=\"\" width=\"209\" height=\"129\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=r56foHZB_50\" target=\"_blank\" rel=\"noopener\">Send data to Cayenne platform<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Send to Cayenne<\/strong>:<br \/>\nPublish a data to Cayenne.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2080\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/CayenneSend.jpg\" alt=\"\" width=\"201\" height=\"58\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=r56foHZB_50\" target=\"_blank\" rel=\"noopener\">Send data to Cayenne platform<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Cayenne Update data<\/strong>:<br \/>\nWill check if there is an incoming data<br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=JEeA6t5YpTE\" target=\"_blank\" rel=\"noopener\">Control ESP8266 with Cayenne mdevices<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>TIME<\/strong>:<br \/>\nGets the time from an NTP server<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2085\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/NTP.jpg\" alt=\"\" width=\"292\" height=\"103\" \/><\/li>\n<li>Video: <a href=\"https:\/\/www.youtube.com\/watch?v=sRzWWQCWGxE\">Get time from NTP server<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Geolocation<\/strong>:<br \/>\nMake a request to the Google Geolocation service to get the position of the board. You need to create an account and a Key will be given. Once you called this block, you can use the location block.<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-2087\" src=\"http:\/\/easycoding.tn\/wp-content\/uploads\/2020\/06\/Geolocation.jpg\" alt=\"\" width=\"269\" height=\"53\" \/><br \/>\nVideo: <a href=\"https:\/\/www.youtube.com\/watch?v=0vCOh1l9pdE\">Geolocation<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MQTT Connect: Connect to an MQTT broker. The server could be local or remote. Video: Basic MQTT operations Video: Communication&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1080,"menu_order":6,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1668"}],"collection":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/comments?post=1668"}],"version-history":[{"count":23,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1668\/revisions"}],"predecessor-version":[{"id":2088,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1668\/revisions\/2088"}],"up":[{"embeddable":true,"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/pages\/1080"}],"wp:attachment":[{"href":"http:\/\/easycoding.tn\/index.php\/wp-json\/wp\/v2\/media?parent=1668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}