Moisture sensor example for Cube Cell

Just wonder if anyone has an example sketch for a moisture sensor on a CubeCell?

tried didn’t work

#define SensorPin GPIO2 
float sensorValue = 0; 
void setup() { 
 Serial.begin(9600); 
} 
void loop() { 
 for (int i = 0; i <= 100; i++) 
 { 
   sensorValue = sensorValue + analogRead(SensorPin); 
   delay(1); 
 } 
 sensorValue = sensorValue/100.0; 
 Serial.println(sensorValue); 
 delay(30); 
} 

I assume your sensor is Analog output.

  1. GPIO2 no an ADC input pin. You cannot get a correct reading by analogRead() on this pin.
  2. HTCC-AB01 only has 1 ADC pin and connected to the Vbat voltage divider internally.
  3. HTCC-AB02 has 3 ADC pin and ADC1 pin connected to the Vbat voltage divider internally.

If you use HTCC-AB01, please check this to know how to use it.
https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/frequently_asked_questions.html

If you use HTCC-AB02, please check HTCC-AB02’s pins_arduino.h and ADC example.
Just replace “ADC” in ADC example with the pin you connected to sensor output.

#define ADC P2_0
#define ADC1 ADC
#define ADC2 P2_1
#define ADC3 P2_2

Can you tell us the model of the sensor?

sure it’s Arduino Compatible Soil Moisture Sensor Module

https://www.jaycar.com.au/arduino-compatible-soil-moisture-sensor-module/p/XC4604

I’m also having trouble compiling code for a I2C capacitive soil moisture sensor. The library I’m using is this one.

Does anyone know how to fix the errors the arduino IDE is showing?

Thanks heaps

hi,

You can comment out these functions directly. There are no such functions in the development environment of cubecell.
%E5%9B%BE%E7%89%87

the Adafruit_seesaw library is designed for SAMD09 core, I think rewrite the communication program using the Cubecell I2C library should be easier.

OR

Edit the library Adafruit_seesaw.h and Adafruit_seesaw.c.
Only keep begin() , getVersion(), getTemp() , .touchRead() and sub-function called by these function.

Thanks guys I’ll try modify the code and see how I go.

Yeah no luck, my code skills aren’t quite up to scratch to get this working :frowning:

I read the instructions for AB01 but is is not clear what do you mean by “remove the resistance”. I have joined the 2 points in the picture. However i still read the "battery: (i am poweredvia USB)