Catnip I2C Sensor not Working

Hey Guys,
im currently trying to measur the Moisture of my Soil using these Catnip I2C sensors.

The problem I ran into is that I wont get a reading frome the sensors, the output I get, using the example sketch, looks like this:

I2C Soil Moisture Sensor Address: 20
18:09:17.101 -> Sensor Firmware version: FF
18:09:17.133 -> 
18:09:17.133 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:20.173 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:23.275 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:26.357 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:29.421 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:32.520 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535
18:09:35.601 -> Soil Moisture Capacitance: 65535, Temperature: -0.10, Light: 65535

I've already tried to add " Wire.setClockStretchLimit(2500);"/ Wire.setClockStretchLimit(4000); as suggested by Github/the sellers page since I use an ESP6266.

Running the I2c scanner sketch returns the following:

18:11:51.385 -> Scanning...
18:11:51.385 -> I2C device found at address 0x21  !
18:11:51.431 -> done
18:11:51.431 -> 
18:11:56.377 -> Scanning...
18:11:56.409 -> I2C device found at address 0x21  !
18:11:56.453 -> done

I'am using 5k ohm resistors ond SDA and SCL and run the Sesnor on 3.3V

Full < CODE/ >, schematics, and pictures please.

1 Like

The I2C scanned reports a device at address 0x21.

You seem to be using address 20 (or 0x20).

1 Like

Sorry Guys!

The Example code

#include <I2CSoilMoistureSensor.h>
#include <Wire.h>

I2CSoilMoistureSensor sensor;

void setup() {
  Wire.begin();
  Wire.setClockStretchLimit(4000);
  Serial.begin(9600);

  sensor.begin(); // reset sensor
  delay(1000); // give some time to boot up
  Serial.print("I2C Soil Moisture Sensor Address: ");
  Serial.println(sensor.getAddress(),HEX);
  Serial.print("Sensor Firmware version: ");
  Serial.println(sensor.getVersion(),HEX);
  Serial.println();
}

void loop() {
  while (sensor.isBusy()) delay(50); // available since FW 2.3
  Serial.print("Soil Moisture Capacitance: ");
  Serial.print(sensor.getCapacitance()); //read capacitance register
  Serial.print(", Temperature: ");
  Serial.print(sensor.getTemperature()/(float)10); //temperature register
  Serial.print(", Light: ");
  Serial.println(sensor.getLight(true)); //request light measurement, wait and read light register
  sensor.sleep(); // available since FW 2.3
}


If I looked at the right library, then your code seems to be using the default library address of 0x20.

Try:

I2CSoilMoistureSensor sensor( 0x21 );
1 Like

THX dude!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.