Node-Red Automation, MQTT, NodeMCU & MicroPython

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey robot makers how are you doing i hope you're having a good day so far so today's show is all about node red and automation so if you've built any robots or any kind of sensors and things and you think how do i get that data to do something useful today's show is really useful to you so let's dive straight in my name's kevin come with me as we build robots bring them to life with code and have a whole load of fun along the way okay let's get over to keynote so i said all about node-red so what is this all about so today's session we want to learn what node red is uh we want to learn about what mqtt is uh you'll learn a lot about that today uh we'll look at a simple weather station i've got one on my desk here that we can have a look at and see how all this fits together we will build a node-red flow and a dashboard this is so cool you can get the dashboards on your mobile phone anywhere on your local network very very easy trivial to do and we'll look at how to load micro python onto um an esp8266 otherwise known as a node mcu so i've got a couple of them here because i use these in my projects simple because they have wi-fi built in that really helps us build projects that are internet of things type related i would say this is um a level beginner because we're talking about some quite straightforward concepts even though there might be some acronyms and things will explain what all those mean so let's get over to node red what is this all about so node-red is a flow-based programming tool originally developed by ibm um i think it's by a british developer actually i've seen quite a few the videos of the guy who's either the lead developer or the inventor of node-red his idea if you go to nodered.org you can download the code there or you can learn more about it and it's one of these pieces of software that's under continual development so whatever you see online it's probably moved on by then if you're watching this maybe a year from now it'll probably have developed even further but it's totally awesome so let's have a look a bit more detail what it is so what is a node so you can see on the screen there um we have these little lozenges these little um rectangular blocks on the screen that are connected together by what looks like noodles by bits of spaghetti and the idea is that these things create a flow so things go from one node to another node it does some kind of function or operation on it and then it passes it to the next one down the chain and it might have several inputs and have several outputs and depending on what the node that you picked from the palette of nodes that's available it will do your bidding so it's very visual um i'll quite like the way this works similar in kind of style to things like scratch although instead of being top to bottom this is left to right this is how we we create and read these diagrams so the data comes from a source we then pass it into a node or it's emitted from a node that we select from our palette and each node performs a function and then the collection nodes we generally call that a flow and we can have several flows as well all interconnected so a quick tour of the node interface and we'll have a look at it for real in a minute but i just want to give you a quick overview of what all the different parts mean it is quite straightforward and well laid out so on the left hand side we have a node palette and that's where you'll find all those little lozenge shaped things which are the nodes um the main part of the screen is where the flow is and at the top of there there's some tabs um on the right hand side we have some information configuration and some debug panes they sort of slide in and out as they needed and at the very top right we have a button that's called deploy now when i first started using this i was like why'd you have to keep deploying things and the idea of this is you can work on something and when you've got it working you can then click deploy and that version is then what's produced um you know what's what's active in in real life um they've since built into this things like source code control using git so you can you can rewind or reverse some of your projects if you make a mistake but it's very forgiving but it's quite simple interface very easy to get started with this so um we are also going to be talking today about um some q a's from the facebook group i'm actually going to do that a little bit later on i've made a note of that i think i put my slide in the wrong place if i'm honest so um we'll come back to that shortly but if you've got any questions and answers put them in the chat and i'll come to them um a bit later on in the show um so just put a queue in front of it makes it easy for me to scroll through because i'm doing all this by myself so dashboards so one of the cool things about node red is once you've created these flows and you've got the kind of mechanics in the background of things working you've got data flowing in it's doing something to it and it's spitting out somewhere it would be really nice to sort of graphically show that data so you can either chart it you can have these what i've got on screen at the moment is some little uh pie charts little donut charts that are showing humidity and there's a temperature one that also goes with this and uh these are very easy to sort of put together and then view on your mobile phone or tablet or pc and if you're clever you can make these work over the internet as well and these are updated in pretty much real time so node-red makes all this very trivial to do building dashboards um connecting data from from your robots from your sensors very straightforward and we'll have a play with that in a minute we'll do a bit of demo so these can be used to trigger other events as well so it works both ways the dashboard is just like a read-only view you can have buttons on there and sliders so you can interactively push events back to your robot so you could for example build a dashboard that's got a slider on it and that slider might make the um you know the bucket of a smart robot move up and down or it might make the robot move backwards and forwards or it might be that you have a button that presses a light and makes the light go on and off for example so um just as on the side i created quite a bit of home automation using node-red i'm using uh the stuff i'm going to be showing you today mqtt and something called homebridge and it enabled me to get sort of head start of what was now quite common where you have um home automation through your mobile phone you can sort of select a scene so when i come into this uh this robot lab i can press a button on my stream deck and the lighting will all adjust to the perfect lighting for broadcasting um i might have a different one for sort of a morning coffee i might have another one for um i don't know different points during the day if i've got a meeting i know it can be less distracting so i've got lots of different scenes set up there and i can just press press of a button make them happen and what i did in um in the house was we had a heated mirror in the bathroom and we had a fan that came on when you open when you um switch the light on and i didn't like the fact that this fan would stay on as long as the light was on and if you switch the light off it would stay on for another 15 minutes so um i put a device that's called a sonoff i think i've got one here let me just go back to the main screen for a second just while we're on this one so this is a sonoff stands for software on off and essentially inside this it's a little plastic device i've got here it's got some mains that comes in one side and mains goes out the other side and if i can sort of just get this thing apart um i'll show you what it looks like inside so there is just a little circuit board with two header pins that are you know designed for mains electric and in the middle we've got a tiny little chip and on the back we've got some circuitry as well some relays and transformers and things so what happens here there's a little clickable button there and there are some header pins there's five header pins there and this is actually just an arduino type chip you can use the arduino ide to program this yourself and that's exactly what i did i created some code that would turn the mains on or off depending if it was a signal sent to it and just like the um node mcus that we're looking at today because it's more like node mcu if i'm honest uh this has wi-fi built in so i don't know if i can show you on the screen there there's a little wiggly line just on the side of the circuit there and that is actually the wi-fi antenna for this so i built some code that connects this to the local wi-fi um it listens on a mqtt server which we'll get into in a minute and it listens for specific events happening such as turn light on turn fan off that kind of thing and then i then exposed those on off um events through something called home bridge which we'll get into in a minute and then that was able to then translate that into something that um my apple phone would be able to listen to that's my doc on the screen there we've been able to listen to and um it could then make a button appear on my phone and i could press that button to make the fan go on and off and then i could do things like automation i could say you know don't turn the fan on if it's past 10 am at 10 pm in the evening um but make sure you can turn the fan on from 6 am in the morning and if the elect enough the heat has been on the heated mirror has been on for more than say an hour switch it off all that kind of logic you can do in the apple home app or in node-red and you can also capture all this data as well and put it in a spreadsheet like a google sheet if you wanted to so i'm going to look at a bit more of that how we do that kind of home automation stuff but with a view to you know how we integrate this to robots so dashboards is one way we can quickly build interfaces for that so the raspberry pi is an ideal device for building internet of things iot um it's got all these header pins that we can connect things to it has wi-fi if you if you you buy the model that has wi-fi on the zero um wh and the h the header and node-red exposes those gpio pins in node-red so it means we can very easily connect things like led switches directly to our raspberry pi um if we wanted to do some experiments so i have in my little drawer bits next to me here again i should have thought this through before i started the show so i have a sense hat which is a sort of official raspberry pi um device hat they call it it plugs onto the top of the raspberry pi so i've got a zero i'm just holding now so it just connects through to the header pins there it's got a little led matrix there but it has a whole load of sensors it's got a little little joystick you can do up and down left and right um it has a humidity sensor it's got a temperature sensor pressure sensor all all the sensors and that means that we can take that data through node-red and we can do things with it so we can build a little if you know if you buy one of these you can connect that very easily but we can do it with raw components and that's exactly what i want to show you in a minute on the overhead so all the things raspberry pi is sort of really on the money when it comes to you know cool technology and integrating with things so node-red comes installed i think automatically on the raspberry pi if you choose the full desktop version i believe but it's very easy to install and it's in the list of recommended software we can have a look at that as well so mqtt um this is a technology that i'm really interested to show you so you might not have heard of this it's a messaging protocol so it stands for message queue telemetry transport and on the screen there's a little animation there of a satellite just passing by and that's because this was originally developed for collecting telemetry information from satellites and controlling them in orbit as well as like monitoring oil pipelines so things where there's a great deal of distance but you want to get as real-time information as possible so the protocol is very lightweight very simple to implement and use it's all open source so it's ideal for the kind of lightweight message passing that we're interested in so you'll hear people talk about a mqtt broker an mqtt client and just other things we're going to get into in this slide here so it uses the publish and subscribe pattern so publish and subscribe if you think about um magazines for example um somebody will publish a magazine and you will subscribe to that so whenever they have a new issue you'll get that um because you're subscribed to it so it's a kind of one-way um way of you know understanding if events have happened if new messages have occurred and because we might have more than one type of message there's an ideal called a topic and it's a bit like a channel so you've got all the different channels of communication that you might want and you can just subscribe to one topic on that and topics are very again lightweight they on the fly you don't need to sort of build it in advance configure it you just saw when you send a message you send it on a topic and if you're subscribed you subscribe to that topic and because they're going to the same server you'll both be in communication so it's very easy to create um sort of build up and tear down these things very simply um the other clients can subscribe to topic and receive messages posted to those topics and the messages contain what's known as a payload so the payload is the thing that you're interested in it might be the data and it's usually structured in such a way that um whoever is receiving it knows how to deal with it so typically we use things like json objects javascript object notation which is of sort of curly braces and it's very specific way of writing data and passing that between two things so because of the internet that uses json all the time um so that's the kind of thing that's in the payload but it doesn't have to be it could be binary it could be whatever you want it to be could just be pure text but the message has like a little header on there which contains who it was from what what quality of service we don't need to get into that because this a beginner's one but it has kind of header information that you don't really care about but just make sure the message gets to you and then there's the payload which is what you are interested in so like i said very easy to implement we'll have a look at that in a minute and um like i said it was originally developed for monitoring satellites and oil pipelines so we're going to use that i have one of these running in my home as well on raspberry pi it works very reliably no fuss so how do we connect all these things together so on the screen at the moment i'm showing a diagram which has a robot on the left hand side it's going to connect to our mqtt server um so that means it'll probably need something that can communicate via bluetooth um to something that can receive that and then put that onto the network or it has native wi-fi itself so maybe a node mcu or an esp32 or any kind of chip like a raspberry pi that has wi-fi built on so that's going to pass the message to the mqtt server and the message that it might send is that it's detected a face or a button has been pressed or some telemetry information and what i mean by telemetry is you know what's the rangefinder um sending us back as a in the way of data so that's the kind of thing that we can collect from our robot the mqtt broker will just sort of pass that message on to anybody that's subscribed to it so the kind of things that we can connect to it is our node-red server that can listen to mqtt topics and it can do things with them when they when they get passed in there is also the in um if this then that we'll have a look at that um slightly later on in the show and there's something called home bridge as well so all these kind of receive those mqtt messages and can do things with them and the home bridge one is the one that can connect if you have an apple device to your apple network if you use if this then that or node red you can probably connect that to alexa devices as well as um google home devices as well but node-red has by far the most number of things you can configure yourself if this then that requires a subscription but is available over the internet so node-red isn't typically exposed over the internet um but you could make that happen there is ways and means so we can build lots of interesting apps dashboards data loggers very easily with our node-red we can log things to databases and spreadsheets very very simply trivially i would say um the the issue there is if you log data to a file and then you forget about this it's just going to fill up whatever device that's on because you'll forget about it because it works so reliably and then you'll think why is that thing stopped working and it's probably because the log file is full um so you make money to think about things like round rubbing log files they never quite get full right sort of gets to the end of the file the agreed file size and then goes back to the top and then start writing again so how do we connect mqtt to node red it's a node there's a node that's called the mqtt in node and we can connect that we configure it by just clicking into it we'll have a look at that in a minute on the demo and there's some options in there such as what is the mqtt server that we're connecting to the broker what's the topic we're listening to and what's our client name so that the server knows who we are which messages we're interested in um we're then going to pass the data which we receive to that particular mqtt node so we subscribe we're getting some data in it's going to be in a json format so we might want to split that out to make it more of a native object we can look at and we can pass that and i've got on the screen four different types of node and we will have a look at these interactively on the demo in a minute but we've got something called message.payload and that's a debug node so we can have a look and see what's actually happening in ills messages i've got a chart a temperature and a humidity dashboard widget and so that's going to build a dashboard and i can access that through my computer and see what the actual temperature is in a kind of nice graphical way rather than just being a pure number we'll have a look where all that data is coming from in our little weather station as well so um how do we connect mqtt to homekit we have um a couple of options there one is um hap node.js hap stands for home kit accessory protocol for node.js and that's what i'm actually using again open source very simple to do i downloaded the code from github i believe and then just run it straight on my device i configured a couple of accessories which is how this is presenting the data to my uh to my actual phone so i can see on my home app what the temperature is from these homemade um weather stations so it's very easy to sort of pair that up and we can see on the screen there there's a there's a qr code one of those funny sort of digital diagram things and the qr code means that i can just point my whole matter up at the screen and it will pair with that particular device if you're trying to do that on this it won't work because you're not on my local network but uh the little text under it says what this sort of the the key that you need to type in potentially uh and other information as well so that's how we add um that's how we get started with um um bridging the gap between homekit and mqtt so we can take those messages from our weather thing we can do something with it in the apple home environment ecosystem that's what i was looking for um and to add accessories to um home bridge there is a tab on there you just click on that you can then add extra extra accessories in there and they've got a whole load of everything you can buy they've probably got an accessory for that you just click it configure it and then it's part of your home kit installation so you can then do things with it so if you have um if you buy a nest camera for example that isn't part of the apple eco system so you have to use um you know the either the alexa app don't let this h2o because it's listening alexa cancel there we go so um we we can either um we can use home bridge to bridge the gap between those different ecosystems and bring devices that don't necessarily have apps um to talk to each other so that's a pretty cool thing um these things can be a bit fiddly at times the actual accessories and it's down to who's written it and how good that is so your mileage may vary with that but actually pairing with the um home bridge very trivial to do i got up and running in about half an hour i would say so home bridge connects things to apple's homekit platform uh it runs on raspberry pi's on mac os windows linux all the things and there's a link on screen there which is github.com bridge slash home bridge and then there's the wiki page on there as well you can learn all about it it's very simple to get working on a raspberry pi and that's that's the route i chose so if this then that what is that so if this then that um is an app you can subscribe to um i believe there's a free tier where you can build three apps i'm on the paid one it's not very expensive it's about three or five pounds a month something like that three to five pounds and that means you can build a lot more than three apps uh so i've got apps that do things for me not to do with robots in this case but things so such as when i go live on this um it can connect to is listening to an event on youtube for any any time i go live and that will tweet about that it will instagram about that if i instagram a picture it'll tweet the picture so it helps just do a lot of the things that i would have to do by hand and it's very extensive and in how it can do that so we'll have a look at that as well i've got some um examples where we can have a look at that um on my account um so you can connect all the things together and similar to what we can do with node red this can do this can sort of hand off those things from node-red and then do them on the internet so if you want to have um a google docs spreadsheet um i don't know convert that and save that into a database it can do that kind of thing for you the number of things it can do are just vast but just think of it as a as a sort of sequence of things that can happen based on a number of integration blocks that you can plug together it's very very easy to set up so i talked about the the node mcu one of the things um that is really cool and now that we've got the raspberry pi pico and micro bit um which i've got on our little overhead here there's our raspberry pico and we have the micro bit this this is the version one micro bit they both run micro python oops and um yeah that's fine and the node mcu can also run micropython as well so how do we actually get that onto that device um so that we can write some small programs such as our weather station you can use c just like you can with arduino to program these node mcus but um micropython is really taking hold in the embedded chip market so why not make use of that it's an ideal chip for doing this on it's got loads of storage um i think we did the comparison video a couple of weeks ago and it had at least twice that of the the raspberry pi pico so it's an ideal use of that so how do we actually flash the micro python on there so what we need to do is we need to grab that's my wrong slide there there we go now what we need to do is we need to go to github.com and then it's is it marcel stower slash nodemcu dash pi flasher and you might be able to do this in funny actually but this is the the route i use i used i downloaded this code i created um a little virtual environment for my python just so that any specific libraries to do with that the instructions role on the on the site actually if you follow that very very straightforward to get that up and running and this little user interface which i've got on the screen there which shows you you can either select the serial port or you can just let it auto detect you download the firmware from micropython.org and there's one specific one for this chip for the nodemcu we'll have a look at that if you want to and you'll get a little file that you can then use this interface to flash so you'd literally just select it there with the browse button leave the baud rates and everything as they are um you can select erase flash if there's a program already on it and then you just say flash and it'll take maybe 30 seconds and then you've got micropython running on your little chip so that's um nodemcu and how we get it on there and then the little slide that i wanted to go over let me just go back to that which is this one here so this is the little weather station and i can show you this on the overhead camera as well in a second so the node mcu that we talked about has built-in wi-fi that means it can go anywhere in my house and as long as it's got power and i use like a usb um phone charger just to power it doesn't need very much power at all i've used my micropython to create the code for this we can have a look at that shortly and i use the the nodemcu pi flasher tool to get micropython onto the chip and the little program that runs on this simply takes a reading from that little white device i just go to my overhead camera for a second so this little white um chip here this is a dht i'm going to get it wrong i think it's either an 11 or a 22. i want to say 22 i think the white ones are 22 and the blue ones are the dht11s i think one of them is a bit more accurate than the other so that just spits out readings on one one of the um pins and we just use our node mcu to take them readings and and then um package them up and send them to our mqtt server and we package them up into a little json block that says here's the temperature and here is the humidity and and when i thought on i'd included a third one which was and this is in this location such as like the loft the hall the summer house wherever so you can use any of those and you can see from the diagram there it's literally just a couple of pins and a breadboard this is not a complicated device to use and these are all off the shelf components i've not done even any soldering these are just um header pins pushed in with jumper wires and then i've got a little black project box that i bought from shop online i believe and i've just put it in there just to make it a bit more robust but it's pretty pretty crude as you can see there i'm just showing on the overhead camera now as well that there's the box on the bottom there there's a little sticker that says bedroom temperature sensor and that lid just goes onto that project box and just keeps it stuff you know fluff and dust from getting in there essentially so that's our little device a little weather station um that like i said you can get them that detect temperature as well as pressure and humidity uh i believe these these ones do all three i'm not sure whether we collect all three and send that on but so we just had a look at that one already so demo time my favorite time let's get over to um the raspberry pi so i'm going to go to that and then that so i'm using vnc to connect to a raspberry pi and what i want to show first of all is so if i click on the uh the raspberry pi start button i go down to preferences there is an option there called recommended software if i click on that it'll load up this little little dialog box that shows me all the available software that the raspberry pi organization recommend that we install on our raspberry pi it doesn't always automatically install them when you when you flash the memory card from raspberry pi um but there are certain packages that they would say this is this is the best one that we think is available so for example if you want to do word processing and spreadsheets they have the libreoffice so libreoffice is one of the recommended things that we can just see it's got a little tick box next to it if i scroll a bit further down node red is there as an option and if you click on that little box there and then click ok click apply it will start installing that for you so it's very easy to get this installed um off the bat and we can see we've also got things like funny and visual studio code there as all recommended pieces of software so what's a bit misleading there is i've actually got um node red running on this but i didn't install it through their recommended things so that's why it hasn't got the tick but it is actually running on this machine so if i also go to my um my my pc let me just go to that one no that's not it that's my notes you don't want to see my notes let's go to that one there and that there yes that's fine so what we've got on screen at the moment is um we're connected to our node-red server so you can see that it's got the ip address one 192.168.1.160. and that's on my local network and then there's a little semicolon in the address bar one eight eight zero and that's what port this is running on so you could potentially have multiple versions running on different ports if you had a fast enough machine so as we can see on the screen we've got the the layout like we described before we've got the the node palette on the left hand side in the center we have our flow which is on the tab i'll call this one weather station there's another tab there i can click on and that's an empty one at the moment and then on the right hand side we've got some um different panes to show things so at the moment i'm on the info pane and we can see that there is um some a little tree diagram of things and this is actually the the dashboard that we're going to create we can also look at there's a debug messages there and i can see if i um if i wire this little home loft node directly into the message pane and click on the deploy button it'll now start spitting out if i just clear that spitting out even more uh things to our message.payload and we can also do that from the hall as well just in case we're not getting any messages from that other device and what will happen there is any messages that have been sent to those two topics will appear um here so i can see now i've got a message has just come through and it's on the topic slash home slash temp and the payload is a json object and i can see in there it's got the word temperature semicolon 26.70 and then it's got um humidity 41.80 and several other messages are coming through with pretty much the similar um similar output so that's great but that's not showing as anything we can't do anything with that yet so that's the raw data that's coming from these mqtt notes so if i double click into one of these and we can have a look what happens so i've just double clicked on the the slash home loft mqtt in node and on there i can see that the server that it's connected to is called mqtt server and we will actually go and have a look at that in a second running on the raspberry pi on a different machine the topic that it's listening to is slash home loft and i can see there why that's not getting any data now actually that should actually be slash home temp slash loft attempt for temperature uh there's a thing that says qos that's quality of service so you can prioritize messages based on this quality of service if you want to make sure that message always gets through ahead of other ones and bubbles up the queue faster for example that's what that qrs is for amongst other things and then output we can say um what do we want to output this to to the next node along the tree and i'm just going to say just auto detect it leave it as it is you can give it a name if you want to i've just left it as it is so if i do that i need to now deploy that because i've just changed it if i just clear the the debug as well i can now see that i am getting messages now from the loft as well as the hall so i'm getting two lots i'm getting temperatures and i'm also getting temperatures both loft on the whole and we can see that message payload lights up when it receives a message um now every now and again i also get one of these unexpected token n in json at position 15 and if we look at the message below uh where it says temperature it says n-a-n and that means not a number and for some reason i've asked for a number from the uh the temperature center and it hasn't given me one so it's just spitting out whatever it's getting there's no kind of error checking on there i could probably have done a better job and actually creating these in the first place but these have been running for about about two or three years actually uh and these are not been created in micro python these are created in arduino ide using c but as you can see it's working pretty reliably we can plug that in in a second to our dashboard and we can see what's going on so that's the first note then and these the the whole one is exactly the same but instead of being home slash temp slash loft it's home slash temp slash loft hall exactly the same and then we have a json node so if i double click on that one it says on there the action is to convert between json string and object and the property that it's converting it is the message payload so what i'm going to do now i'm going to delete those inputs to the message payload debug thing and i'm going to wire the json object the json node into the message payload so just to have a mental look to see on the left hand side you can see we've got little speech marks we've got a curly brace we've got the word temperature call on 24 and then humidity so i'm going to deploy this and this is going to change what they now look like so now that they come through just ignore that nam one for a second and i'll also pass that one there we've now got an object we can look at so instead of it just being a string of text it now understands that this is an object it's a json object and it's colored them in differently so we can actually expand them and we can work on them we can individually reference the temperature or the humidity so that's what that json node is doing we can split out now those two things so i've got um on the right hand side uh a dashboard node for a chart if i double click on that um so and here it's it's got a couple of properties so top to bottom we have group and that's what group on the dashboard is going to appear in so ignore that for a minute we've got things like size we can say how many units wide this is on the dashboard what type is it it's a gauge we could have a doughnut compass or a level the moment it's just a gauge there's a label which is temperature the value format is message.payload.temperature so remember before i said the first node is just spitting out a string of text the second node the json node is splitting out into objects so now we can say message.payload.temperature and from that node it knows exactly what we're talking to the units is just units we could change that to be um if it's temperature celsius for example so i could change that to degrees c and then there's a range so because this is going to be a chart we want to be able to specify what the axis of that that chart will be so i've said minus 20 degrees to 50 degrees celsius that should be more than enough and then there's a color gradient from green yellow to red depending where it falls in that range so i'm just going to click done on there and deploy and now what i'm going to do i'm going to go over to the um let me just find the right button for this to the dashboard uh which one is it dashboard and on the dashboard button we can see the layout of the site so there is um some groups there's a whole group and a loft group uh actually we can get rid of that one there's nothing in that one so i'm just going to edit that and delete it and i'm just going to rename that one there to be home so i'm just updating some of the nodes there just to make it look a bit better i'm going to deploy that and at the top right there there's a little button that says it's a little breakout button this is actually going to load up the dashboard that we've just created um so let me go to there let me just edit it do i need to enable this yeah enable it update deploy it and now if we go back to that page that we just looked at we've now got some widgets on our dashboard so the dashboard has got a nice blue header that says home and then there is two groups there is hall and loft and each of them has got a little chart on it so there's a humidity chart and a temperature chart and the humidity chart is going between 0 and 100 because that's the right range for humidity so it says the hole is 41.2 whereas the loft is 42.2 so it's slightly more humid in the loft and that's probably because it's raining at the moment and there's um there's not you know it's closer to the rain so it's getting more of that humidity coming through and then temperature wise and this is what you'd expect the loft is quite cool that's 20.5 degrees c whereas in the hall it says it's 26.8 i don't think it is actually 26.8 um but it might be next to something that's quite warm in there so um i would take that with a pinch of salt but we can see that there is a difference between the hall and the loft and we can also see that these are beautifully rendered um all we need to do is just go to a device if i try loading this up on my phone now for example so if i go to 192.168. and then colon 1880 and then slash ui and i look at that let's wait for that to render and if i can show you this on the screen you can see i have exactly what we have on the other screen which is those two donut charts and that's live i can i can see that right away so that's an example of how to build a very quick dashboard in um node-red if we go back to the uh screenshot there if i go back to the node interface so there's just two um flows on this but two what you call them flows this area is called the flow there's two sets of things happening on here one is for the uh the loft and one is for the whole so let's build one of these on flow one so what we will do on the left hand side we find the the network palette area and there's a note there's an mqtt in so i'm going to drag that across onto the pane there and it's got a little red triangle which means that it needs some configuration that we've not done so if i double click into that it knows that the server is the mqtt server because that's the only one that's available there but it doesn't know what topic we should listen to so i'm just going to do hash and hash means all the topics it's kind of like a wild card like star is uh when you're doing searches um quality server is going to leave us two output i'm going to leave as auto detects that's fine and then the other node i'm going to put is the debug node so i'm just going to put that on there and then i'm just going to wire the two together and then click deploy now if i go to the debug pane and i just clear that we'll see lots of messages coming through and not just from that whole sensor i've also got on my network um a 3d printer which uses octo octopi octal print to manage all the print jobs and that spits out loads of stuff on the mqtt server so i can check to see you know what the current status of a print is you know is it 70 through i could then make that connect to um you know an old mcu that's got a nice screen on it that'll show the percentage and i could just have that somewhere maybe take it with me and plop it next to me so i can see how far the print job has gone so you can see the potential for doing um interesting things with node red very simple to use and it's just a matter of plugging one node into another and configuring them correctly so if i look at some of the other things that we can do let's move that out of the way we can create comment nodes they don't do anything they just record a comment just like a comment in regular code we can do all kinds of different functions there's lots for switching values or sequences and messages we can select a range which filters things out in effect we can have a delay so if a message comes in we can get it to wait a certain amount of time before sending it on um and we can trigger things as well so we can say after three messages have been received then trigger an event for example we can execute arbitrary scripts so i could create a python script for example that is executed by this execution node um we can create random numbers um if i just feed that into the um message payload that will just create random numbers within a range that we specify um then we've got mqtt out so we can write messages back to the mqtt server based on something some event that's happened so i could create a button on the dashboard that when i press that it sends a sig it sends a a message um to the mqtt server and maybe our robot responds to that so we could create a dashboard for controlling our robot you know up down left right sends different messages different uh different messages to our robot on a particular topic so we could have a range of robots all on different topics so there's an idea and we've got other things as well web web http requests so you can build web pages apis with this you can ping servers you can play audio output you can split join sort or batch particular sequences of messages then you've got pauses so i was talking before about outputting things if we want to output all these messages to a csv file we just plug in that node to that mode double click we say what the file is called and it will just start output into a file on our file system so we can create data logger very trivially in this if we wanted to save this to a database all we would need to do is bring the database uh plugin in so what i'll do i'll click on this button here and go to manage palette and we can see here we've got nodes and installs nodes of the things that we've already got installed whereas install is the library of things so for example if i want to save to a database by just doing mongodb i can see there there is a node-red mongodb node and what i will look at when i'm trying to evaluate which is the one i want to install because there's several on the screen i'll look at how old they are as in when were they last updated and i will also look at what version number they're on is any that are so there's one that's version two there might potentially load that one in and that one's only a year old some of these are like four years old that one's there says two months old so i'm going to go with that one so if i install that click install it's going to go in the background grab that from the repository install it locally and then we'll see loads of nodes appear or a few nodes appear so we've got a mongodb a mongodb out and a mongodb in added to the palette there so if i now look on the left hand side at the very bottom of our list we've now got um let's see where they've gone there they are storage shop and i've got database in our database out the in requires us running mongodb so i'd have to install that separately somewhere else um but mongodb is quite a good database if you want to very quickly get one up and running uh if we're just scrolling down the list of pallets on the left hand side again so we've got a raspberry pi area so that's got the gpio in gpo gpio out it's got the mouse and the keyboard and i think there are some other ones that you can install as well the dashboard area is where we've got all the the nodes for the dashboards we've got buttons drop downs switches sliders numeric inputs text inputs date pickers color pickers are formed put all these in and then we've got outputs text outputs gauge outputs charts audio outs notification which sends an email um ui control actually notification doesn't send an email that sends a notification by the browser and then we've got template as well so you could create a template um using some divs and html and css and it will apply that template to your particular dashboard uh i think that is all the ones i've got installed so that's a quick whistle stop tour of node-red and we can see that where they've got some real data coming in from the sensors if i go back to my overhead camera this sensor is actually running as we speak this one is plugged in this little blue light is on just there if you can see there's some tape that's just in the way there's a little blue light just on there i think i put the tape on just to stop anything falling off and shorting this thing out because you know it is just held in place with a bit of blue tack i think and um there's the the temperature sensor pressure sensor um it's just got a wire coming from the ground the black wire is ground the orange wire is from the five volts and then there's a blue wire which is the data pin it just has one pin there going to pin number three i think that is on the node mcu and that's just happily collecting data and just spitting it out so if we go back to our node um which so there's one that's called loft one that's called hall and then there'll be another one that's called bedroom that one there bedroom is this device that i've got on here so we go back to the overhead shot not the overhead shot the uh screenshot and go back to that weather station one i can essentially just duplicate all these by dragging them copying and pasting them and then copying those three and pasting them and then we can just join them all back up as well and what i will do is i'll just edit that first node so instead of being hall it's then bedroom update that deploy confirm deploy and if we now go to our dashboard we should now have a extra set i've just not put them into particular order that's what i need to do there but we can see we've got a couple of extra ones and they're reporting the temperature in here as being um 21.9 degrees which is pretty much bang on what it is actually uh especially it's under a hot light but it's under a warmish light so that's um node red i'll show you um if this then that so this is my if this then that account and i've got a couple of i've got 10 apps that i've got currently running there so if there's a new stream started by me it will then tweet to kev's mac um if i like a video it will send a rich notification to the ifttt app that was just me testing out it will tweet my instagrams as native photos on twitter so i send out pictures um maybe every other day on instagram maybe i should do one here now from the live show like this and um i can send that out and that will get um tweeted out by this particular app tweet your instagrams as native photos on twitter that's looks like a duplicate that one post your instagram videos to twitter if i get a new follower i get a rich notification and what else we got if new public video uploaded post a tweet with image to kev's mac so there we go and if somebody likes one of my videos then again it posts a tweet that somebody liked my video and i will get an email if it rains tomorrow as well so to create these we just click this great big plus button here the interface on this is designed for like mobile devices look the size of that if this and then you add the first thing and just look i'm going to scroll down just look how how little the uh the scroll bar has moved given how many things are on there there is loads of these so you pretty much need to come ready prepared for what what kind of integration you want to do so let's scroll up and let's say for example is there a is there a google thing so google assistant google sheets google docs google drive let's do google assistant we can say a simple phrase or say a number or say a phrase with a text ingredient let's just pick the simple phrase and then it's going to ask me to connect to google assistant so i don't want to do that on this particular show but you can see how you basically just click on a block uh and that'll take you through to a particular set of options that you can use and then um you can you can do something with that so if this if if an event has been triggered then that so then that is that the next step in the process like though tweet the message or save the file or do whatever so that's similar to what we can do in node-red with the nodes but this just uses a different approach and it's available through the world wide web so wherever you are in the world this will still work um what else is this so home bridge this is the home bridge server um so i've got a few bits and bobs running on here so there's that great big qr code i can go to the accessories i can let's go to configuration actually and find an accessory that we want to plug in and plug in so let's search for so nest camera something like that so if i click on that it's going to see so there you go home bridge nest camera and if i click on that it says it's verified so we assume it's good we can click install it's going to do all the stuff in the background that it needs to do to configure that quick drink and um that plugin will then be available to configure i've not done a great deal of configuration on these but they do work very reliably very well so you can plug in if you get some cheaper cameras rather than the official um home kit ones you can essentially just plug these in you could get a raspberry pi with a camera built in and pull that into your network as a sort of native i'm just trying to find one on my desk here usually i have loads of these just knocking about i can't find one time but yeah essentially you get a raspberry pi zero with a camera module plugged in and you can very quickly make that into like an official you know camera that goes by your uh home app um so that's uh homebridge and what else was going to show you i've got my notes here all the things i need to cover up in the demo so we talked about that um sending messages building a dashboard so flashing the the node mcu and some of the code as well let's have a quick look at that shall we um so i'm going to load up uh funny i think let's go for funny i'm gonna go over to here and just ignore all the error message stuff at the moment all right so what i'll do i'll actually go to um i'm jumping about here what i'm going to do is i'm going to open up a new terminal i'm going to go into my documents folder into my micropython folder and in there i've got a node mcu flasher there we go that's not it we do want that one in a second though that's the code that we can use to so i'm just struggling to find the right one here node mcu pi flasher there we go yeah the other one the nodemcu wi-fi we'll have a look at that code in a second that's the actual code that we can create and run on our nodemcu to connect to the mqtt broker and send and receive messages so i'll show you how trivial that code is so on here this is um what i downloaded from github from the nodemcu pi flasher repository um from the person that i mentioned before was it marcel sloan something like that whatever it said on that slide earlier uh and then all we do is we because this has got a requirements.txt file that tells me that we can we should be using this with a virtual environment so you can see when i just looked into that file there's a couple of different things that it wants to be installed so i've already gone ahead and created the virtual environment but the way that you would do that you would type in python 3 and then dash m and then you type in vnv for virtual environment and then the name of the virtual environment i used to just use the same thing vnv and then so if i'm just going to do source um vnv bin activate which activates that particular virtual environment don't worry about this if this seems a bit high level it doesn't really matter too much there is instructions on how to do this and then i'm just going to do python and then nodemcu-pi flasher and that's going to run the pi flasher module so there we go this is the interface so i've got a node mcu um i just hold this up here um plugged in to my computer ready to go uh i don't know whether this one is going to work it's going to if it's going to place play good with us but then let's go ahead and see if it works so it has detected it on serial 001 it's asking for the nodemcu firmware so i'm going to browse into my downloads folder and i think on here i have actually got micropython so i'm just trying to find there we go esp 8266 dash and then a date dash bin so let's open that one and then let's flash our node mcu so if i go to the overhead now that flashed up got little led lights on it that just showed some activity the moment on screen it just says it's uploading stub see if we can do all of them at the same time there we go so it says it's uploading stub and it's just waiting for that to complete and once it's done that um we should have micropython installed on our little device uh interestingly it detects things like you know the the chip speed how much memory it's got on there um i think this one has got four meg of flash built in um still says uploading stub i would have expected that to do that by now i think that hasn't worked but this one it seemed to be playing up this particular chip that i was working on i have got another one we can try instead plug this one in instead and let's just cancel that let's just run it again and we'll just browse to that same file that we just had a second ago which was um that one there and then i'm gonna do flash uh actually i'm just going to check there we go so this node mcu device i've got here now is in is actually in um an official expressive motor shield um somebody calls it motor shield yep so similar to the uh the motor shields that we've used elsewhere in our smiles robots but this one works with the nodemcu it's got a lot of headers there i don't know if they are intended to be for servos but there's a whole load of them but we've also got the motor a motorb outputs as well so we can control quite a few robots um motors with that as well so i'm going to try that out with a smart robot myself just haven't got around to that yet so this seems to be having a bit of trouble i don't know what's going on there um i'll come back to that later but this is the tool i always use to flash this it usually works to be honest um so let's just cancel that it might just be something to do with my machine it might be because i've got funny in fact maybe that's what's causing it if both both pieces of software try and access the serial port at the same time um it messes things up that might be what's going on so instead i'm going to go over to thony which i've got on screen at the moment i'll just go back to that version of the screen and at the bottom of the screen it says micropython esp8266 and that's the chip that we use in these node mcus so i'm going to try flashing the firmware using this funny let's see if this will work so let's browse that same file it should it should be exactly the same that we've just looked at but instead of using pi flasher we're going to use this instead um we're going to connect to that serial port there and then install let's see if that actually works it's flashing as if it's installing there's a little bit of activity there then but it's giving me an error message on the screen which it says invalid argument no idea what that means it could be that i'm using something wrong there it's the same with whenever you try and do anything live it never works does it it's fine to say this is how you would install micropython on these things and just don't try and do it when you've got many apps open at the same time they're using the same ports or you'll get weird issues like this but let's go and have a look at that code that we wrote to connect to the mqtt broker so i'm going to go into documents and then i'm going to go into the micro python area so i've got folders for micropython for arduino and um for web stuff as well so this is the arduino one we want to scroll down until we get to micropython there we go and then there was one that's called nodemcu wifi and there's three parts to this file but there's a boot main and this mu mqtt simply dot pi that's the library now the thing with micro python is unlike the arduino where when you're compiling your code you'll import the libraries when the compiler compiles that code it bundles everything into the output into the hex file that it's going to generate micropython doesn't do that because it doesn't actually compile it and then load it it's an interpretive language so it will look at things what you know one thing at a time very quickly but one thing at a time from a file so it doesn't compile anything in that sense and that means that we have to have those three files on the device itself rather than having them bundled into one area so um let's have a look at the boot.pi for a second i hope there's nothing too sensitive in there no so it's all good let me just go to the full screen so you can see this code and um what we've got there in fact can we do that that's better so this is the thunni interface and i've got a couple of lines of code there so i've got import time and then from umqtt simple import mqtt client so that's going to represent our mqtt client stuff then we've got you bin ascii we've got machine we've got micro python we've got import network import esp um esp.os debug none no idea what that means and then import gc for garbage collection gc dot collect so it clears up anything that's in the memory and then there's a couple of variables there so we've got ssid for the wi-fi name so that's where you type in your wi-fi um ssid you know the thing that you connect to the password for the wi-fi the server the mqtt server we'll have a look at my mqtt server in a second but that's essentially just either a name or an ip address the client id is just the name that you want to give this particular device it can just be random but um yeah it doesn't really matter what that is as long as it's not the same as something else that's already on the network and then we have sub and pub so topic sub is b notification and topic pub is be hello so it's going to subscribe to notification but publish to hello and then it's got a couple of variables for something to do with messaging so this last message message interval and counter we can ignore them and then this is the code to connect to the wi-fi look how simple this is station equals network.wlan and then network.sta underscore if so that's like the station interface and then station.activetrue station.connect ssid password and then it says while station is connected equals false do nothing pass so that piece of code just keeps you um doing nothing until you get a connection once you get a connection it says connect dot successful and then it's just printing out the station ip address this code doesn't do anything further at this point this is just an example of what you can do there so that's the boot pi and boot pi is when you switch on a micro python device on like a battery this is the first piece of code it will run it's analogous to in arduino speak the setup piece of function so you have set up and then you have loop so this is like the setup area then we have main dot pi and that's like the loop in the void loop in arduino so this has got a bit more stuff in there so we've got a couple of functions one that's called sub cb and then it will it takes topic and message as parameters it prints out the topic and message and it says if topic equals b notification a message equals received then print esp received hello message so this is just testing um that you receive something there's another one that says connect and subscribe so what this function does here is it will connect to the mqtt server and it will tell us that it's connected and it will recl return a client which is just like an object an nqtt object that we can use in the rest of our code and then there's another one restart connect restart reconnect so if it fails to connect it basically just restarts the whole machine so that'll then reload the boot.pi and then come back to this piece of code and then this um it says while true client.checkmessage.iftime.time is minus the last message is greater than the message interval so what this is is kind of like a a way of limiting the number of messages you receive because it might be um you try and check too many times and then it causes a problem and i actually came up against this with the code that i'd written the really crude code that i'd written for the the uh the fan and the heated mirror in the bathroom i didn't have anything like this so that when a message was received i would hear the the um what's it called the relay in the um the sonoff clicking on and off very very quickly thousands of times a second kind of quickly and that's because it was running through a piece of code like this but without any kind of breaks on it so this is quite a sensible piece of code to just limit how many messages you get through in a particular message interval and then what it does is just list it's published into a particular topic and then it's just incrementing a counter and that's all that piece of code is doing there but that's the block of code there is where we put our messages um to send to that topic so we've got one to receive and one to send so it's very simple to use this a that library we can have a look in there but that's that's where all the sort of magic happens um and this is stolen from somewhere else on the internet but um yeah it's quite a big piece of code there but it handles all the errors that's not massive actually it was a hundred and two hundred and something lines of code it's not very big but that does all the processing specific to mqtt's and all that good stuff so that's how we would create some code put it onto our nodemcu um so it could for example get the the temperature publish that to a topic and then we can receive that into our mqtt server so i'm going to connect to the mqtt server i think i've already got this open in another window so if i go over to here and i connect to which is the one that we've used is it this one is it this one this is the one so this server here is this little terminal window is connected to um i just do if config yes 152 is the ip of my mqtt server so i'm just going to type the word screen and i use screen i use the screen command if you've ever used that on terminals it's a way if you if you have a session running so say on my apple mac i have um a terminal open and i'm connected to my mqtt server and i'm doing stuff i'm running some processes if that connection gets broken that terminal will cease to exist on that server and stop running whatever i'm running so sometimes i want things to carry on running even though i might have disconnected and the screen command can help you do that so you just type the word screen in it is something you have to install but um just do that app get install screen and it'll get you there so screen dash ls will show me all the different screens i've got running and if i do screen and then dash capital r and then the number of the server i want to connect to so i'm going to type in that one there which is 29458 and so it says new screen it's not really what i wanted so i'm just gonna detach from that one let's um let's just clear the screen let's try connecting to that other one instead so that was the lower number one the lower number one makes sense because that's probably the first one that was spun up yes right so this was this has actually stopped running so i'm just gonna i'm gonna show you what's going on here i have two processes that run on this um this mqtt server the first one is called mosca or mosquito and that's the actual mqtt server so if you install mosca or mosquito that does all the brokering that that is the server the message queue itself and it never saves these it simply is just a messenger in between so you pass it a message it checks through who subscribed to that and passes the message on and that's all it does it doesn't do anything else so it's very simple to use um so i've got a command there called moscow and then piped into bunyan that just gives it a nice colored output i think and then on another terminal i've then got um hap node.js which is that home kit application protocol node.js thing and if we look in this folder that we're in you can see i've got some accessories i've got core.js so if i go into the accessories folder i can see there that i've got a lofttemp.js so if i do cat loft temp.js i can see that the the code which is just javascript code to connect to the mqtt server and then output that to this hap node.js and that then passes it onto homekit and all that integration there so if i run this if i just clear that i go back down a folder and i do node and then core dot js that's now going to connect i can see messages there so it says hap node.js starting connecting to mqtt server and then it's got alex lamp fan connected gen bedside lamp mirror connected summer house sensor connected and then it's telling me about um the temperature messages that are coming through so they're the exact same messages that we can see on our node on our mqtt server on that node red thing that we looked at earlier they're the exact same messages but then that's passing that through so if i load up on my apple home kit here if i go to the bathroom for example i will see that there is a couple of devices on there one is the mirror one is the fan and i should see that they get a status on there as well and that actually comes through if i just go to that for a second i can see there's like various different tiles on here and i can see there that there is uh i don't know if you can see this there heated mirror off and fan on or off so if i click that and then i go back to that screen there you can see that turning fan on to turning fan off and that's if i press this you'll see those messages appear on the screen fan on fan off and that's what all this all this stuff that we've built um is actually working so i can press a button on my apple homekit device um i can talk to the um the voice assistant whose name cannot be mentioned because it's right in front of me that will pass on that message and it will activate whatever happens there and this homekit bridge this hap node.js takes those messages passes them onto the mqtt server that then publishes them as a message to the um the thing that's running in my loft little sonoff device that's got some code that's listening to that topic and then that goes oh fan off and then it will switch the fan on or switch the fan off so that's how we can plug everything together and i've got some other examples there so this is um another little um thing i built which is a little mailbox with a little um flag and if i just take off the front of this and show you inside the little blue thing there is a servo is one of the sg90 servos and that's connected to our little fan um blade there and that's also connected to a node mcu so we can just see that peeping through there so if i gave this power if i unplug this and i plug this in instead we should be able to see on our um on our server there um that this thing has appeared so probably just take a couple of seconds for it to connect to the uh to the wi-fi network uh and then i can't remember what i've actually called this which would help um but we'll be able to sort of send it a signal to say you know switch it up switch it down and it will uh raise or lower the flag so what i was thinking there is if i um if i get an email the flag could go up but given i get thousands of email junk emails a day it'd be up and down all the time but you get the idea you could have this maybe somebody rings the doorbell and this goes up or or whatever all interactive stuff so that was just a little fun project that i created um i found the thing on thingiverse and thought oh that looks good i know what i could do with that um so that's uh the technology so i've got a couple of things running there one is the the mosquito broker itself and then i have no um hap node.js as the software that's sitting between my apple homekit stuff and all this rest of the uh the home automation and then the um the node red is just in addition to all that so that's another way of putting another user interface instead of the apple home one we can just have that interface instead and switch things on and off so it's very easy to create a button on that dashboard that you can click on and off so um that's all the things i wanted to show you um to do with node-red i hope you found that useful and i said we would do a bit of a q a as well so i'm going to go through that as well and um i don't know if i've asked already if you uh if you like this content you find this valuable please like um like on this live stream now that's always good to do um subscribe to the channel if you're not already subscribed and hit that little bell just to make sure you get notifications when i go live i'm gonna put out the mid week video as well and i'm going to be putting out things on them spotify um stitcher and i and um what's the other one spotify stitcher and itunes so all the podcast uh locations and the way that i'm doing this i've got a piece of software that's called decrypt dscript and it will take my voice as you can hear it now put it into text i can then remove all the so um uh all those kinds of filler words it can just remove them it just cuts out the audio which is just mind-blowing that it can do this and then i've got some text that i can very easily put into a blog post and also the audio which has got rid of all those awkward pauses and live stuff that you don't mind hearing but when you hear is a pre-recorded thing you think maybe you shouldn't say those things um you can cut all those things out very easily so i can make a podcast um repurpose this content very easily so some people prefer to listen to things while they i don't know doing household chores commuting if that's still a thing um and you'll be able to do that by subscribing to the podcast on evil's platform spotify stitcher or itunes podcasts so the itunes one hasn't been approved yet it takes a little bit longer but spotify we're just like yeah yeah whatever um the thing with that is um you can subscribe to um podcast if you're if you're a make if you're a video content creator and you want to host your podcast somewhere you can do that but it cost money and i was thinking i don't really want to spend any more money on that i'm sure i can figure all this out myself and all they require is an rss file and the rss file let me load this up i can show you what this is all about um it's just um a real simple syndication it was something from the early days of the internet when people used to sort of want to get news articles from all over and then to syndicate into a simple place and i thought that that looks like an interesting thing to do um how can i create an rss file without um having to pay money to somebody else to do that for me um i'm pretty sure i had that on the yes on that one there i'll show you this on screen in a second uh and the thing with um rss is it's xml and xml is ugly i find it like tedious to write that i want to write something in yaml yaml is a much more elegant way of writing data into a file it's more human readable so let me show you what what i needed to do i'm just going to get this loaded up here first before i share the screen there we go right so if i go over to here so can you see that let me see if i can zoom in a bit there we go so if i hide that and get rid of that you should be able to see a bit better right so this is yaml this is yet another markup language uh it's much easier to write because you just write the whatever the key is and then the call on and then the the value that's going to be paired with that key so i've just done like a description you need to have all these like subtitles summaries types is it episodic or serial um uh how's it going image what category does it fit into is explicit and so on um so this is what i created and i created a little rss generator which is just some python code which will read in that nice yaml file and spit out an xml file in all the right formats so if i got the actual xml file there on screen i can share with you if not i can just click it from the uh from here which is podcast xml there we go so it outputs this um xml file which is the rss feed so that means i can just update that very easily and then save it to upload it to github github is where i build my smartphone website which is what all this stuff is built all from markdown and then you see the finished article within about a minute or so and also that means the rss feed is updated so all i need to do to add a show once i've built in decrypt in descript is to just update this yaml file run the generator and then save it to github and everything else just flows from there you've then got a new show so without very much effort i've created like quite a lot of extra content so that was one thing i wanted to share with you so if you go to spotify and you search out the robot show uh it's nice red um let me show you one here nice red background um so if i go to um spotify for example it will be on the apple one by the end of next week but um there have been problems with that right so it's this button here which is the robot show if i just click on that there's only one short moment which is the one i did last week uh about the five issues but if i just hold up my screen there you can see the robot show with kevin mcclair so it's the robot show red button a little smart robot and uh yeah you can find that there so that you prefer to listen to that you can listen to the show usually a shortened version of that right over to questions so i've got a few questions on the screen here let me see if i can get these up a bit easier so here we go so sean says um uh i feel like i missed something watching these videos i'm looking through the documentation but what power does smart mini run on and whereabouts is it right so so let me confess something to you well the idea of this mars mini is that it uses a really small battery so the design i put together um i haven't got the battery to hand but i know you can get really small um lipo batteries that are flat and the idea is that they would fit underneath this between the motors and this little motor holder board so i've been working with laurent and he has ordered a battery he's fitted it and he just designed a very slightly i think it's slightly taller and slightly longer designed version of that if you go to thingiverse you'll find that there i was thinking that you know do these need to have power i'm going to power it through the usb cable through the tiny and laurence also designed the um the tiny holder on the back little backpack that this sits in so it's worth having a look at his uh his version of the design there and once i've got my battery delivered i had ordered this about two weeks ago and then i got notification from amazon saying that the order had been cancelled i guess ordering batteries is tricky they have to get special permission with the the air companies the flight companies um i don't know it's just one of those things i think so yeah i'm gonna have to order that again um so somebody else says i want to learn to build robots um i like everything you do so i've been thinking about this i'm gonna do an episode probably the midweek one on how to get really started very basically with robots and i'll show you the back of my room over here [Music] a bag of um this is this kit cost me three pounds i think from ebay and what you get on there is um i think i've not got the the motors for this but you essentially get a board which is the body of the robot um and then there's like a rounded um nut on there and that's going to drag on the floor and then the two motors sit either side of that and then you've got these little wheels that plug into them and then there's a bag of components there and this this particular robot i think just detects light uh or follows lines i'm not sure which one it does it looks like it's got some line sensing diodes in there so um i guess you have to solder these on but there are other variants which you can buy for a similar kind of price they use they have those yellow so the motors are pinched for the uh smart crossover version so this smiles robot has the uh the wheels built into there and that's the it's a cross between um an auto diy which is sat there and a smart robot so that was one of the one of many projects i started we don't finish there's the exact same kit but with the motors in the bag so i've got a few of these it has like a battery compartment as well in there so very easy to put together and then i've got another box here which has got a larger version of the exact same thing so this one has the same yellow motors in there a much larger battery compartment and a wheel instead of the um see the wheel there and then what it's got in there um it's got all kinds of components some great big wheels there's a great big chassis in there but we also have things like um that is the motor shield it's one of those l298s are they called it has some servos it has a motor shield um not sure what that one is it's called sensor shield and it also has an arduino you know in a little bag now this thing didn't cost me a lot of money i think i bought it from maybe aliexpress there we go and that's the size of the the chassis that that's going to sit on so i was thinking maybe i could do a show on that you know putting this together showing what that looks like uh it's also got our favorite little range sensor there as well the hc-04 that was sr004 but that's an entire kit there and there's some instructions um how to build this so it's an arduino powered robot and everything that you need to build is in that kit there so that's for another time but that's how i would get started in robotics i would buy one of these very cheap kits i would put it together and then i would take it from there that's how i got started i bought pretty much the exact same thing as this um i've actually given it away to somebody i have those yellow motors on it um it had the battery compartment on there and then it had an arduino plugged into the motors controlling the motors on and off and i brought the code myself um just using some code that found online about how to build some robots and that was the thing that got me started and then i bought a 3d printer because for me the physical side the engineering side was always a bit of a challenge because i don't have ready access to the tools and things to make these um you know to build these plastic shapes and things so and i'm not great at woodwork so for me the 3d printing was the thing because i can design things and i can print them out and that's where i got started with things like the uh the crab robot and you know modifying that just before this show started i was working on the uh the new versions of the claws i've got to the point where this crab was working i put the claws on these red ones and i've made a bit of a design mistake so this round hole here i don't know if you can see that that's where the uh the servo horn is supposed to go but i've not left a hole for it um so you can see on this one um this one has got a cut out area and that's where the servo horn can go in to actually make it move so i've had to print out some slightly different ones and also change my filament to black as well um because i was printing his face he's got a little face plate now and so he's coming along just having a bit of an issue with some of the servo code as you can see there he's kind of only got one limb on he's got his old leg on there as well he's on the foot so that's how i would get started in robotics i would get a kit very cheaply because they've kind of solved a lot of the problems for you and it's just a matter of following the instructions to get you into it and then from there you can then develop all the different skills that you have now i am working on um a learning system for getting started in robotics it's quite involved a bit of work for me to get it polished and up front but um it is in the works uh i'm hoping to to you know get this out there very soon and um you'll be able to sort of learn from there as well so that was uh how do you get started to answer that question um so brian moore says i hope you're keeping well thank you very much brian hope you're keeping well as well and um i've got peter long give me a thumbs up there as well thank you for that and then my auntie marlene says i'm going to need you to turn the thermostat down 26 degrees i'd be melting my face off if it was that hot in there i think the the sensor must be a little bit out perhaps um and then my old collie joe my friend joe always saying uh if you have trouble with smiles i recommend kevin's new podcast about the five fixes thanks joe i should have you as a moderator from my show really shouldn't have i'm lacking a moderator i think kevin's had a sixth issue that's right loading code um yeah i think i had too many ids open all trying to connect to the same uh at the same time so and uh what joe also said the interesting facts about the battery for the micro bit apparently it was decided to drop the watch size battery for two for two aaa's of concerns it was a choking hazard so i did start out using some of these um watch batteries i mean they wouldn't last very long to be fair um trying to drive some motors but um it was more just how can we keep the size how can i make a robot as small as possible i've even found some smaller motors i've got them on order at the moment they are like watch type servos well the stepper motors but they're even smaller than this so and the other thing i was thinking maybe i shouldn't share this now but we've gone small with smarts maybe we should go large maybe we should have like a smart xl a smiles pro or smiles mega what what's the best name for that mega xl smiles big smiles tell me what you think in the comments and uh we'll name that but yeah i'm thinking about a much larger version of smiles where we can put some proper batteries in there like the 18 650s maybe like four 18 650s um bluetooth modules wi-fi modules the whole work so space won't be a premium and we can have some great big wheels on that as well and uh bigger tracks everything can just be sort of scaled up so that's been on my mind as i think that maybe to sort of design and build uh be a lot of fun but keep all the aspects the same all the sort of same look and feel and it was interesting in the uh the facebook forum um kevin thomas the designer of smiles um he said he designed smiles about three years ago and uh he was a student at the time when he was designing this i think he's just finishing his studies now or just finished um but he says he's learned a lot since then so he's thinking about doing some updates to smiles uh given what he's learned since so can't wait to see what he's come up with there um so a message there from shadowcast great video very informative thank you for that that's what i aim for aim for sort of informative and fun i've got my two post-its notes there that says be informative and fun i'll try and do that and if you do enjoy the show um you can always help me out by going to buymeacoffee.com uh slash kevin maclean that can help pay for this soft web hosting royalty free music that i use at the beginning of the show the graphic software canva for doing all their thumbnails and stuff and all the graphics on the screen the streaming software i use as well ecam and all the fancy equipment that i have to bring this to you in a high quality way so the microphone the lights the camera eye watering the expensive camera um computer use and all the other stuff as well uh nobody's bought me coffee in the past two or three weeks would you believe i think was it laurent was one of the last people or tom i think tom might be one of the last people to buy me a coffee just saying that if anybody wants to reach out and help me out um if you've not checked out um if you don't know already i do a video every sunday so um who do we have at the beginning of the the start there sean was saying um this is one of her first videos that she's watching me live so i do this every sunday at seven o'clock gmt it's gonna be seven o'clock bst now isn't it because um it's british summer time so maybe i need to update my slide because that's about an hour out isn't it um but yes if you live in the americas or canada you'll your time zones are on the left hand side there in the middle column we have the european zone pakistan india and russia and then on the right hand side we have china and australia and i think maybe another russia as well i should find out because i always say that but there are all the different um time zones and if you've not checked out smilesfan.com that's where i upload all my code and um blogs and videos and stuff there's just lots of things on there you can even buy parts on there as well from the little shop um i do have to say with the shop um there seems to be a bit of delay getting some parts to people i've seen it take um a couple of weeks actually to get some parts through so um not seeing don't buy from my shop i'm just saying if you do just be aware it's not like next day delivery for some of this is the price is reflected in the the how quickly you get the parts so um it isn't um i looked at having some of my own local stock here um but it can it tends to be very expensive to post that out um so it can be quicker i just get it direct from them for supply to you it just takes a little bit longer so there are some options there for you so that was the q a that was the website stuff and we talked about the coffee i think that is everything so check out the podcast as well let me know what you think about that um if you've got any other questions any of the follow-up um please let me know there i'm just going to do one last check of the website um the facebook group so i run two actually run three facebook groups uh the small robots group is the one that i own uh the smiles community is one that i'm an admin of i don't own that one that's kevin thomas's and then the there's one that's raspberry pi pico i'm already a mod of that as well and we've got 2.3 000 people in the small robots one this is just mind-blowing but i did say if people had any questions and some people did come through and they they have some questions there um and it's corinton who was asking the questions before about how did you get started in robots it just didn't show up on the the feed there let me just scroll down to the there was an interesting video that somebody posted of a horse in the uh smart small robots group and i've got a robot that's just on my shelf back there that's a spider that works in it almost exactly the same way and i thought that was interesting maybe we could do something with that so yes i've got some other questions i just wanted to quickly cover off um so one from pedro and he says i want to make smart mini robot um put it to work and i said what specific problems you have in there and he said um he just wants to get started in robotics he doesn't know anything about that and he just wants to to do i do so yes buy a kit play from there is what i would say and then mohammed was saying what's the difference between the robot cat made from a raspberry pi pico and the one that's from the arduino nano and the servo driver is its power or speed or speed of processor so he's asking really why have i chosen to use the pico and it's because you can download the open cat and you can get that working right out the box with all the code that's already there but i'm one of those people that's like bleeding edge cutting edge i want to do something that hasn't been done before so nobody's got one of these open cats working with a raspberry pi pico so i thought i'll be that person um because a it's a bit of a challenge it's interesting and you learn things along the way doing these things so i learned that there wasn't readily available um pca 9685 drivers for the micro python for the pico so there is now and um yeah what was interesting is the the creator of um the open cat got in touch with me and said hi because that was actually in the raspberry pi magazine this month so in the april edition of the raspberry pi magazine on page 77 you'll see a nice picture of the uh um the open cat pico cat as i call it um on my 3d printer with the um the raspberry pi pico at his feet so that's why that's why um because it's like why do people climb mountains because it's there it's the same kind of thing really you can do it another way you know but if there's a hard way i'll do it that way because that's the way i'm wired uh and he says what is the best control kit for the cat and how does it differ and what the effects so the control kit i think the original one was designed for that pca board where you can plug all the different servos in it might not be but i'm pretty sure it was um you can plug it directly into all the pins on like any you know an arduino this there are quite i think there's an 11 servo so you need to have at least 11 pins that you can address um and you know is there any benefit from plugging them all in i don't know i find it easier to plug it into a separate board and just have one pin coming off that two pins coming off that you can talk to it control each one individually and the code that i'm writing i'm building a library up so i've got like a strategy here i want to get my um my in move this robot here built and working he's got his torso just behind me there and his arms just there as well that's one of his arms and i kind of started this without realizing just how difficult it can be to build one of these and um what am i saying here so that's when i went to smaller robots i thought i can experiment with smaller robots learn what i need to learn there like how to get servos to work how to use micro python all that kind of stuff and then i can apply that to the larger robot and the larger robot can do interesting things like it can do you know image recognition it can do face detection all that kind of stuff um and i've experimented on smaller things so speech recognition um speech synthesis i've done that with um raspberry pi zeros i've done a video on that i could apply all these things to that so that's why i wanted to keep everything in the micro python or python sphere so that all the code works together and i've not got bits of code that don't work with other things so the code that i write for my cat i can use on the crab because they just sort of arms and then that can also work um right back over there we've got two um three actually quad robots that code can run on them as well because it's just legs and we have a class for legs in in our python code so we write it once we can use it many times and then we can build other interesting robots with that so we've gone quite a bit over time today and i'm gonna try and keep these to about an hour and a bit like nearly two hours in now so i think it's time to draw that to uh to a conclusion so hopefully you found that interesting i've answered all the questions that people have raised this time if anybody else has any questions um for next week's show feel free to uh to reach out into the small roberts group drop me a message there and uh yeah we can take it from there cool hopefully you found that interesting today um i've really enjoyed doing this one this week and i shall see you next time thanks everybody bye so [Music] [Music] you
Info
Channel: Kevin McAleer
Views: 1,955
Rating: undefined out of 5
Keywords: node-red automation, node-red tutorial, node-red home assistant, node-red dashboard, node-red dashboard tutorial, node-red mqtt tutorial, node-red raspberry pi, node-red projects, raspberry pi zero, raspberry pi, micropython, esp8266, nodemcu, how to flash nodemcu esp8266, how to flash nodemcu 8266, how to flash nodemcu firmware, home automation, ifttt, If This Then That, HomeBridge, HomeKit, Apple Home App, node red iot projects, Kevin McAleer, IoT, mqtt, What is mqtt
Id: hiVcgUdjy0A
Channel Id: undefined
Length: 98min 50sec (5930 seconds)
Published: Mon Mar 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.