Please help. Can not read voltage sensor after compile with thinger code

hello there, i made a simple project to measure a DC voltage using voltage sensor and ESP32. when i used my voltage sensor code, it worked to measured. but when i combined with thinger.io code, it can’t worked. anyone help me about this problem?
this is my combined code:

#define THINGER_SERIAL_DEBUG
#include <ThingerESP32.h>
#include "arduino_secrets.h"

ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

const int analogPin = 15;
float Vmodule = 0.0; 
float result = 0.0;
float R1 = 30000.0; //30k
float R2 = 7500.0; //7500 ohm resistor, 
int value = 0;
 
void setup()
{
   pinMode(analogPin, INPUT);
   Serial.begin(9600);
   thing.add_wifi(SSID, SSID_PASSWORD);
   thing["voltage"] >> outputValue(result);
}
 
void loop()
{
   thing.handle();
   value = analogRead(analogPin);
   Vmodule = (value * 5.0) / 4095.0;
   result = Vmodule / (R2/(R1+R2));
   
   Serial.print("voltage from module = ");
   Serial.print(Vmodule,2);
   Serial.print("volt");
   Serial.print(", measurement = ");
   Serial.print(result,2);
   Serial.println("volt");
   delay(500);
}

and this is the original code for voltage sensor:

const int analogPin = 15;
float Vmodule = 0.0; 
float result = 0.0;
float R1 = 30000.0; //30k
float R2 = 7500.0; //7500 ohm resistor, 
int value = 0;
 
void setup()
{
   pinMode(analogPin, INPUT);
   Serial.begin(9600);
  }
 
void loop()
{
   
   value = analogRead(analogPin);
   Vmodule = (value * 5.0) / 4095.0;
   result = Vmodule / (R2/(R1+R2));
   
   Serial.print("voltage from module = ");
   Serial.print(Vmodule,2);
   Serial.print("volt");
   Serial.print(", measurement = ");
   Serial.print(result,2);
   Serial.println("volt");
   delay(500);
}

and it’s the debug serial monitor for combined code:

[NETWORK] Starting connection...
[NETWORK] Connecting to network Sate gulung
[NETWORK] Connected to WiFi!
[NETWORK] Getting IP Address...
[NETWORK] Got IP Address: 192.168.1.9
[NETWORK] Connected!
[_SOCKET] Connecting to iot.thinger.io:25202...
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Connected!
[THINGER] Authenticating. User: stasiunsepedalistrik Device: ESP32
[THINGER] Writing bytes: 54 [OK]
[THINGER] Authenticated
voltage from module = 0.00volt, measurement = 0.00volt
[THINGER] Available bytes: 25
[THINGER] Writing bytes: 8 [OK]
voltage from module = 0.00volt, measurement = 0.00volt
[THINGER] Available bytes: 24
[THINGER] Writing bytes: 7 [OK]
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt
voltage from module = 0.00volt, measurement = 0.00volt

the original debug:

voltage from module = 1.15volt, measurement = 5.73volt
voltage from module = 1.14volt, measurement = 5.72volt
voltage from module = 1.14volt, measurement = 5.72volt
voltage from module = 1.12volt, measurement = 5.58volt
voltage from module = 1.14volt, measurement = 5.72volt
voltage from module = 1.14volt, measurement = 5.71volt
voltage from module = 1.14volt, measurement = 5.72volt
voltage from module = 1.15volt, measurement = 5.74volt
voltage from module = 1.12volt, measurement = 5.61volt
voltage from module = 1.15volt, measurement = 5.73volt
voltage from module = 1.15volt, measurement = 5.75volt
voltage from module = 1.15volt, measurement = 5.76volt
voltage from module = 1.14volt, measurement = 5.71volt
voltage from module = 1.13volt, measurement = 5.66volt
voltage from module = 1.16volt, measurement = 5.78volt

please help me because this is for my final project on campus :’)
thank you.

Hi,

ESP32 has two ADC, the ADC2 wont work if the WIFI is in use, change the reading pin to one assigned to ADC1

image

Hope this helps.

hi ega, Thank u so much for helping me. it works! :smiley: