How to Node-RED!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi today we will take a look at note read we will link all the IOT devices in our home and access them conveniently from a user interface as an example we will use my main switch the washing machine controller and the prototype of the weather station which we will refine next episode this should provide enough sensors and actuators for in overviews we will run the note read server on a Raspberry Pi which is also running the MQTT broker from the beginning of this series check out the home automation playlist if you haven't seen it yet all the commands codes flows and paths shown in this video can also be found on the project page linked in the description as teased in the last episode note red is already pre-installed on the raspberry and stretch image which we are using it can be found in the programming menu however it is lacking NPM the node package manager which is needed to add any useful extension we use here but no worries we open a terminal and simply execute update nodejs and node read this script updates everything and also installs NPM it can take half an hour to complete note read can be accessed by anyone in the local network so it's recommended to add some password protection this takes a little bit longer to set up but it's optional we change to the node-red home directory using CD tilde slash dot node - read and install the node red admin package sudo npm install - g node red admin this installation took even longer than the update from before now we can use the admin tool to generate password hashes for our users so they don't appear readable in the config files we type note red admin hash - pw then type the password and return this password hash can now be copied in our user configuration we open another terminal and edit the note read settings using the Nano editor we search for the admin health setting and comment the block in now we can change user name remove the old hash and copy and paste the password hash from the other terminal into the editor using the right mouse button functions of the terminals since users is a list we could also add more users like this the permissions can also be set to read only by using read instead of Asterix I don't need another user so I remove it to also protect the user interface we want to create we also need to set the credentials for the HTTP note off save using ctrl o and exit with ctrl X now no dread should be password protected let's configure here a last thing you won't a note read server to start up automatically when the Raspberry Pi is powered up this can be easily achieved using the command sudo system control enabled note read service and we are done here I simply reboot the raspberry to be sure everything works as expected on startup let's go graphical note red is a graphical development environment which can be accessed from the browser the address is the IP of the raspberry at port 1880 the first time it will ask you the username and password we just set up before we start we check the menu we got the latest version and since we installed NPM the manage palette menu entry is also available we enter it and get the option to install extensions on the second tab to be able to design a user interface for our home automation we need to add the note red dashboard extension once that is finished installing we finally can start exploring on the left side we have all the available nodes input output function raspberry and the newly added dashboard nodes we can simply grab a node and drag it into the flow on the right side we have the info tab which provides very useful infos for the selected node the debug tab for our debug output and also newly added dashboard tab to construct our user interface we take a debug output node and drag using the left mouse button from the output connection to the input now we need to tell the MQTT input note where to subscribe double clicking on it opens its settings we didn't set up our MQTT broker yet so click here to edit we type the address here localhost would also work since our broker is also running on this raspberry and we also add the username and a password then the topic where to subscribe we can use the hash wildcard to get all the messages from the weather station set a quality of service you like and done node-red works by sending message objects between the nodes these messages contain at least a topic and a payload our debug node prints out the payload of the message which will be the MQTT data received from the subscription our changes to the flow are not effective yet those small circles indicate that there are changes that need to be deployed which is done by pressing on the deploy button now the changes take effect and our messages start to be displayed in the debug tab it works to stop floating the output we can stop it pressing the small button at the node one important note is function we can drag it on the connection to put it between the function node execute JavaScript to manipulate messages and receives a message object and can return one which will be sent to the receivers in this case we can filter the messages by the topic and forward only the temperature we've added the Griese to the payload it works the function note can also store data in the global context object which can be often seen in my flows now let's create a user interface to display the temperature we can simply take a text note the inputs and outputs can be connected to as many other nodes as you like the small triangle indicates there is a crucial setup missing in the node and the options we can see there needs to be a group assigned so we need to create a new I structure in the dashboard tab first the first level in the hierarchy is the tab we create one then we can add the group to the tab now we can assign our text to the group the data can be formatted using an angularjs template check out the info tab for details giving the node a distinct name helps to identify it let's see the result the UI can be found at the same address as note read with edit / UI at the end and there is our output as we want to add more functionality it's probably a good idea to add additional flows I will keep the first one for the weather station and add another one by clicking at the plus up here let's try to publish to mqtt now to control actuators or simply inject some information we add the topic to which we like to publish this is the one of my main switch now we add a switch UI element the UI controls have also an input and are able to reflect the state they receive everything in the UI is always updated instantly since the switch controls my lava lamp we can try creating a new tab in the UI also adding a group indicating the room and we attach the control to the group the appearance can also be changed to custom icons the data sent by the switch can be adjusted here my main switch expects a one for on and zero for off switching to the info tab we can find all the details about the note for example where to find the custom icons let's deploy and test it now that we have two tabs this menu appears we can switch to the Lite tab and can switch my lava lamp on and off if I hadn't forget to set the label correctly let's check out some other probably important notes for further development the inject note can be configured to send a timestamp repeatedly or even at a specific time at specific days one viewer asked me how to letter we must do something at a specific time this can be a solution I can set it up here to turn my lava lamp on at 11 o'clock every day it's also possible to address the raspberry hardware using note read for example sending PWM to a pin or receiving i/o signals from a pin let's take a look at the current state of my own automation I've added the sensors of the weather station and attach them to gauges and charts and I also created a control for the washing machine attachment which can even start the washing machine at the time we conveniently set using the UI the flow for the weather station is quite simple it just connects the MQTT topic to the charts and gauges some of the values are smooth that and some other are simply scaled using a function the washing machine part is a little bit more complicated beside a simple reflection of the status LEDs as icons the timer setup is rather complex since there is no UI element for time input I've used the template element within custom input field a very interesting node is the audio it can be used to do text-to-speech even when your phone is locked I've stored the link to the UI webpage as a shortcut on my phone to access it quickly I turn the notifications on lock my phone and simulate the finished status LED isn't that awesome and here's how the timer works I set the start time and activated great okay let's check out two more very useful functions both can be found in the menu the first one is to create sub flows this can be used to create all nodes which are simply built from other nodes this way you can reuse reoccurring parts easily in your complex flows the last function we take a look at today is a simple import-export this is the easiest way to share our flows we can select the part we like to export and go to menu export clipboard here the selected section of the flow can be copied as a JSON object encoded in one string Hashemite flows on the project page so you can copy them import them in your note read and check out all the details now this is out of the way we can concentrate on the hardware of the weather station in the next episode the current prototype simply consists of a windows with some sensor shields plus a photo resistor it already uses deep sleep but this still can be improved a lot if you can't wait another week you can check out the link below for the code of the current state and some details about the sensors I hope this video was at least a little bit informative I'm personally impressed by the possibilities that open up given those tools we can simply take it as a prerequisite for all the home automation projects to come don't forget to subscribe and share my videos if you liked them see you next time bye you are so intelligent you are so big
Info
Channel: bitluni
Views: 308,201
Rating: 4.9629068 out of 5
Keywords: node red, home automation, tutorial, diy, mqtt, raspberry pi, linux, browser, smartphone, iot, internet of things, washing machine, lights, text to speech, tts, make, node-red, romote, timer, alarm, wemos d1 mini, esp8266, esp32, microcontroller, arduino, ide, graphical, development, programming, wifi, maker, node, red, user interface, ui, raspberry, deep sleep
Id: GeN7g4bdHiM
Channel Id: undefined
Length: 12min 58sec (778 seconds)
Published: Sun Oct 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.