I’m using pin D4 aka A0 on ESP32 to read analog value from i2c soil moisture sensor. Sensor working properly when I’m using test code int sensorPin = 4; // select the input pin for LDR
``cpp
int sensorValue; // variable to store the value coming from the sensor
void setup() {
Serial.begin(115200);
}
void loop() {
delay(1000);//sets serial port for communication
//esp_sleep_enable_ext0_wakeup(GPIO_NUM_4, 0);
//sensorValue = digitalRead(sensorPin);// read the value from the sensor
//Serial.println(sensorValue);
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);//prints the values coming from the sensor on the screen
delay(1000);
}
But after using ThingerWifi.handle on my code, sensor just read value 4095 (its indicate sensor detect no moisture, in fact it is not). I;m trying this too with LDR analog sensor, but its shows value 0 then up to 2400 then back to 0 again. Is it a bug on ThingerWifi library? How I overcome this?
Code after using ThingerWifi.handle
```cpp
#include <ThingerWifi.h>
int soil_sensor= 4;
//WiFi credentials
#define ssid "xxxxxxxxx"
#define password "xxxxx"
//thinger.io credentials
#define user_id "xxxxx"
#define device_id "xxxxx"
#define device_credential "xxxxxx"
ThingerWifi thing(user_id, device_id, device_credential);
void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
delay(1000);
Serial.println("Connecting to: ");
Serial.println(ssid);
thing.add_wifi(ssid,password);
Serial.println("WiFi connected");
thing["soilhumidity"]>> outputValue(analogRead(A0));
}
void loop() {
thing.handle();
//for testing purpose
float humidity = analogRead(A0);
Serial.println(humidity);
soilhumid= humidity;
delay(1000);