Use a Raspberry Pi to power and parse data from an Arduino (EASY!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm going to show you how to simply plug your Arduino in the USB port of a Raspberry Pi get the data off of it and then use that data in some really cool ways and you won't need any programming you won't need any networking you just plug it in and start dragging stuff around let's get started okay so I have a Raspberry Pi I think this is a three B+ or whatever it doesn't really matter you can use a one you can use a zero if you want but I've got a Raspberry Pi 3 B+ plugged in to the network which is completely optional and it has power if you want you can connect up your monitor keyboard a mouse that's fine but basically when you plug one of these things in you want to consistently use the same port so whatever Arduino I'm using like let's say if I have one doing the temperature and humidity and another one monitoring my garage then the temperature and humidity one will always go in this port and the garage will always go in that port and so just be mindful of that when you do this and so we're gonna take this and we're gonna take this uno generic you know with that sketch on there and I'm gonna plug it in to the bottom port I tend to always use the I tend to always go like this one two three four just to remember which port I've plugged everything in but now that it's plugged in we're ready to move on to the next step okay so at this time you have your Ord we know connected to your Raspberry Pi via the USB port I'm going to assume that you have the Raspberry Pi turned on and we are going to access node-red now there's two different ways to do that and I'm gonna show you a little bit about both of them so the first way is if you have a monitor keyboard mouse attached to your Raspberry Pi you can do it through the user interface there and so I'm gonna i've got V and C connected so this is gonna look like crap but basically I'm connected to the Raspberry Pi desktop so there's a few things you want to know one is to get to know to read I'm gonna do it the wrong way first so if I were to come on here if you haven't used node-red before and you do this you do 127 dot 0 dot 0 dot 1 colon 1880 there's a good chance that time it ran of course it did if it didn't run then what you would do is come here to the menu and programming and node-red and what will happen is if you run it in the little terminal window which you won't be able to see it now it'll show you it'll give you a command of how to auto start no dread when when your pie boots up but for the most part I think of the new ones it's all I've started so that's not bad but if it isn't you can just come here to programming and know to read so then you would access it by doing one 27001 and that's fine and the newer your Raspberry Pi is the better the user interface will feel doing it straight from the PI I tend to prefer to like to do it over the network so if you want to access it remotely from your network then it needs to be on the same network that your computers on but basically you can hover over this up/down thing and it's gonna give you the IP address of your PI which is in my case is 192.168.1 oh four you can ignore the slash 24 so I'm gonna close this down and then you can do the same thing over here you can go to 192.168.255.255 anyt and install and type in serial and the first one will be what you want node node read node serial port but that should be installed by default if you're on a Raspberry Pi I'm using the latest version but I think going all the way back to Jessie so I mean Jessie Buster you know all that like they all should have it so basically what's gonna happen now is I'm gonna double click on this and you see I don't have any serial ports on here so I'm gonna hit the pencil and then I'm gonna hit search and what its gonna do it's gonna bring up three options now the the USB ports either show up as a ma or USB now I'm not sure which one it is at this point so I'm gonna just hit USB take it hope it's a good guess and then the baud rate is your serial begins speed here so I did 9600 9600 doesn't sound very fast but with the type of thing we're doing that's plenty fast so I'm gonna set that at 96 and then there's really nothing else you need to set I'm gonna hit add and then I'm just gonna give it a name I'm gonna it's an you know so I'm going to do or do we know you know hit done and deploy and you'll see that I'm connected now if you weren't connected then what you do is come back here and do the same add serial port thing again and select the AMA one but the thing is that this is every single time you plug in your Arduino you want to plug it in the same port on your thing so generally what I do is I start at the one low by the network connector and then go high by the network connector and then do low away from the network connector and low and high away from the network connector so I just have like a little system that the the four of them that I connect go on that order so I'm gonna connect this to a debug node which I just drug in from over here and I'm gonna go to this little bug in the upper right hand corner and when I click that I'm gonna tell it to just show me current flow and you could if you get a bunch of things going on I it's to me it's easier to keep this on current flow so I'm gonna hit deploy and we should see yep so we're starting to see those things to come in now they have the under symbol at the end so we'll see how that affects it but basically we see these things coming in every two and a half seconds where they have this h equals T equals and random equals so we're getting our data which is sweet so what we want to do is we're gonna break this we're gonna pull this out we're gonna break this and hit deploy will clear this so we don't see all that other information so now what we want to do is we want to begin parsing that data so there's a lot of different things you could do you could use JSON you can use other things but we're keeping this as absolutely simple as possible so we're gonna use the switch statement and so what we're gonna do is we are going to say that if it contains T equals then send it to the top little dot and then we're gonna add another one and we're gonna say if it contains H equals we're gonna send it to the second one and if it contains random equals we're gonna send it to the next one and then we're just gonna put let's see I'll leave that there I'm not gonna do an else so basically it's only going to do something with it if it contains T equals H equals or random equals and just to remind you those are coming from here T equals the temperature 80 equals the humidity random equals R and so what's gonna happen is we're we're gonna hit done and you're gonna see there's gonna be three dots here so now we're basically what they call parsing that data so that it goes to these different things now in our situation let's let's do this let's drag this so that the only one that gets debug is the random numbers so when I hit deploy we're gonna see that the only one that comes up is random everything else gets thrown away so cool or parsing data and so now we're basically sending each one of these things on their own track so what that means is that we can come over here and we can use this change thing and let's stick with random for a second so we can stick with the change and we're going to come in here and we're basically going to say change and we're gonna search for random equals and we're gonna change it to nothing so basically we're gonna strip out that random and now if I come here and hit this and hit deploy you'll see that now all of a sudden it's just giving us the random number now if we click on this you can see that it's not actually that seventy-three the little inter symbol isn't really in there it's just it's just telling us that that's the end of the line so I think we're good there so basically what we can do now is we can come here and we can paste this and we can make two more of these and we can change T equals to nothing and we can change with the H equals to nothing and so now we've got these three little things and now we have our raw data back okay so basically I've stripped that stuff out so I'm gonna go ahead and put these back into the debug node so we can see what data we're getting and now you'll see that we are getting just the raw data and so we can see here that you know we're just getting raw data we're not getting all of these other we're not getting all the T equals eight equals and all that kind stuff so one of things we probably want to do is come in here and call this one temperature and call this one humidity and call this one random okay it's now we're deploying those so we have our data here we have the temperature the humidity and the random number going on here they're all being parsed we're down to just the raw data so now what we can do is start making our user interface so if you haven't followed me in my videos you probably have an installed node-red dashboard so we're gonna go ahead and do that if you have you can skip ahead so what we're gonna do is we're gonna go to palette manager and then we're gonna go to install and we're gonna type in dashboard ok node-red dashboard this is the one right here the second one node-red dashboard install it's gonna take a minute so I'm gonna just pause the video ok so what that did is that added a whole bunch of things down here and this is real similar to what I've done in some other video so I'm not going to spend a ton of time on it but let's say that we want to I'll tell you what let's try this let's try a couple different ways to do it so the first one will do is the gauge and I'm gonna double click this and I'm gonna tell it to add a new UI group just like I did with the new serial port and I'm gonna add a new UI tab and I'm just gonna make it as wide as I can make it heat if you know if you know how much I hate this thing like it doesn't ever want to drag so I'm gonna get it close there we go we're gonna take it and we're gonna get a great fan-freaking-tastic so anyway adding a new UI tab and we're good add let's see that's 16 that's perfect can you just types it now you can't tell you okay so we've got that now we have added this gauge and basically because our random number here is between zero and a thousand we're gonna make our scale here between zero and a thousand on this thing and then we're gonna get rid of the word units and we're gonna give it a label of random number and I'll just call this random gauge so what we've done is we're gonna make this gauge and it's gonna bounce around as this number changes so if we come over here connect it to the random number hit deploy since installing this dashboard we have a new thing so you can basically take whatever you have up here up to the 1880 and you can do this and put a UI at the end and you'll see that now all of a sudden we have a gauge and that gauge is gonna is going to bounce around based on how big the random number is between one and a thousand so sweet we're visualizing some data so the other thing we could do we could do a very simple text one let's take this and we're going to drag this together we're going to double click it and we're going to call it temperature and we're going to I like this label style and now if we click this done display we come back here without even refreshing the page we have the the temperature showing up up here and then we'll do one last one let's do uh tail let's play with this let's I've never done this one before so let's do chart if I double click this and do I'm gonna do the last second oh that will do the last seal last ten minutes I don't know I'm making this up as I go so we're gonna call it humidity and I don't know we'll pick a color fantastic blue I'm a fan of blue and we will call it humidity and done drag it together hit deploy come over here and now let's see what happens oh oh we got a chart going on this is cool okay so all of a sudden now we're making a chart of the humidity over the last I'm guessing I think I put an hour and so as more data comes in you'll notice we're not refreshing the page it's just making a chart of this random humidity and so very cool very very cool that in just a couple of minutes we were able to do stuff with our data now if you haven't played around with node-red there's a lot of stuff you can do here so in other words let's let's take the same I'll tell you let's take this random number here and you can do some more logic on it like let's say you want to add another switch statement here now you can keep this connected here but I can add a switch statement here and I can basically say if it is greater than 900 do something and if I can I can say if it's less than or equal to 900 do something else and so like let's say in this situation I would want it too if my temperature whatever that random thing represented it hit it was over 900 I might want it to email me and so like I could drag this out here and if it was over that then I would come in here and I I put in my gmail information and it would email me if it ever hit that high or it could tweet something you know you can you can do all kinds of different things here with the logic you could send this information to Watson IOT you can blast out MQTT messages all that stuff but the point is that in just a few minutes we were able to plug this thing in know networking know crazy code and parse this data and actually do some fun stuff with it and get our charts in order and you can you can make these as fancy as you want but this is just a real simple simple way of doing it so anyway thanks for watching
Info
Channel: AnotherMaker
Views: 13,199
Rating: undefined out of 5
Keywords: node-red, arduino, arduino serial, pi, pi serial, raspberry pi, orange pi, banana pi, pi arduino, arduino pi, arduino node-red, node red, node red dashboard, node-red-dashboard, serial node red, serial-node-red, parse data, parse data pi, parse data arduino
Id: U2u1jvcUXBc
Channel Id: undefined
Length: 16min 26sec (986 seconds)
Published: Fri Jul 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.