Adafruit STEMMA I2C capacitive moisture sensor - how does it

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
CvRNL
 
Posts: 3
Joined: Mon Jul 27, 2020 5:54 am

Adafruit STEMMA I2C capacitive moisture sensor - how does it

Post by CvRNL »

Hey all,

I have the Adafruit STEMMA I2C capacitive moisture sensor. I am trying to understand how this sensor actually works, because it does seem to work a little different than most other capacitive soil moisture sensor. This is how far I got, but maybe someone can correct/add more info (this is based on info from Atmel, the product page, the Adafruit Github code for this sensor and from this forum, and from a paper by Furlan 2021):

A) This sensor only works with one metal capacitor plate. Instead of a ground plate, it uses the actual ground (or in the case of this sensor the actual soil). Therefore it works as a single self-capacitance sensor.

B) The SAM D10 chip starts by charging the capacitor plate to a known voltage (I assume 3.3 volt, given that this is the input voltage into the chip?).

C) Once charged to the known voltage, the chips let’s the capacitor discharge (how?). The time it takes to discharge is measured. The wetter the soil is, the more capacitance the soil capacitor contains, and the more charge it will hold at the known voltage. Therefore the time it takes to discharge will be determined by the amount of water that is present in the soil around the sensor. (But what does the value that you get from the code actually stand for? Seconds, milliseconds? And is there maybe a formula to convert it into capacitance?

Hope someone can see if this makes sense, and add some missing pieces! Especially how the chip works to charge/discharge is still a bit of a mistery for me.

Cheers!

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit STEMMA I2C capacitive moisture sensor - how doe

Post by mikeysklar »

CvRNL,

While we do not have any formal write up on how the sensor works pointing you to the relevant chunk of code might be of value.
This design is superior with a capacitive measurement. Capacitive measurements use only one probe, don't have any exposed metal, and don't introduce any DC currents into your plants. We use the built in capacitive touch measurement system built into the ATSAMD10 chip, which will give you a reading ranging from about 200 (very dry) to 2000 (very wet). As a bonus, we also give you the ambient temperature from the internal temperature sensor on the microcontroller, it's not high precision, maybe good to + or - 2 degrees Celsius.
https://learn.adafruit.com/adafruit-ste ... r/overview

Code: Select all

    def moisture_read(self):
        """Read the value of the moisture sensor"""
        buf = bytearray(2)

        self.read(_TOUCH_BASE, _TOUCH_CHANNEL_OFFSET, buf, 0.005)
        ret = struct.unpack(">H", buf)[0]
        time.sleep(0.001)

        # retry if reading was bad
        count = 0
        while ret > 4095:
            self.read(_TOUCH_BASE, _TOUCH_CHANNEL_OFFSET, buf, 0.005)
            ret = struct.unpack(">H", buf)[0]
            time.sleep(0.001)
            count += 1
            if count > 3:
                raise RuntimeError("Could not get a valid moisture reading.")

        return ret
https://github.com/adafruit/Adafruit_Ci ... /seesaw.py

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”