Placeholder Image

字幕表 動画を再生する

  • please go to the line.

  • The computer guy dot com In order to view schematics, code and Maur for the projects that you are learning about welcome back.

  • So in this video, we get to pull out the turkey baster.

  • So what is a turkey baster have to do with Arduino projects?

  • I'm gonna show you in a couple of minutes.

  • So the project that we're going to be dealing with today is we're going to be using a soil moisture sensor for an Arduino again.

  • When you think about creating art, we know projects.

  • One of things you should think about is what are the real world applications?

  • What are the real things people would actually care about?

  • And one of the things really is basically determining whether the moisture in the soil is of the appropriate level.

  • Think about how many people have flower gardens or urban gardens Or basically, you know, all the people out there they've got always wonderful potted plant.

  • Some have to replace a part of plants every month because they forget to water them where they overwater them.

  • Right, This is a really this is a really legitimate issue watering your plants the appropriate level is a really a problem for real adults.

  • And so what this this soil moisture sensor does is basically it reads the resistance between the two prongs s.

  • There's a positive problem in a negative problem.

  • You put this into the soil and the current tries to go between these two problems and it sees what the resistance there iss.

  • So basically, the Maur resistance there are is the dryer.

  • The soil is the less resistance there is, the wetter the soil is.

  • So we're able to take that as an analog reading.

  • So we're able to get a number output and then when Once we have that number output, we can make that a value of a variable.

  • And then we can put that into a function for all kinds of different things to happen.

  • Maybe you could post to a server, So if you have, if you have these with Arduino, you know, wife eyes in multiple different gardens they composed to a server.

  • You can wake up in the morning and you can see which gardens should be watered or wish garden should not be warranted.

  • And if you don't want to connect to a network.

  • Maybe you could simply have the Arduino, you know, have a green led or a red led a green led.

  • If the soil is right, a red led.

  • If the soil is bad or again, we're in the yard, we know we're in the yard.

  • We know world.

  • Not only do we want to be notified of problems, but really, if the system can automatically rectify the problem, that's really the good thing.

  • That's really what the modern world's about.

  • So we can also have is we can have the art we know, you know, basically be able to read at the value of the variable.

  • And if that value of is whatever it should it be, it could do something, such as turn on a water pump to automatically water people's gardens.

  • So again, imagine flower gardens.

  • Imagine herb gardens.

  • Imagine that type of thing.

  • You place these in there, you have them connected to different water pumps when it gets too dry, then pumps out water into the garden, and you have a great little automatic irrigation system.

  • One of the great things you can do with our Reno's, too, is again.

  • You can have multiple sensors so you could have the soil moisture sensor.

  • You could have a photo tenant fan sensor, basically determine what the sun like sunlight currently is, and you could have a temperature sensor.

  • So one of things you could dio is you don't want a water plants in the middle of the day when it's too hot.

  • So basically, you could say if the soil is dry and the temperature is below 80 degrees and it's dark, then water the plants.

  • So these are the types of things that these types of projects you can start doing once you add in things like this little moisture sensor.

  • So with that, let's go over to my little workbench to show you howto put this little project together.

  • Then I will show you a very simple code and then show you the example of how it all works in action.

  • So here the components that we're going to need for this particular project, you will notice some non technical components Here.

  • We need these non technical components to be able to test the sensor and be able to see how the readings work.

  • So I just have a little glass of water here is just plain normal water and I also have a mug of potting soil.

  • So this is just relatively a dry potting soil, so we can put the sensor into that to determine how wet it is.

  • And then we have the turkey baster, the turkey baster.

  • So since this is a dry soil, what we're going to dio is we're going to put the moisture sensor into the dry soil, see what the reading is, and then we're going to start adding water and see how they're reading changes.

  • So those air than on, like really technical components.

  • Beyond that, this is all that is required for this project.

  • So we have our soil moisture sensor here.

  • And so when you buy this, this all comes as a kid.

  • You have these problems.

  • So the problems here betting on which ones you buy, they actually don't have any brain power to them.

  • Basically, these air just problems that you plug into the ground and then you have the positive and negative wires that you then run to this little controller unit here.

  • So this is the brains of this particular unit.

  • Then pass that when you take a look at the module for this unit, you'll have positive you're VCC and you have ground.

  • Now you complain the VCC either into five volts or into three vote.

  • You will get a different reading from it, depending on whether it goes into five or three volts.

  • So just whatever you're gonna do for your project, just keep doing that because of you set a value for variable in an if statement that should trigger.

  • And then you change the input going in.

  • You may run into some issues there, then passed that we have the analog outputs.

  • So all the way on the right hand side, we have the analog outputs of the analog output.

  • We have coming down here to a zero.

  • So with this particular type of moisture sensor, you can actually have digital output or analog output in order to read a specific number.

  • What we're gonna be using today is the analog output, and this is really all you need for what we're going to be doing today.

  • You just assemble this again.

  • We have it going for five whole.

  • We're going to ground and then we have the analog.

  • Why're going to a zero this is how the project is built.

  • So let's go over and take a look at the code.

  • So here is the code.

  • Here is literally all the code, our main lines, that is, that is all the code that we're going be doing today.

  • So there's no libraries or anything else.

  • This is very simple, since basically over we're doing is reading from an analog sensor.

  • The first thing we're gonna have to do is you're gonna have to define the analog pins.

  • We're gonna define a zero, and we're going to call that the soil sensor.

  • So in order to reference a zero now we will say soil sensor.

  • Then we go down and we set up the environment, and all we're gonna do here is we're simply going to do serial dot began 9600.

  • So this starts the serial monitor service so that we can actually read out from the Arduino and see what the sensor readings are then passed that we get into the loop and literally Oh, my God.

  • I got three lines here.

  • That's it.

  • So we got into creating a variable sensor of value equals analog, reads the function and log read soil sensor.

  • So we're going to analog, read a serial a zero, and then we're simply going to a serial dot print line the value of sensor value.

  • Then we're going to delay for 500 milliseconds, or about half a second.

  • Repeat, repeat, repeat, repeat.

  • So basically all we're going to be doing for this particular project is reading the analog value from that sensor pin on and then printing it out to the serial monitor.

  • So let me let me upload this code to the art we know, you know, and I'll show you how it works.

  • So I've connected the Arduino, you know, and I have uploaded the sketch.

  • So now that it's powered, we can go to tools, we can go to serial monitor and we can see what the output ISS so we can see that we're currently getting an output of 1023.

  • So if we take a look, we have the sensor right now and the sensor is not connected to anything at all.

  • It's not in the soil, it's not in water and so we can see the max value.

  • The max resistance that we're going to get is 1000 23.

  • Now one of things I'm gonna show you is the minimum resistance.

  • So if the high is 1000 23 what I want to do in this kind of shows you how this works is if I connect both sides.

  • So this is simply one wire.

  • I'm connecting the mail to one side, the mail to the other.

  • And as we can see, the value goes down to zero.

  • So when there is no resistance at all, it zero.

  • When there's the max resistance, it's 1000 23.

  • So that's your high and your low from there.

  • One of the interesting things to see is that we take our little glass of water here, and we simply put our sensor into the glass of water.

  • We can see that the value for the sensor actually does not go down to zero.

  • A lot of people would think if you put this in water that the value will go down to zero.

  • But as you can see, it's down that 252 140 range, so you don't actually get a zero value when you put it in the water.

  • Then from there we're going to do is we're gonna take this and we're going to put it into our soil and so we can shut it all the way to an indoor soil, and we can start to see what the value is now.

  • One of the things that I will tell you when you're using the sensors is it does take a few minutes.

  • Let's just say it takes a few minutes before the number fully stabilize.

  • When I say a few minutes in my playing around with this, I would really say it takes about 20 minutes.

  • I don't know exactly what's going on between the two little problems and their what's happening with the soil and everything else.

  • But basically what I found in order to get a truly stable number, it takes about 20 minutes for everything to work out.

  • So just realized if you're gonna be using the sensor, don't think that you can simply shove it into the soil and you will get the specific number you're looking for immediately.

  • It will take a little bit before it equalizes, so here we can see it's equalizing out to about 3 91 again.

  • It's still going up a little bit 3 92 One of things that might be useful is with the serial monitor.

  • You can do things like show time stamp so you can start printing this out with the time stamp.

  • And then the nice part is, what you can do is you gonna walk away, go have a cup of coffee.

  • You go to the bathroom, whatever else, and then you can see what the current value is.

  • You can scroll up a little bit to see how long it's taken to get there.

  • So this is just one of those things just to keep in mind to get a tee, get the state stable number you're really looking for.

  • Give it about 10 or 20 minutes.

  • But here we've got a relatively stable number again.

  • We're saying, seeing that 3 97 3 98 so once since we have that, what I'm going to do is I'm going to take a turkey baster.

  • I'm goingto grab a little bit of water here, A little bit of water here.

  • Then we're gonna go over and we're going to put the water into our little thing.

  • And this will show the value go down.

  • So as we now are watering, watering our little sensor, we can see the value has gone all the way down to, like, 167 170 mark again.

  • This is one of things as soon as you add water because the water is gonna percolate through the soil.

  • Plus, there's some chemical reactions with the water the whole nine yards.

  • So just realized when you put water in to the container, the soul of the soil sensor will immediately start reading values, but you shouldn't take the values is being accurate again until I would give it about 10 minutes.

  • That's one of the one thing be thinking about.

  • If you're gonna be doing a project like an automatic watering project, one of things that I would say Let's have the sensor.

  • Check the value or trigger, Let's say every 10 minutes or so.

  • So that way, if the if the value is below level, so you turn the pump on you pump water into the plant into the pot, and then I would have a wait 10 minutes before determines whether or not Maura water should go in because as you can see it takes a little bit of time before it stabilizes.

  • So if you just simply keep pumping water in, you may run into an issue with, you know, the very, though the value of variables so on and so forth.

  • And so basically, that is all there is for this particular project.

  • So what you do is you.

  • You, you you take your soil, you plug this in, you shove it in there, leave it for about 10 20 minutes.

  • See what?

  • See what the reading is when it's dry.

  • Then put enough water in there.

  • Put an amount of water in there that you think is appropriate what you think the level the water level should be.

  • Then again, leave the sensor for about 10 20 minutes to figure out what that value is, and then take those values, turn it into an if else statement and then have the f else do something within your sketch again.

  • You can have it post to a server.

  • You can have it turn on an led light or again, you could even have a turn on a water pipe or something like that.

  • So that's all there is to this particular project, and I think it's a pretty nifty, nifty neat, low little sensor at the end of the day.

  • So that's all there is this particular projects.

  • You have your little soil moisture sensor.

  • Basically, what this does is it is able to read their resistance.

  • It sends since the positive through one problem, it tries to pick the positive up through the ground.