Soil moisture sensor - strange readings
Teknor last edited by
I have a straight forward MySensor setup with a soil moisture sensor. I am currently at a trail and error stage, but plan to impement this in my green house for seasoning plants.
Problem is I get strange readings in Domoticz. Very little difference in the readings between the dry and wet soil. Also the readings varies a lot.
(I have not tried to tune the knob on the sensor board.)
Is it normal with this variation and little difference between wet and dry?
The sketch is the standard MySensor code described in the build-section of this site.
All help is highly appreciated.
Have you tried with some different soil types? The trim pot on the sensors should set the threshold for the digital output, it shouldn't change the analog readings
@Teknor The sketch in that page is not designed to work with type of sensor, but with one with a voltage divider. The last comment in that page explains it.
Teknor last edited by
Thanks for the answers, not sure if I am closer to a solution. I am using digital output from the sensor according the the Mysensors description. Is it recommended to use analog output, if so, are there any sketches I can use "out-of-the-box"?
I have a FC28 sensor, not a YL-sensor mentioned above.
@Teknor @gohan The sketch on the build page is for analog readout, while the wiring section describes a digital connection -- very confusing
You can also get some inspiration from the soil moisture sensor I built for the dollhouse
@Teknor I had the same sensor, just threw the board away and used the wires and the probe. Then I hooked it with a voltage divider using a 10k resistor. You can use the sketch I shared in the same comment for inspiration, or the more recent one here
This sketch does voltage flipping which means it takes two readings with different polarization to avoid corrosion. Without it, the probe would last only a few weeks.
You may of course continue using the comparator board if you just want to set a warning when moisture level is too low.
Teknor last edited by Teknor
Thanks @manutremo . Will give it a try, and use your sample sktetch. Just to get things right, you mean just keep the "fork"? Any documentation on the HW setup, or just a 10k resistor?
@Teknor Yes I meant keep the fork
The setup is simple: a voltage divider involves 2 resistors in series between Vcc and GND, and a sampling point in between them. In your case, the fork will be one of the resistors. Then you need to measure the voltage in the middle connection between the fork and the 10k resistor, and connect it to an analog pin in the arduino.
You will find a good description with images here.
I just made a change to that setup (in addition to using a 3.3v arduino instead of 5v) in that instead of using Vcc and GND, I used two digital pins (4 and 7 in my case) which I enable and disable so I can polarize the fork in one direction or the opposite. Be aware that the resistor should be connected to pin in this case, and the fork to pin 7; otherwise the formula of the voltage divider needs to be modified.
Some sources also recommend bypassing the measuring point to GND using a small cap to avoid noise in that point, but I haven't experienced that problem.
Then you just need to calibrate the sensor by putting the fork into a glass of water and then out in the air, and typing the values you get into the appropriate define's.