How To Receive Multiple Sensor Readings From Your ARDUINO Into Your MIT APP INVENTOR 2 APP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to the zot today I would like to show you how you can use your Arduino with an MIT App Inventor app to receive multiple sensor data from the Arduino to the app now for this tutorial I am using a dht11 which is a temperature and humidity sensor in one and I'm also using a photo resistor and that'll tell us the level of light now um for a schematic on how this is all set up just uh look in the description below and you'll find a link for this uh Project's website and I'll also have a uh downloadable copy of this app if you want to try that out yourself otherwise after we go over the uh circuit here real quick we will go over to the computer and I will show you how to build this app and modify it for your needs now for the circuit of course we have an Arduino board I'm using a nano then we've got our Bluetooth module and this is an hc06 hc05 will work too if you have one of them instead of hc6 and I am running it through a logic level converter because the hc06 is a 3.3 volt logic and the Arduino is running 5vt just remember when you use the uh logic level converter the Arduino or excuse me the Bluetooth module itself has to be po powered from a 5V pin because it needs 3.6 Vol to 5 Vol to operate and if you run off the 3.3 volt pin it won't work but everything else goes through the logic level converter and for more information on this U just like I said go to my website and I actually have a tutorial I've already done on how to use these and hook them up to your Bluetooth modules then of course we've got the dht11 and this is the cheaper of uh all the um temperature and humidity sensors it's not the best for accuracy but uh for this demonstration it'll work there's another one if I remember right it's the dht22 and that one is more precise then what we have is the um photo resistor and that is hooked up as a voltage divider to get the readings out of it cuz you have to hook it up that way or you're not going to get correct readings and um there'll be more information about how to how to hook that up and do it on the website as well then for the app we'll hit connect and we'll connect to my HCL 6 now this app reads takes a reading about every 5 seconds and uh that's plenty um you could actually set this up to probably read every minute or two and you don't really need a temperature reading every 5 seconds but maybe you want a light reading every 5 seconds or every 1 second it's up to you how you want to set it up and I'll show you I've got a lot of light here from the studio lights so it's not going to drop too much I'll cover it up and you can see it did drop down I'll just show you the temperature and humidity sensor working as I heat this up it will take the humidity out so the temperature will go up and the humidity will go down and I'm just simply got a little hair dryer here and as you can see the temperature went up and the humidity went down now there's lots of applications for using the multiple sensor data coming in and before I put this project together I did some research on YouTube and I found three or four videos dealing with how to get multiple sensor data into your MIT App Inventor to app and one of them was in Spanish the other two I think they're Arabic or something like that they were from India um whatever language they speak there I'm sorry I don't know but um I did not find very much information at all on how to do this so I watch the videos and um was able from the screenshots as they were doing it not understanding what they were saying figure out what was going on and that's how I came up with a setup all right with that I think what we'll do is we'll go over to the computer and uh I'll show you the Arduino sketch first real quick um unless you're going to be building this exact circuit you might want to Skip by that and uh after that we'll go over to the MIT App Inventor 2 and I'll show you how you get the data in all right well I'll see you at the computer in just a moment okay now once you've went to the website and copied the code just um open up your Arduino IDE and simply paste it in now we are also going to need a library for this we're including the simple DHT library now to get this Library simply click on sketch go to include Library go over to manage libraries click on that it'll take just a moment for this to load up then in the search field just type in dht11 and as you can see here the second one that shows up it's called the simple BHT now I already have it installed but um you on your screen you'll have a link right here you can click and install the library now as you can see this sketch is pretty short this is the whole sketch right here so what we got is we're defining what pen the uh DHT 11 is on and we're using pen two if you use a different pen simply change this then then we're defining the uh the pin that the photo resistor is on and we're using analog pin one so you put A1 or if you were using analog pin 2 whatever just change that then we're create creating an integer called LVL level and that's to store the value that's red from the photo resistor now of course we got to do our serial. begin and we're running at 9600 if you're using a different rate with your board just just simply change that but 9600 is pretty much default so then what we're doing here is we're making two bytes one for the temperature and one for the humidity then what we're doing is we're reading those and I set this up if it doesn't read it correctly it'll go back and start over instead of giving you um an output that give you the wrong numbers on your Android device if it does read it correctly it'll continue on and what we're doing is we're reading the photo resistor that's what this is here then we're doing a Serial print not serial print line cuz we're printing everything in one line then when we get over to the um MIT App Inventor code I'll show you how we're splitting that apart so first we're printing our temperature reading then we're putting since it's in Celsius we're printing a space and then a c then we do not want a space after that what we're doing is if you look on your keyboard just above your inner key if you hold the shift down and push that button and it's got a straight up and down line now I chose this you can use a different character or number I chose this cuz in all the sketches I've ever ever done in Arduino I've never used the symbol or ran across it anything so you'll be pretty safe using this so then after that we're doing another serial print and we're printing the humidity Then followed that by another serial print which is a space and then a percent and of course again we're putting our symbol here that we're going to be using to to split this apart in MIT App Inventor then we're doing a Serial print line because this is the final value and then we want to send it as a line so we're just printing a LVL then uh I have a delay here and that's uh 5 Seconds now on the MIT App Inventor app what you're going to want to do is you're going to want to read have the clock fire about half that time or even quicker if you're doing both at 5,000 you're going to get some problems and um I I'll just let you try that yourself and you'll see what I mean it just doesn't work very good now I would not run any faster than 1 second CU what I've noticed is you start getting lots of Errors occurring because you're reading it so fast and if you're using this setup and you're going to have the device on all the time reading this I would probably put this at like a minute or two there's no real need to get a temperature humidity and light level reading every 5 seconds but for this demonstration we're setting it up this way so that you can see it working faster all right um now we'll go over to the MIT App Inventor I'll bring that up and we'll run through the blocks on that and I'll show you how to get it done see you in just a moment okay okay now once you get MIT App Inventor 2 opened up just start a new project um name it whatever you want now I've already completed this one to make this a little faster but I'll run through it and show you how it's done now as you can see to start with the only thing on the screen is the connect button now if you use multiple screens in App Inventor you have to reconnect to the Bluetooth whenever you go to a different screen so what I've done is done virtual screens so after you hit the connect button this will actually disappear once it connects to your Bluetooth device now let me show you the hidden elements as you can see I've hidden the temperature humidity and the light levels down here I've got scroll ability turned off cuz it wasn't needed and I've got everything set to be centered when it's up and when we get to the blocks editor I'll run through all that with you real quick but um we're going to need a Bluetooth client and and we're going to need one clock and that's all we'll need with this now if you don't want to put this together you just like to download download this and try it right away on the website I'll have a link that you can download my app and try it out and if you want you can go ahead and build your own modify it to your likes so over to the blocks now to start with of course we have to connect to the Bluetooth device and that's what um these two blocks are for this one is your list picker and lets you select your Bluetooth device you're connecting to then this one sets it and connects it to your selection from that list now if it turns out to be true that it is connected then it'll run through this block and it sets the clock to fire then it sets the the list picker which was the connect button it makes that invisible so it turns at false then the temp humidity and light and there's a label and then there's the um the name of it so there's six of them here and you got to set them all to True scroll down here next we're going to need two Global variables the first one is I've just called it list and we're creating an empty list now the second one is going to be used for your data that um you're receiving from the Arduino board so what we do is when the clock timer fires it checks and if it is connected then it'll call and check to see if the bytes of available to receive is greater than zero if it is then it'll go through this and what it does is it loads your input your sensor data into the global variable and it goes down and this is where we use that little character right there for splitting it it splits it at the text and it's taking the global input which is that variable and it splits it everywhere one of these symbols is and then it deletes that symbol so then what we do is it puts them into the list and there will be three different readings in so then we simply set the the text to those three labels to what the the sensor data you've inputed is it's that simple this is really easy to do then what we do next is we're just deleting everything that's in the list and what was in the input so the next time it comes around it's empty and ready to go with that I don't think there's really anything else to go over I hope you found this information helpful um if you did please give us a thumbs up we would appreciate it very much and uh just remember you can go to the website too and there will be a written out tutorial on this and there will be pictures of the block diagram and that's where you'll get the Arduino sketch and all that and I'll have some more pictures and info on there so thanks for joining us here at the Z Hut today hope you have a great day
Info
Channel: Z-HUT
Views: 213,283
Rating: undefined out of 5
Keywords: mit app inventor 2, arduino, sensor, tutorial, dht11, dht-11, photo resistor, photo eye, dht22, dht-22, how to, temperature, humidity, zhut, z-hut, z hut, app, Receive Multiple Sensor Readings
Id: 5YovICoYCLg
Channel Id: undefined
Length: 15min 15sec (915 seconds)
Published: Sun Dec 11 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.