{"id":1641,"date":"2019-02-23T19:25:29","date_gmt":"2019-02-23T19:25:29","guid":{"rendered":"http:\/\/www.richa1.com\/RichardAlbritton\/?p=1641"},"modified":"2019-12-12T16:02:58","modified_gmt":"2019-12-12T16:02:58","slug":"setting-up-mqtt-on-raspi-with-node-red","status":"publish","type":"post","link":"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/","title":{"rendered":"Setting up MQTT on RasPi with Node Red"},"content":{"rendered":"<p>Download and install Raspian\u00a0Stretch Lite onto RasPi SD card<\/p>\n<ul>\n<li>\n<pre class=\"\">sudo raspi-config<\/pre>\n<ul>\n<li>Enable SSL and any other desired options<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><!--more-->Connect remotely using Putty:<\/p>\n<p>Connect via SSH to the Pi&#8217;s IP address<\/p>\n<p>Update and install all of the necessary software:<\/p>\n<pre class=\"\">sudo raspi-update\r\nsudo reboot<\/pre>\n<p>after the reboot, log in and\u00a0install Node-Red<\/p>\n<pre class=\"lang:default decode:true\">sudo apt-get install nodered\r\n<\/pre>\n<p>Once installed, we will need to start Node Red by running the following code.<\/p>\n<pre class=\"lang:default decode:true\">node-red-start<\/pre>\n<p>Now you can go to the Pi&#8217;s IP address in any web browser but be sure to add port 1880 to the IP address like so:<\/p>\n<p style=\"text-align: center;\"><em>http:\/\/192.168.1.32:1880<\/em><\/p>\n<p style=\"text-align: left;\">Now we want to make it so Node RED runs on startup.<\/p>\n<pre class=\"highlight\"><code>sudo systemctl enable nodered.service<\/code><\/pre>\n<p>install MQTT support<\/p>\n<pre class=\"\">sudo wget http:\/\/repo.mosquitto.org\/debian\/mosquitto-repo.gpg.key\r\nsudo apt-key add mosquitto-repo.gpg.key\r\ncd \/etc\/apt\/sources.list.d\/\r\nsudo wget http:\/\/repo.mosquitto.org\/debian\/mosquitto-wheezy.list\r\nsudo apt-get update\r\nsudo apt-get -y install\u00a0mosquitto\u00a0mosquitto-clients python-mosquitto<\/pre>\n<p>Test by starting the service<\/p>\n<pre class=\"\">sudo \/etc\/init.d\/mosquitto start<\/pre>\n<p>open a new Putty terminal<\/p>\n<p>In the first terminal enter the following:<\/p>\n<pre class=\"\">mosquitto_sub -d -t hello\/world<\/pre>\n<p>In the second Window, enter:<\/p>\n<pre class=\"\">mosquitto_pub -d -t hello\/world -m \"Hellow from Terminal 2!\"<\/pre>\n<p>If successful, the packet sent from terminal window 2 should appear in window.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1641\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1641\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Download and install Raspian\u00a0Stretch Lite onto RasPi SD card sudo raspi-config Enable SSL and any other desired options<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1641\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1641\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/setting-up-mqtt-on-raspi-with-node-red\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[15],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5AhH6-qt","_links":{"self":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1641"}],"collection":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/comments?post=1641"}],"version-history":[{"count":5,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1641\/revisions"}],"predecessor-version":[{"id":2027,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1641\/revisions\/2027"}],"wp:attachment":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/media?parent=1641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/categories?post=1641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/tags?post=1641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}