For a future video you may want to try the Sonoff "Zigbee Smart Water Valve". It also uses ESPhome and if you use MQTT you can monitor the water usage, set it by amount of water, time and with some coding soil moisture, battery, schedule... I just installed mine on my wife's garden/rain barrel/pond pump and works great. Currently I just set it to turn on 2X a day for 30 seconds (16 ounces each run). Next is MQTT and soil moisture checking, then rain forecast..... Great video you did
Amazing video that has covered a lot of things i wanted to grasp. I am new to this so i hope i am not asking the obvious For the voltage divider you used identical resistors which is why you used a multiplier of two in the code correct? could you have used different value resistors to get 3.3v and not used the multiplier? any benefit of one over the other and what value resistor did you use? also the polynomial is to approximate the discharge curve of the LI battery correct? again, great video
Yes, the identical resistors were to cut the voltage in half. When doing a voltage divider, you're going to be working with a ratio. If you take a reading between two resistors, the resulting voltage will be V*r2/(r1+r2). Since both r1 and r2 are identical, my resulting voltage is V*1/2. If you want 3.3V, then the ratio you need depends on what the input voltage is. The resistors can be almost any values, as long as they result in the correct ratio. Practically, however, there are a couple of other considerations. Lower resistors values will result in more current flowing through the divider (total resistance is R1+R2, and thus current will be V/(R1+R2)). If there is no switch breaking that circuit, then that current will flow all the time. This can be bad for battery life, especially for a device which is mostly "off". So for battery monitoring, I like to use larger values (100k to 1m). You can't go too crazy though, because you do have to have enough current for the sense voltage to be measurable. And yes, the polynomial was just an approximation of the this batteries discharge curve. It's not super accurate, but it's enough for a rough estimate. Linear honestly isn't much worse than polynomial given the other inaccuracies in the system.
Thanks a lot for sharing your project! A quick question: the Xiao C3 is rated up until 3.6V whilst the battery is 3.7V (and I assume the voltage goes even higher, maybe lower 4.x when fully charged). Have you experienced any issues with it, should I be considered if I were to copy your setup with a 3.7V LiPo battery?
Not sure where you're getting the 3.6V from, so IDK what to reference there. The Xiao is made for 3.7V LiPo batteries. The higher charged state voltages (~4.2V) are no problem; that's just how LiPo batteries are.
@@TechDregs it is under 4.2 Recommended Operating Conditions files.seeedstudio.com/wiki/Seeed-Studio-XIAO-ESP32/esp32-c3_datasheet.pdf But clearly your setup works, so it's probably a non-issue. :)
That's power to the ESP32-C3 module itself. The battery is managed by a separate chip, and then ran through voltage regulators as output to the ESP32-C3 which never sees more than ~3.3V. You can see the power arrangement on the schematic: files.seeedstudio.com/wiki/XIAO_WiFi/Resources/Seeeduino-XIAO-ESP32C3-SCH.pdf
I can't speak to accuracy, as I have no other soil moisture measurement devices that use a different type of sensor. But since I reconfigured the sensor to draw power via GPIO that turns it off when in deep sleep, battery life is over four months on a charge. I did something like a followup in these videos: ua-cam.com/video/4EZYYPmQnJY/v-deo.html ua-cam.com/video/Yttauf94A04/v-deo.html
Thanks, this is great and exactly what I want to create. Would you be willing to share the design for the case and a link to the battery you used (for sizing)?
I generally no longer share STLs for designs, but one thing that's helpful is that you can usually get STEP files for the SEEED Xiaos either directly from them or from grabcad. I wouldn't get this battery again, so I won't link it. I wasn't paying attention and ordered a 3-wire battery, and the third wire isn't useful (I think it's a thermistor in the battery for temp monitoring).
I was testing a very similar setup, and found that my Xiao ESP32C3 was still drawing ~25mA in deep sleep. I wasn't able to reduce the power consumption, so with it only lasting a day or two, I ended up making it a hardwired system instead. What kind of battery life did you ultimately end up with?
25mA is way too high. That doesn't seem like it's going into deep sleep at all. Battery life will obviously depend on the battery size you use, but with my current setup where I power the sensor via GPIO pin, I last recharged on January 24th, and it's showing roughly 50% battery remaining.
@TechDregs good to hear yours is working as intended. I had 3 separate sensors connected to GPIO 2-4, and a high gain antenna, but even with the antenna disconnected, it was drawing around 100mA in use, and then dropping to a steady 25mA during deep sleep. I tried looking at all of the deep sleep protocols, but never could figure out what was causing the high draw. I'll have to take another look at it soon. Thanks for the info!
Hmm... yeah, I don't know. It just doesn't sound like you're not hitting deep sleep. How are you measuring current draw? Are you using a voltage divider on the battery leads for ADC measurement? Are the GPIOs being set to off/low for each sensor prior to sleep?
@@TechDregs I used a multimeter in series to measure the current. I've been using the esp_deep_sleep() function with a number of different sensor controllers I've built, and know that the devices do in fact enter deep sleep (or some semblance of it), but for whatever reason the current draw is still high. They don't appear to enter any of the alternative sleep modes. I dabbled with trying to set the GPIOs to low individually before entering deep sleep, but that never seemed to make a difference. No worries! I need to do more testing to get to the bottom of it.
@@holodiscus Very strange. Is the current draw still high without the sensors? I would probably check what happens when adding them one by one so see if you can isolate what's causing the draw.
Do you have a github page or a written guide with wiring diagrams? I'm just getting started with ESP32 using batteries. Also, did you consider fitting a solar panel to this battery to keep it topped up?
This is my very first ESP32 project and I am trying to understand how to connect a 18650 battery to the board. How did you make the connection? Are you connecting it to the 5v pin?
If you're using a Xiao, the battery connections are on the underside of the board. There are two pads there than you solder the battery connections to.
I pasted your yaml code into the code for an ESP-D1 on Home Assistant and did a search and replace of the > and < markers as directed. When I run the "validate" on the code, I get the following error message: INFO ESPHome 2024.3.1 INFO Reading configuration /config/esphome/d1-1.yaml... ERROR Error while reading config: Invalid YAML syntax: while scanning a simple key in "/config/esphome/d1-1.yaml", line 61, column 9 could not find expected ':' in "/config/esphome/d1-1.yaml", line 62, column 9 I do not see anything where I would think a ":" would be needed.
I'm not sure. It could be a spacing issue in your YAML or it could be a change to ESPHome that has occurred since I did this project. Lines 61/62 are in the WIFI setup for me, and I don't see any issues there, so I'm guessing it's in the lines above that somewhere. Just check all the indentation. I haven't updated mine in a while, but next time I do I'll update the code in the details.
Ok, my sensor is working, it reads 30 second and after 3h in deep sleep. But I have 2 questions. 1. It seems that the Voltage reading is not very accurate. I have calibrate the value Many times but after some reboot it reads 0.2 0.3 V more or less than the real battery value. I have used two resistor 220k in parallel. 2. How can I do to allowr home assistant to show in the dashboard the last value read when the esp32 is in deep sleep. Thanks in advance for any help.
For #2, that should just show up automatically over time. For #1, battery voltage in my experience can fluctuate a bit, especially when it's above 4.0V. It seems to settle down and get smoother below that.
read esphome deepsleep page. While in deep sleep mode, the node will not do any work and not respond to any network traffic, even Over The Air updates. If the device’s entities are appearing as Unavailable while your device is actively sleeping, this component was likely added after the device was added to Home Assistant. To prevent this behavior, you can remove and re-add the device in Home Assistant. i think this should solve your problem.
Looks like mine died this week (I think water got into it), so I can't test this, but try replacing: pin: 4 with: pin: number: 4 inverted: false allow_other_uses: true In both places that it appears. See if that works. They implemented a change recently to break using a pin multiple times unless you specifically allow it.
Can Share all ? the project is amazing. I've been looking for something like this for a long time and now I'm grateful to you for showing it. can you show the wiring properly? Thx
There's actually very little wiring. The battery is connected to the battery pads on the bottom of the board. I've got a voltage divider on the positive lead, with one side to ground and the other to an analog pin. The sensor board only has three wires: power in, ground, and sensor out. The sensor out just needs to go to an analog pin. The YAML is in the description; so you can see which pins I used there for the sensor and battery voltage readings. One trick that I have done since this video is powering the sensor from a digital GPIO pin, which I enable when the device wakes up and disable when it goes to sleep. That has a huge impact on battery life, as this sensor draws about 5mA when it's on.
I updated the details with the code. Basically, you just add onboot and onshutdown commands, and add the pin below as a switch. Make sure to change the GPIO to the pin you're using for power to the sensor. I also added a wifi signal sensor, since that can be useful to see.
thanks@@TechDregs , I was implementing it on my side and apparently HA after 2023 requires the use of 'allow_other_users' if the same pin is used for several uses (battery life and battery voltage) I replaced pin: 4 for 'pin: number: 4 allow_other_uses: True'
Hello, I'm trying to make my yaml configuration, but I got this error: Pin 0 is used in multiple places. Could you help me? thanks in advance Failed config sensor.adc: [source :55]
Pin 0 is used in multiple places. platform: adc pin: number: 0 mode: input: True output: False open_drain: False pullup: False pulldown: False inverted: False ignore_strapping_warning: False drive_strength: 20.0 name: Battery Life unit_of_measurement: % device_class: battery update_interval: 2s attenuation: 11db filters: - multiply: 2.0 - calibrate_polynomial: degree: 4 datapoints: - from: 3.4 to: 0.0 - from: 3.6 to: 8.43 - from: 3.81 to: 50.06 - from: 3.86 to: 57.63 - from: 3.92 to: 72.56 - from: 3.96 to: 90.96 - from: 4.05 to: 100.0 - lambda: !lambda |- if (x > 0) return 0; else if (x > 100) return 100; else return (x); disabled_by_default: False force_update: False accuracy_decimals: 2 state_class: measurement raw: False sensor.adc: [source :80]
Pin 0 is used in multiple places. platform: adc pin: number: 0 mode: input: True output: False open_drain: False pullup: False pulldown: False inverted: False ignore_strapping_warning: False drive_strength: 20.0 name: Battery Voltage update_interval: 2s attenuation: 11db filters: - multiply: 2.0 disabled_by_default: False force_update: False unit_of_measurement: V accuracy_decimals: 2 device_class: voltage state_class: measurement raw: False
You need to allow other uses. It's an update ESPHome has since I made this. Use it every time you setup a pin which is used more than once. pin: number: 0 allow_other_uses: True
Did you calibrate your sensor values? You need to test what voltage it sends in open air and fully submerged in water. I used these: www.amazon.com/Capacitive-Moisture-Corrosion-Resistant-Detection/dp/B07SYBSHGX
Would you be able to explain the switch code here. switch: - platform: gpio pin: GPIO10 id: sensor_power internal: true Sorry a noob. Have you got a switch wired into pin 10 thanks for a great project
I'm using pin 10 to provide the power to the soil moisture sensor rather than wiring it directly to the output voltage pins on the ESP32 board. That allows me to turn power to the sensor on and off. This is the routine that sets up pin 10 as a power outlet that can be turned on and off (which ESPHome calls a switch). So, switch: - platform: GPIO tells ESPHome that this will be a binary on/off switch using a GPIO pin. ID: sensor_power is the internal name of that switch so I can refer to it elsewhere (like the boot and shutdown sequences). Internal: true means that it isn't exposed externally, so the switch won't show up in Home Assistant.
Sorry just reading this again and doing a little Google I was un aware you could supply 3.5 volts from a gpio pin. Other than vin etc. am I misunderstanding. Probably 😢
Depends on the pin. Some pins are input only. But GPIO pins can output about 40mA of current at 3.3v. There is also a total power budget that you have to stay under, but if you're only doing one or two pins of output, that's not a concern.
@@TechDregs Pleas ignore this if you wish. I know you are not a help board. But I am curious. I have it all working. But when it goes into deep sleep it becomes unavailable on the dashboard. I have read on a few forums that it is best to change over to mqtt and then you can use birth and will_message. But I did a quick try and havn't been able to do the switch to mqtt. I am wondering if you have the same issue.
Thanks for the tutorial! But by Pasting your code i get the following error code: INFO ESPHome 2024.5.5 INFO Reading configuration /config/esphome/boden-feuchtigkeit-1.yaml... ERROR Error while reading config: Invalid YAML syntax: while scanning a simple key in "/config/esphome/boden-feuchtigkeit-1.yaml", line 16, column 1 could not find expected ':' in "/config/esphome/boden-feuchtigkeit-1.yaml", line 17, column 1 can someone help me out? Many thanks!
@@TechDregs Is it possible that you send me the 3D print file in an E-Mail? I will not sell the file. I just ordered a printer and i´m verry new in this material.
@@TechDregs Thanks for the project also is it possible to connect the battery directly to the esp32 c3 supermini?, and is it possible to send the 3D print file by email? Of course, I will not move the file to the web. Well thank you
It's an older project, and ESPHome has received many updates in the meantime. It will require several changes to work with current versions of ESPHome. You might check on the ESPHome discord for help with all the adjustments.
It is not a conductive sensor, so the conductivity is not all that important. Probably calibration is needed anyway, the soil will have an influence on the readings. ua-cam.com/video/m0mcCtcViTY/v-deo.html
For a future video you may want to try the Sonoff "Zigbee Smart Water Valve". It also uses ESPhome and if you use MQTT you can monitor the water usage, set it by amount of water, time and with some coding soil moisture, battery, schedule... I just installed mine on my wife's garden/rain barrel/pond pump and works great. Currently I just set it to turn on 2X a day for 30 seconds (16 ounces each run). Next is MQTT and soil moisture checking, then rain forecast..... Great video you did
Thank you so much for explaining that. I had everything working except that. Great project. Looking forward to making a few.
Amazing work! I'm making my own and this saved me a lot of hassle
Glad it helped.
Amazing video that has covered a lot of things i wanted to grasp. I am new to this so i hope i am not asking the obvious
For the voltage divider you used identical resistors which is why you used a multiplier of two in the code correct? could you have used different value resistors to get 3.3v and not used the multiplier? any benefit of one over the other and what value resistor did you use?
also the polynomial is to approximate the discharge curve of the LI battery correct?
again, great video
Yes, the identical resistors were to cut the voltage in half. When doing a voltage divider, you're going to be working with a ratio. If you take a reading between two resistors, the resulting voltage will be V*r2/(r1+r2). Since both r1 and r2 are identical, my resulting voltage is V*1/2. If you want 3.3V, then the ratio you need depends on what the input voltage is. The resistors can be almost any values, as long as they result in the correct ratio.
Practically, however, there are a couple of other considerations. Lower resistors values will result in more current flowing through the divider (total resistance is R1+R2, and thus current will be V/(R1+R2)). If there is no switch breaking that circuit, then that current will flow all the time. This can be bad for battery life, especially for a device which is mostly "off". So for battery monitoring, I like to use larger values (100k to 1m). You can't go too crazy though, because you do have to have enough current for the sense voltage to be measurable.
And yes, the polynomial was just an approximation of the this batteries discharge curve. It's not super accurate, but it's enough for a rough estimate. Linear honestly isn't much worse than polynomial given the other inaccuracies in the system.
Thank you for sharing your project, most interesting.
Thanks a lot for sharing your project! A quick question: the Xiao C3 is rated up until 3.6V whilst the battery is 3.7V (and I assume the voltage goes even higher, maybe lower 4.x when fully charged). Have you experienced any issues with it, should I be considered if I were to copy your setup with a 3.7V LiPo battery?
Not sure where you're getting the 3.6V from, so IDK what to reference there. The Xiao is made for 3.7V LiPo batteries. The higher charged state voltages (~4.2V) are no problem; that's just how LiPo batteries are.
@@TechDregs it is under 4.2 Recommended Operating Conditions files.seeedstudio.com/wiki/Seeed-Studio-XIAO-ESP32/esp32-c3_datasheet.pdf
But clearly your setup works, so it's probably a non-issue. :)
That's power to the ESP32-C3 module itself. The battery is managed by a separate chip, and then ran through voltage regulators as output to the ESP32-C3 which never sees more than ~3.3V. You can see the power arrangement on the schematic: files.seeedstudio.com/wiki/XIAO_WiFi/Resources/Seeeduino-XIAO-ESP32C3-SCH.pdf
Is there any update on this project? How is the battery life? How accurate are your readings? I'd be very interested in a follow up
I can't speak to accuracy, as I have no other soil moisture measurement devices that use a different type of sensor. But since I reconfigured the sensor to draw power via GPIO that turns it off when in deep sleep, battery life is over four months on a charge. I did something like a followup in these videos:
ua-cam.com/video/4EZYYPmQnJY/v-deo.html
ua-cam.com/video/Yttauf94A04/v-deo.html
@@TechDregs Interesting videos, thanks!
How well did the capacitive sensor hold up?
It's still going. I haven't looked at it closely in a while... it's just out there doing its job.
Thanks, this is great and exactly what I want to create. Would you be willing to share the design for the case and a link to the battery you used (for sizing)?
I generally no longer share STLs for designs, but one thing that's helpful is that you can usually get STEP files for the SEEED Xiaos either directly from them or from grabcad. I wouldn't get this battery again, so I won't link it. I wasn't paying attention and ordered a 3-wire battery, and the third wire isn't useful (I think it's a thermistor in the battery for temp monitoring).
I was testing a very similar setup, and found that my Xiao ESP32C3 was still drawing ~25mA in deep sleep. I wasn't able to reduce the power consumption, so with it only lasting a day or two, I ended up making it a hardwired system instead. What kind of battery life did you ultimately end up with?
25mA is way too high. That doesn't seem like it's going into deep sleep at all.
Battery life will obviously depend on the battery size you use, but with my current setup where I power the sensor via GPIO pin, I last recharged on January 24th, and it's showing roughly 50% battery remaining.
@TechDregs good to hear yours is working as intended. I had 3 separate sensors connected to GPIO 2-4, and a high gain antenna, but even with the antenna disconnected, it was drawing around 100mA in use, and then dropping to a steady 25mA during deep sleep. I tried looking at all of the deep sleep protocols, but never could figure out what was causing the high draw. I'll have to take another look at it soon. Thanks for the info!
Hmm... yeah, I don't know. It just doesn't sound like you're not hitting deep sleep. How are you measuring current draw? Are you using a voltage divider on the battery leads for ADC measurement? Are the GPIOs being set to off/low for each sensor prior to sleep?
@@TechDregs I used a multimeter in series to measure the current. I've been using the esp_deep_sleep() function with a number of different sensor controllers I've built, and know that the devices do in fact enter deep sleep (or some semblance of it), but for whatever reason the current draw is still high. They don't appear to enter any of the alternative sleep modes. I dabbled with trying to set the GPIOs to low individually before entering deep sleep, but that never seemed to make a difference. No worries! I need to do more testing to get to the bottom of it.
@@holodiscus Very strange. Is the current draw still high without the sensors? I would probably check what happens when adding them one by one so see if you can isolate what's causing the draw.
Do you have a github page or a written guide with wiring diagrams? I'm just getting started with ESP32 using batteries. Also, did you consider fitting a solar panel to this battery to keep it topped up?
ua-cam.com/video/Yttauf94A04/v-deo.html
This is my very first ESP32 project and I am trying to understand how to connect a 18650 battery to the board. How did you make the connection? Are you connecting it to the 5v pin?
If you're using a Xiao, the battery connections are on the underside of the board. There are two pads there than you solder the battery connections to.
I pasted your yaml code into the code for an ESP-D1 on Home Assistant and did a search and replace of the > and < markers as directed. When I run the "validate" on the code, I get the following error message:
INFO ESPHome 2024.3.1
INFO Reading configuration /config/esphome/d1-1.yaml...
ERROR Error while reading config: Invalid YAML syntax:
while scanning a simple key
in "/config/esphome/d1-1.yaml", line 61, column 9
could not find expected ':'
in "/config/esphome/d1-1.yaml", line 62, column 9
I do not see anything where I would think a ":" would be needed.
I'm not sure. It could be a spacing issue in your YAML or it could be a change to ESPHome that has occurred since I did this project. Lines 61/62 are in the WIFI setup for me, and I don't see any issues there, so I'm guessing it's in the lines above that somewhere. Just check all the indentation.
I haven't updated mine in a while, but next time I do I'll update the code in the details.
Can you charge the battery via the Xiao or do you need to de solder and charge via a charger. Thanks/
If you plug the Xiao into any USB port/charger, it will charge the battery. No need to desolder.
Ok, my sensor is working, it reads 30 second and after 3h in deep sleep. But I have 2 questions.
1. It seems that the Voltage reading is not very accurate. I have calibrate the value Many times but after some reboot it reads 0.2 0.3 V more or less than the real battery value. I have used two resistor 220k in parallel.
2. How can I do to allowr home assistant to show in the dashboard the last value read when the esp32 is in deep sleep.
Thanks in advance for any help.
For #2, that should just show up automatically over time. For #1, battery voltage in my experience can fluctuate a bit, especially when it's above 4.0V. It seems to settle down and get smoother below that.
read esphome deepsleep page.
While in deep sleep mode, the node will not do any work and not respond to any network traffic, even Over The Air updates. If the device’s entities are appearing as Unavailable while your device is actively sleeping, this component was likely added after the device was added to Home Assistant. To prevent this behavior, you can remove and re-add the device in Home Assistant.
i think this should solve your problem.
nice video sir, i do as well as your code , but after update ESPHome platform - adc duplicate error show , so what to do any other way?
Looks like mine died this week (I think water got into it), so I can't test this, but try replacing:
pin: 4
with:
pin:
number: 4
inverted: false
allow_other_uses: true
In both places that it appears. See if that works. They implemented a change recently to break using a pin multiple times unless you specifically allow it.
@@TechDregs Thank you , New ESPhome update as well as working fine pin multiple
how much battery life as well as your deep sleep time?
I wake mine up for 10s every 6hours (so, 4x a day). The battery I used lasts ~3.5months on a charge.
@@TechDregs good battery backup 👍
Can Share all ? the project is amazing. I've been looking for something like this for a long time and now I'm grateful to you for showing it. can you show the wiring properly? Thx
There's actually very little wiring. The battery is connected to the battery pads on the bottom of the board. I've got a voltage divider on the positive lead, with one side to ground and the other to an analog pin. The sensor board only has three wires: power in, ground, and sensor out. The sensor out just needs to go to an analog pin. The YAML is in the description; so you can see which pins I used there for the sensor and battery voltage readings. One trick that I have done since this video is powering the sensor from a digital GPIO pin, which I enable when the device wakes up and disable when it goes to sleep. That has a huge impact on battery life, as this sensor draws about 5mA when it's on.
@@TechDregs great stuff. Would you have the YAML that includes the GPIO pin as the 'smart' power source for the sensor?
I updated the details with the code. Basically, you just add onboot and onshutdown commands, and add the pin below as a switch. Make sure to change the GPIO to the pin you're using for power to the sensor. I also added a wifi signal sensor, since that can be useful to see.
thanks@@TechDregs , I was implementing it on my side and apparently HA after 2023 requires the use of 'allow_other_users' if the same pin is used for several uses (battery life and battery voltage)
I replaced pin: 4 for 'pin:
number: 4
allow_other_uses: True'
What code did you use to calibrate the moisture sensor? (so I can get my min and max values)
Can you share the 3d printed design? I'd like to make my own :)
can you show me what kind of resin did you have use (black/gray)?
It's just cheap basic epoxy from a local hardware store.
Thank you. i wil do it to. 😀
Hello, I'm trying to make my yaml configuration, but I got this error: Pin 0 is used in multiple places. Could you help me? thanks in advance
Failed config
sensor.adc: [source :55]
Pin 0 is used in multiple places.
platform: adc
pin:
number: 0
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
inverted: False
ignore_strapping_warning: False
drive_strength: 20.0
name: Battery Life
unit_of_measurement: %
device_class: battery
update_interval: 2s
attenuation: 11db
filters:
- multiply: 2.0
- calibrate_polynomial:
degree: 4
datapoints:
- from: 3.4
to: 0.0
- from: 3.6
to: 8.43
- from: 3.81
to: 50.06
- from: 3.86
to: 57.63
- from: 3.92
to: 72.56
- from: 3.96
to: 90.96
- from: 4.05
to: 100.0
- lambda: !lambda |-
if (x > 0) return 0;
else if (x > 100) return 100;
else return (x);
disabled_by_default: False
force_update: False
accuracy_decimals: 2
state_class: measurement
raw: False
sensor.adc: [source :80]
Pin 0 is used in multiple places.
platform: adc
pin:
number: 0
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
inverted: False
ignore_strapping_warning: False
drive_strength: 20.0
name: Battery Voltage
update_interval: 2s
attenuation: 11db
filters:
- multiply: 2.0
disabled_by_default: False
force_update: False
unit_of_measurement: V
accuracy_decimals: 2
device_class: voltage
state_class: measurement
raw: False
You need to allow other uses. It's an update ESPHome has since I made this. Use it every time you setup a pin which is used more than once.
pin:
number: 0
allow_other_uses: True
@@TechDregs grazie
Hi, great job, what is the battery duration with that configuration?
With the GPIO power setup, at least 4 months on a charge.
Pretty cool. +1 sub
How long it runs at battery?
Currently, it's been almost 4 months since I last charged it. It might last another month or two, looking at the voltage plots.
can you send the link of soil sensor and where did you get it connected. with my sensor only stupid values
Did you calibrate your sensor values? You need to test what voltage it sends in open air and fully submerged in water. I used these: www.amazon.com/Capacitive-Moisture-Corrosion-Resistant-Detection/dp/B07SYBSHGX
Would you be able to explain the switch code here. switch:
- platform: gpio
pin: GPIO10
id: sensor_power
internal: true
Sorry a noob. Have you got a switch wired into pin 10 thanks for a great project
I'm using pin 10 to provide the power to the soil moisture sensor rather than wiring it directly to the output voltage pins on the ESP32 board. That allows me to turn power to the sensor on and off. This is the routine that sets up pin 10 as a power outlet that can be turned on and off (which ESPHome calls a switch). So, switch: - platform: GPIO tells ESPHome that this will be a binary on/off switch using a GPIO pin. ID: sensor_power is the internal name of that switch so I can refer to it elsewhere (like the boot and shutdown sequences). Internal: true means that it isn't exposed externally, so the switch won't show up in Home Assistant.
Sorry just reading this again and doing a little Google I was un aware you could supply 3.5 volts from a gpio pin. Other than vin etc. am I misunderstanding. Probably 😢
Depends on the pin. Some pins are input only. But GPIO pins can output about 40mA of current at 3.3v. There is also a total power budget that you have to stay under, but if you're only doing one or two pins of output, that's not a concern.
Awesome thank you. Love to learn.
@@TechDregs Pleas ignore this if you wish. I know you are not a help board. But I am curious. I have it all working. But when it goes into deep sleep it becomes unavailable on the dashboard. I have read on a few forums that it is best to change over to mqtt and then you can use birth and will_message. But I did a quick try and havn't been able to do the switch to mqtt. I am wondering if you have the same issue.
Thanks for the tutorial! But by Pasting your code i get the following error code:
INFO ESPHome 2024.5.5
INFO Reading configuration /config/esphome/boden-feuchtigkeit-1.yaml...
ERROR Error while reading config: Invalid YAML syntax:
while scanning a simple key
in "/config/esphome/boden-feuchtigkeit-1.yaml", line 16, column 1
could not find expected ':'
in "/config/esphome/boden-feuchtigkeit-1.yaml", line 17, column 1
can someone help me out? Many thanks!
Check your spacing. YAML is very sensitive to indentation.
@@TechDregsthanks. Will double ckeck
I tried to ask chat gpt and it gave my this code. 👨🏼💻
How do you think a solar charger would do?
Already done. :) ua-cam.com/video/Yttauf94A04/v-deo.html
@@TechDregs 🐐🐐
How did you get the voltages for the battery?
See ~2m in the video. Just taking a reading via a voltage divider to an analog pin on the Xiao.
How will you charge it?
I'll just pull it and charge it inside on a cell phone charger.
I can't see a link to your 3D printed parts. May i ask?
Sorry, I generally no longer upload 3D prints. Too many of my past designs ended up being sold on ebay and etsy.
@@TechDregs Is it possible that you send me the 3D print file in an E-Mail? I will not sell the file. I just ordered a printer and i´m verry new in this material.
@@TechDregs Thanks for the project also is it possible to connect the battery directly to the esp32 c3 supermini?, and is it possible to send the 3D print file by email? Of course, I will not move the file to the web. Well thank you
@@rudopodkrivacky I don't the supermini has onboard battery management.
I cannot get this to compile. Can someone help me out.
It's an older project, and ESPHome has received many updates in the meantime. It will require several changes to work with current versions of ESPHome. You might check on the ESPHome discord for help with all the adjustments.
normal water does not conduct like mineral salts or acid or hard ground water PH
but great project.
It is not a conductive sensor, so the conductivity is not all that important. Probably calibration is needed anyway, the soil will have an influence on the readings.
ua-cam.com/video/m0mcCtcViTY/v-deo.html