Soil Moisture Sensor on batteries with ESP07 running ESPHome - Start to Finish

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi one and welcome back to my bench today we're going to be working on a project to further improve my setup in the garden using this capacitive soil moisture sensor where I want to build a battery operated sensor that will be running ESP home on this ESP 07 module and will connect to my home assistant setup so I can at any given time know what the humidity of the soil is and based on that we will know to turn on the irrigation that I have set up now a while ago I made a video where I explained how this sensor works and I've used it to connected to Arduino so you can go out and check that video if you're interested to see the basics of the sensor because I will not be covering that in this video but instead I will be focusing more on getting it to work with ESP home and for that the first thing that we need to do is to figure out a way how we can Flash the ESP home firmware to aboard like this so this is the ESP 07 module that comes on a small PCB uh with onboard ceramic antenna and an antenna connector uh we won't be using that one in the current setup because I think that the ceramic antenna will be enough and the idea is that compared to a standard node MCU as I used in my projects which looks something like that this is a lot smaller just the the module on the Node MCU without the USB to serial and all of the other components so the idea is that we can Minify the project as much as possible and have it battery operated So the plan is that I run this directly out of the battery voltage and um hopefully it works okay we'll see the goal is to have something that will run for the summer season so about three to four months of battery life because afterwards I will remove it from the ground and I can charge it up and get it ready until the next growing season next summer and before we go any further into today's projects I want to thank today's sponsor which is PCB way PCB way allows me to create all of these beautiful pcbs for my projects that you can check out in the link uh below and not only that PCB way also provide services for 3D printing and CNC Machining that can help you out with all of the projects they already have an awesome project library that you can also check out so you can get ideas and readymade pcbs including all of my own and you can go inside their website to find inspiration and order any of these if you want PCB way is the One-Stop shop for all your manufacturing needs so check out the links in the video description for more details and for a welcome bonus for your first project now to program the module I'll be using a board like this this is a USB to serial converter that can operate on 3.3 volts and this is really important because we don't want to burn the module out without any voltage um regulator on it and from here we have connections for 3.3 volts ground uh RX and takes to talk uh and program the module this one is the same that I used to program some of the son of switches that you can check that video up here if you want and the way I have it connected is I'm using a breadboard to just provide me with multiple connections because on the board itself we need to connect quite a few pins in order to make it work let me go a bit closer on that so this is the back side of the module and you can see we have VCC and ground connected here at the bottom and next to ground we have connected gp15 also to ground the enable pin we have connected directly to VCC then we have the takes and RX connections that are switched so takes connects to RX on the module and vice versa and one final connection that we need to make temporarily in order to get this module into flashing mode is GP Z which I have it connected with this white wire that when powering on the module for programming we need to pull that down low so let me show you that how it goes okay so now this is just an extension lead that I have coming in from my computer if I connect this we'll see that it will start running and flashing the uh onboard LED uh but in the state where it has it code running if we go to the Arduino ID and if we try to upload the blink sketch I'm going to change the timing here uh to 500 milliseconds just for demonstration purposes and if I try to upload this it will compile the sketch but when it tries to upload it it will stop and throw an error so now it's it tries to connect to the module tries several times but after a while it will give up and say an error that uh it's not able to communicate with the module because the chip on the ESP board is not in a flashing state so we need to change that and connect the GPO Z to um so here is the error message so fail uploading and to fix this we need to power off the module we need to connect gp0 to ground so I'm just going to and make sure that it's it's not off it's a bit sketchy but this is a onesoft project so onesoft thing uh it's worthwhile while but you can get certain adapts that you can do this now if we power if we power on we'll see that the LED is no longer flashing so it's not running the code that we have here and if we now try to upload let's see what happens it's going to compile the sketch again and now we should see a difference when it says connecting it should start uploading and it did so hopefully everything goes well and we will wait for a few seconds for the code to upload and then what we will need to do is to break the connection of GP Z and reset everything so okay so it says done uploading now we need to Power It Off remove the GP zero connection to ground and then power it on and now we see that it blinks uh much faster than it was blinking before now from here there are few other things that we need to do and the first one that I want to do is to remove that red LED that power indicator because remember the goal is to have this whole thing battery operated so the less current that we can uh waste on LEDs the the better so in order for me to do that I will need to use my hotter station try to heat up the board and carefully remove that led physically from from the board so let's see how that goes okay so that went quite good considering in just the size of the LED uh which is this here I was able to successfully remove it without any damage to the module probably without any damage to the LED itself but that's really not our goal here the goal was to remove it now let's try connect it again and confirm that it's still works okay so let's connect it and you can see that we now have the flashing blue light but without the red LED hopefully that would save us a few milliamps in the final project now next up is to connect the es home firmer on the module so we make sure that we can uh communicate through it with um home assistant and for that I connected once again GPI zero to ground using this white Barre and and I'm going to start the module in flashing mode so we don't see the blinking blue light here if we go to our screen here I'm at the web. home.io page so I'm going to try and Flash the board with the home assistant firmware I have com 5 this is the port and I'm going to say prepare for first use let's see if the module is recognized and if it start to install and it looks like if it's doing that so let's wait a minute and see how this goes okay so seems that the configuration is installed I'm going to close this one and I need to uh Now power it off so it says that the Wi-Fi serial is not detected but that is because we still have GPI pult zero so we need to turn this off remove this wire and now if we try to par it on hopefully now it starts with the es firmware let's see within home assistant okay so that does not seem to have worked immediately but what I did is I went into es home I clicked on add new device and followed the steps here to get here and download the binary which I then installed directly uh from here by using the install button and now we seem to be having the device here and we also got the message that it's installed let's add it okay so finish we have nine devices and we have the garden soil moist currently we don't really have anything inside and I think it's best if we try to edit let me try to increase here uh this board because uh it's not a 01 so it's 07 let's try to save and wirelessly install this and hopefully with that we can configure and make sure that uh we have control over the module let's see how this goes and that seems to have worked we have the module back online so now next upep is to start adding the soil moisture sensor and investigate the deep sleep options for the module and here is the sensor now connected with the soil moisture sensor and I have it connected to home assistant where it reads the moisture content currently in the air at about 1 second and this is the code that does that it's connected to pin a z but because I'm using the ESP 07 module uh that does not have an internal voltage divider so the input voltage that we need to apply is between 0o and 1 volt and the Soul moist sensor by default will up to will output up to three uh volts usually around 2 something so I'm using a voltage divider of 220 kilms resistor and 100 kilms resistor that should divide the voltage to about a maximum of 1 volt and if I now we can see the percentage out put and if I take a glass of water to simulate moisture soil as I dip it in then it goes a bit over 100% so we'll need to calibrate that a bit because we shouldn't want to go over 100% now let me wipe this off and it should be down to about 10 12 volts and we can vary that using the calibration function where we we can set the voltage went on 100% And the voltage went on 0% based on the output that we have from the moisture sensor now as a proof of concept this all works later on I'm going to enable this median sensor so we're only reading about every few seconds and I'm also going to increase the update interval and now my goal is to move all of this to be battery powered because that will be a big variable in the whole project and if that works then we can move to deep sleep and moving everything into an enclosure and to make the whole thing running out of batteries I used the uh two 18 650 cells in par that they have Salvage from an old laptop battery and I've added a TP 4056 board so I can later on charge and also use the built-in protection to discharge the batteries to a certain level before everything cuts off and because the operating voltage on the ESP 07 is from 3 to 3.6 volts and the battery would output about 4 volts when fully charged I'm using a diode in series uh with the circuit so there is a small voltage drop on the diode and that from about 4 volts on the battery that provides about 3.8 on the ESP 07 which it seems to be running fine and I have it running this on my bench for a couple of minutes currently it's not showing anything within the soil moisture but if I get the sensor and hold it in my hand then it changes the capacitance and starts showing something now this whole thing works I haven't done any measurements in terms of how long this will last but we will take a baseline reading with my multimeter currently I'm going to connect it in series here so we know how much current we drw from the battery and next up will be to add some deep sleep functionality and package the whole thing okay so now the whole circuit is currently off and I have my meter set to 200 mli ohms okay so we are drawing about 76 77 and I'm guessing that will drop out depending on how the ESP communicates and connects to the network after the whole boot process is complete let's wait a bit for that to stabilize and I think we are already online because I can see the values changing and yeah that's about I think the best we can get so 73 milliamp is uh our Baseline let's see how we can improve that by adding some deep sleep to the code okay so that was fairly easy to be done you can see now that we are drawing just 3.6 milliamps and the whole device is in sleep mode so if I touch the sensor uh nothing changes in the dashboard so we can see that it stays with the old value that we have and after the timeout have passed then the device will boot up and for that to happen I had to connect one of the gpios with the pin uh reset so that is used to basically reset the uh ESP 07 so it knows to boot up again and connect to the network um that happens in about 5 to 6 seconds um from what I've seen and we can see that over here so let's wait a second for it to boot up okay so it's starting to boot up now I'm going to get the sensor in my hand and we should see in just a few second that the value will update once it connects to the network and becomes available so still connecting and now it's updated to 60% if I release it it goes back down to 20 something so we will need to do some adjustments on the uh values that we use to provide the humidity because now it's running of a slightly higher voltage and that might be an issue but I think we are um currently okay to put it outside and for that we're going to need an enclosure and once once outside we can work on the final frameware to make it sure that it works as expected we can probably go a bit lower on that because I think that most of the current that's currently spent in sleep is by the sensor and we can verify that if we disconnect the sensor from power and now we go down to what it says zero milliamps but that's probably something that is measured in the in the micr so something like uh 27 uh close to 28 micr which I think would be quite good to to have but again as I said I'm going to leave that for later on once we have everything inside an enclosure now for the mounting um and the enclosure I can choose one of the three options so these are all electrical boxes that I like to use with my projects in an absence of a TR printer so that would have been best if I can print an enclosure but unfortunately I have to result in using one of these boxes this one is the only one that comes with a grommet so it can isolate any moisture but unfortunately what I don't like about it is that it has screws on the top so moisture can go down through the screws because I plan to have the sensor sticking out from the bottom and being stick into the ground and this would sit uh in the garden like so uh this one on the other hand already have has holes on the side with this rubber grommets uh but uh they don't seal that very well so I think that moisture will be able to come down and it has a lid that goes on top uh so I think I'm going to go with this one it doesn't have the grommet inside to isolate but it should have enough overhand and I'm going to add some hot glue once everything inside and and working so hopefully I make it as watertight as possible and I'm going to make a slot in the bottom where I'm going to probably epoxy the sensor in and it going to stick from the bottom now let's put everything inside the Box for here is the final assembly moment I have the sensor box it on the bottom of the case so we can plug it in so I need to be a bit careful because the glue is not fully cured yet but I just want to make sure that everything works so we have the sensor connected and I've added male and female header pins uh on the battery and on the module so I can disconnect it if I want to and I also because I use the same hit shink I also marked the positive and negative on the battery on the terminal so the black goes with the black let's see if it's going to work we saw the blink there let's see if it's going to appear in home assistant I don't see a reason why it shouldn't but let's just double check that it's actually there and yeah so currently it reads zero and if I touch it with my hand then it goes up so we know that it's sending and in a while it should go to to deep sleep and we can Now package everything up inside the box and put it outside in the garden to further prevent any shorts I'm going to just WR grab the pack with some electrical tape together with the charging board making sure that I leave the connector visible okay so that should be good enough and this will sit some thing like this so let me figure out what's the B best placement so something like this and we can tuck everything inside I'm going to add just a touch of hot glue to the batteries so I can secure them in the case so they are not floppy okay let's see how that goes we can add the lead I'm not going to seal this just now because I want to have this running on my bench for at least a few days before I put it outside to make sure that it runs okay Final Touch and we can now call it complete and with that I hope that you like this video I definitely had a lot of fun building this thing and I'm sure it's going to be helpful in the garden if you want to have further updates on the sensor make sure to subscribe to the channel share this video if you find it interesting and I would see you all in the next one cheers
Info
Channel: Taste The Code
Views: 3,314
Rating: undefined out of 5
Keywords: soil sensor, esphome, deep sleep, esphome sensor on batteries, battery sensor, home assistant, esphome integration, all in one soil sensor with display, capacitive soil moisture sensor, moisture sensor, esp-07, esp8266, esp32, arduino, esp deep sleep, flashing esp-07, smart home, smart irrigation, diy smart sensor, project, 18650, tp4056, taste the code, electronics, diy, smart garden, automatic watering, smart irrigation system, wifi, home assistant esphome, garden, iot irrigation
Id: UFa0F744P5c
Channel Id: undefined
Length: 26min 32sec (1592 seconds)
Published: Fri Apr 19 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.