BeFlE / SoMoSe

Soil Moisture Sensor
21 stars 6 forks source link

Arduino example still up to date for version 3.4? #20

Open R4M5E5 opened 3 months ago

R4M5E5 commented 3 months ago

Hey :) I'm currently struggling a bit to get my new SoMoSe working with my Arduino Pro Mini. For me the Serial output always says averaged humidity = 0. Is the example provided in the repo still up to date for version 3.4? https://github.com/BeFlE/SoMoSe/blob/fcd1b907ee02416727ecbd59eb8bc70b98bcb69b/Arduino/Demo.ino#L1-L42

R4M5E5 commented 3 months ago

So far I found out that my sensor is in low power mode per default, according to the manual I need to call the startMeasurement function and wait 250ms and then check the isMeasurementFinished function. I still have the problem though that most of the time the measured average humidity is 0. Sometimes I got a value of 1 or 2, even when the sensor is in relatively wet soil. The value is a byte so theoretically values up to 255 could be possible. Hardware version is 3.40 and firmware version is 1.10 Any idea what might be the problem here? The temperature value that I get from the sensor seems to make sense. It changes if I take the sensor in my hand and it usually is the same value as the temperature in the room. My sensor v2.2 is working with the same wiring and hardware setup.

BeFlE commented 3 months ago

Hi,

Can you check whether the reference values are set as specified in the data sheet? I have noticed that there seem to be problems sometimes when initializing the sensor for the first time. Sometimes the wet reference value is initialized to 0xFFFF. This should be corrected. This would also explain why the low power mode is active Tomorrow I can give you another code for this, unfortunately I'm not near my PC today.

Best regards Christian

R4M5E5 commented 3 months ago

Thank you, this seems to be the issue. The SoMoSe_getReferenceWet returns -1 which is 0xFFFF I guess. I have set it to 8000 and now it seems to be working :) Has the default value for the wet reference changed for the new sensors? Because with a value of 8000 the highest value for the average humidity I receive for very wet soil is around 30. With my old sensor I got values over 100 for completely wet soil.

BeFlE commented 3 months ago

Hi,

yes the reference values have changed in the new version. When first plugged into the ground, the sensor value will rise for a few hours. After that, however, it reacts quickly to changes. So did you read it once after a longer period of time in the soil? If the value is still too far off, you can also calibrate the reference value for your purposes.

Best regards Christian

R4M5E5 commented 3 months ago

Is there a documentation of this specific behavior that the reference value is automatically determined when first plugged into the ground? From your last post it sounds to me that it works somehow like this: When first plugged into the ground the sensor will automatically calibrate it self and update the reference values. After the calibration phase the reference value is stable.

How do I reset this calibration state? When is the calibration phase finished? Is the calibration also done in the low power mode? I'm asking because I'm building a battery powered device.

Up until a couple of days I was working with the old SoMoSe v.2.2 where my goal was to let my microcontroller(arduino pro mini) be in deepsleep most of the time and periodically wake up. I wanted to only supply the SoMoSe with power while my microcontroller is awake, then take a measurement and turn off the power of the SoMoSe and let the microcontroller go back to deepsleep. I was planning on using as Mosfet/Transistor to do this. Now with the knowledge that there is this calibration phase and that we now have a sleepmode I'm not sure if this is still the best approach. Can you give me more information how the sleepmode is supposed to be used?

BeFlE commented 3 months ago

Sorry, that was a bit misleading. There is no calibration phase.

I meant that the sensor needs a few hours to rise to the actual value when it is plugged into the ground. This is undesirable behavior, but I was unable to compensate for it with the design. The effect is much stronger with v3.4 than with v2.2. It looks as though you are charging a capacitor with a very large time constant when you plot the humidity value over time.

However, once the sensor has been in the ground for 24 hours, this phenomenon is no longer a problem as it is no longer noticeable.

If you are working with battery-operated solutions, I recommend using the v3.4, as it was designed exactly for this purpose.

I am also currently working on such a solution, including solar, with ESP32. Initial tests have shown that it works without any problems.