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.

  • On the other problem.

  • If electricity can flow freely, then you get a value of zero.

  • If electricity cannot flow it all, you get a value of 1023.

  • If you're using five volts on and then basically in between, there is what your sensor readings for your soil will be again.

  • If you're gonna be using these sensors, I would say the one issue it is, it's kind of weird because it's not a digital sensor.

  • There's no real brains or anything to it, but really into really, you should wait about 20 minutes before you really trust the reading that your sensor is giving you again.

  • I don't know what's going on with the soil composition of the soil chemistry or anything like that.

  • What I found is it does take a surprising amount time.

  • This isn't like a lot of sense.

  • There's a lot of sensors.

  • You shove the sensor and you do something.

  • The censor it automatically gives you whatever reading is giving you.

  • This is one of those.

  • Shove it in.

  • Go grab a cup of coffee, drink your cup of coffee, come back and then see what they're reading is because if you go off of the immediate readings, you'll probably run into issues going in the future.

  • Now, one of things that I will warn you is we used our turkey baster today, so this is one of the few times that one a few times you want water anywhere near your we know project.

  • But do you realize when you're dealing with water, water does conduct electricity?

  • And so if you do things like, uh, like it wasn't paying attention, you'll be surprised I wasn't paying fainted, you know, when I was experimenting with this and so at one point I was shoving the sensor into the water, and then I showed the sensor too far into the water, and the water actually got up into, uh into where the wire connectors are and So then I started getting a lot of weird readings because the water was shorting these connections up here.

  • And so I was getting weird readings, even though it wasn't actually connected anything.

  • So do be careful about that with water.

  • If you're gonna use this in a real world like a production environment, I would use something like there's something called liquid electrical tape was really cool.

  • And so if I was gonna put this out in the real world once I made all the connections, I would shellac this.

  • I was shellacked the top part, the top part with liquid electrical tape, because again, you've got the little you've got a little sauder points on the back.

  • You've got these wires up here.

  • If these get wet, remember, with all this is doing all this this sensor is doing, is it seen what the resistance is between the two sides?

  • Well, the two sides were here.

  • The two sides air here.

  • The two sides air here.

  • So if you get a short not just down here on the prongs, but you get a shore up here at the salt or connections, or you get a short here up on the wires.

  • Well, then you're going to start getting readings as if there's moisture when there may not be.

  • So if you're gonna put this out in the real world again, I would use something called liquid electrical tape.

  • If you're just using this as an experiment, you're playing around.

  • Just make sure keep the top of this darn thing dry.

  • If the top of this gets wet, then you'll run into problems.

  • There are other issues people have with these particular sensors.

  • A lot of people say at their toy sensors, because they will be great at overtime.

  • Since there's an electrical current going through the soil.

  • Thes sensors many times will corrode relatively quickly what quickly actually means.

  • At the end of the day, it depends on what environment you are you're in.

  • You know what the soil composition is, how what the soil is so on and so forth.

  • One thing that you may think about, though, is if you want to try to keep the censor, the sensor, good for as long as possible is you might do something such as triggering when the sensor is actually powered up.

  • So right now, in this particular project.

  • What we did is we powered this using the five vote, the standard five volt power connector in there doing aboard again, we can use five older three bowl.

  • Well, that means this is powered up all the time.

  • So even when it's not reading from the analog censor, it is still powered, which means this thing is still going be getting corroded.

  • One of things you might think about doing is actually using one of the digital pens to power this.

  • So what you could do is, since the digital pen can send five hole, you could turn a digital pin on in order to power.

  • This collected the reading from whatever for whatever the reading is.

  • And then you could turn off both the reading pen and the digital pen, and therefore, electricity would not be going through this all the time.

  • If you're gonna be doing that type of thing, though, do make sure to test the hell out of it.

  • I'm not sure how that would work from a stability issue again.

  • As I said before you shove this in the soil, it takes a while before you start to get a good reading.

  • So If you turn power on on did a sensor and you turn power off to the sensor.

  • One of my questions would be is how long would it take before you start getting a stable reading from him?

  • So these are the different types of things to think about, but one of things that also realize that the end of the day again, folks talk about these being toys, and they're almost disposed disposable.

  • But they're also insanely and expensive.

  • Again.

  • All this is a little bored with some foil on it in the connector.

  • I think I bought about five of the whole modules.

  • They think they might cost a dollar apiece, so it is one of those things to be thinking about.

  • It's like, Well, if they die every year, it takes a year to kill one of these things.

  • Let's say it takes a year to kill.

  • One is that's a dollar a year.

  • Is it worth a dollar a year in order to keep your plants water?

  • That just may be one of those things to think about ago.

  • Well, its disposal, yes, it will die.

  • Yes, it will corrode every year, but for a dollar maybe $2 a year.

  • That's something that I think is is a reasonable price.

  • So these are all some of the things that you should be thinking about we're gonna use when these analog soil moisture sensors.

  • So that's all there is to this particular class.

  • Go out.

  • Grab your turkey baster, shoveling these things in the soil and again, the big thing is just Just be careful how you use your your turkey baster.

  • Just make sure the water goes in the right location or you can run into all kinds of problems were not going to even go into If you squirt water directly on there and we know board, don't do this, Do that water and are doing oh, boards generally do not mix.

  • You have water around your we know board.

  • Just be very, very, very careful with that.

please go to the line.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

Arduino - 土壤溼度傳感器 (Arduino - Soil Moisture Sensor)

  • 9 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字