ESP01S + ADS1115 + voltage divider had wdt reset issue

Hello. I had issues of wdt reset rst:4. Attached is the circuit. The green module is mini560, blue module is ADS1115 and ESP01S. I also utilized voltage divider, R1 is 47k and R2 is 10k ohm. The ADS module should read the 9V battery voltage. This project suppose for monitoring 14V battery and I am testing with 9V battery and 12v DC, which resulting to the issues. The ESP01S also will supply battery voltage data to ESP32 as a hub.

I stucked for few days, debugging code, and dont know whats wrong. Tested with multi-meter, the voltage on A0 is correct around 1.5v~ when tested with 14V battery, voltage into the esp01s is around 3.475v~, and everything is okay.

I added 470mf capacitor to esp01s gnd and vcc, but not in the circuit diagram.

Here are the error logs:

Initializing ADS1115...
ADS1115 found on attempt 1
ADS1115 ready. PGA=±4.096V
Voltage multiplier: 5.7000
Hub peer registered: OK
MAC: ----------------------
WiFi channel set to: 1

Transmitting...
First TX in 2 seconds...

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00044870
~ld

And keep looping.

Here are the codes of esp01s:

#include <ESP8266WiFi.h>
#include <espnow.h>
#include <Wire.h>
#include <Adafruit_ADS1X15.h>

// ============================================
// CONFIGURATION
// ============================================

uint8_t hubMacAddress[] = {0x6C, 0xC8, 0x40, 0x56, 0x9C, 0x60};

#define VOLTAGE_DIVIDER_R1 47000.0
#define VOLTAGE_DIVIDER_R2 10000.0
#define VOLTAGE_MULTIPLIER ((VOLTAGE_DIVIDER_R1 + VOLTAGE_DIVIDER_R2) / VOLTAGE_DIVIDER_R2)

#define CHANNEL 1
#define SENSOR_ID 1
#define UPDATE_INTERVAL 2000

// ============================================
// DATA STRUCTURE
// ============================================

typedef struct {
  uint8_t sensor_id;
  float voltage;
  uint32_t timestamp;
  uint16_t adc_raw;
  uint8_t status;
} sensor_data_t;

// ============================================
// GLOBALS
// ============================================

Adafruit_ADS1115 ads;
unsigned long lastUpdate = 0;
uint32_t packetCount = 0;
uint32_t errorCount = 0;

// ============================================
// CALLBACKS
// ============================================

void onDataSent(uint8_t *macAddr, uint8_t sendStatus) {
  if (sendStatus != 0) {
    errorCount++;
    Serial.printf("TX failed (status %d) total errors: %lu\n", sendStatus, errorCount);
  }
}

// ============================================
// SETUP
// ============================================

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println("\n========================================");
  Serial.printf("SimEye Satellite %d Starting...\n", SENSOR_ID);
  Serial.println("========================================");

  // I2C faster speed
  Wire.begin(0, 2); // SDA=GPIO0, SCL=GPIO2
  Wire.setClock(400000); // 400kHz - faster reads
  delay(200);

  // Disable software watchdog during setup
  ESP.wdtDisable();

  Serial.println("Initializing ADS1115...");

  bool adsOK = false;
  for (int i = 1; i <= 10; i++) {
    if (ads.begin(ADS1X15_ADDRESS, &Wire)) {
      adsOK = true;
      Serial.printf("ADS1115 found on attempt %d\n", i);
      break;
    }
    Serial.printf("Attempt %d/10 failed, retrying...\n", i);
    delay(300);
    ESP.wdtFeed();
    yield();
  }

  if (!adsOK) {
    Serial.println("FATAL: ADS1115 not found!");
    Serial.println("Check: VCC=3.3V, GND, SDA=GPIO0, SCL=GPIO2, ADDR=GND");
    while (true) {
      delay(1000);
      ESP.wdtFeed();
    }
  }

  ads.setGain(GAIN_ONE); // ±4.096V
  Serial.println("ADS1115 ready. PGA=±4.096V");
  Serial.printf("Voltage multiplier: %.4f\n", VOLTAGE_MULTIPLIER);

  // WiFi & ESP-NOW
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  if (esp_now_init() != 0) {
    Serial.println("ERROR: ESP-NOW init failed!");
    while (true) {
      delay(1000);
      ESP.wdtFeed();
    }
  }

  esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
  esp_now_register_send_cb(onDataSent);

  int peer = esp_now_add_peer(hubMacAddress, ESP_NOW_ROLE_SLAVE, CHANNEL, NULL, 0);
  Serial.printf("Hub peer registered: %s\n", peer == 0 ? "OK" : "FAILED");
  Serial.printf("MAC: %s\n", WiFi.macAddress().c_str());

  wifi_set_channel(CHANNEL);
  Serial.printf("WiFi channel set to: %d\n", CHANNEL);

  Serial.println("========================================");
  Serial.println("Transmitting...");
  Serial.println("First TX in 2 seconds...");
}

// ============================================
// LOOP
// ============================================

void loop() {
  // Force WiFi channel every cycle (reduces mismatch)
  wifi_set_channel(CHANNEL);

  unsigned long now = millis();

  if (now - lastUpdate >= UPDATE_INTERVAL) {
    lastUpdate = now;

    // Read AIN0 with reduced delay
    float total = 0;
    int valid = 0;

    ESP.wdtFeed();
    yield();

    for (int i = 0; i < 5; i++) {
      int16_t raw = ads.readADC_SingleEnded(0);

      // Skip invalid reads quickly
      if (raw == 0 || raw == -32768) {
        Serial.printf("WARN: ADC invalid read %d (skipped)\n", raw);
        continue;
      }

      ESP.wdtFeed();
      yield();

      float ainVoltage = ads.computeVolts(raw);
      float batteryVoltage = ainVoltage * VOLTAGE_MULTIPLIER;

      if (batteryVoltage > 0.5 && batteryVoltage < 20.0) {
        total += batteryVoltage;
        valid++;
      }

      delay(5); // Reduced from 15ms
      yield();
    }

    float voltage = (valid > 0) ? (total / valid) : 0.0;
    int16_t rawADC = ads.readADC_SingleEnded(0); // final read for reporting

    // Build packet
    sensor_data_t data;
    data.sensor_id = SENSOR_ID;
    data.voltage = voltage;
    data.timestamp = now;
    data.adc_raw = (uint16_t)rawADC;
    data.status = (voltage > 0.5 && voltage < 20.0) ? 0 : 1;

    // TX with timing monitor
    unsigned long txStart = millis();
    uint8_t result = esp_now_send(hubMacAddress, (uint8_t *)&data, sizeof(data));
    unsigned long txDuration = millis() - txStart;

    if (txDuration > 50) {
      Serial.printf("WARNING: TX took %lums\n", txDuration);
    }

    if (result == 0) {
      packetCount++;
      Serial.printf("[%lus] TX #%lu: V=%.2fV Raw=%d Valid=%d/%d Status=%d\n",
                    now / 1000, packetCount, voltage, rawADC, valid, 5, data.status);
    } else {
      errorCount++;
      Serial.printf("[%lus] TX FAILED error=%d errors=%lu\n",
                    now / 1000, result, errorCount);
    }
  }

  delay(5);
  yield();
}

Remove all Serial.print type stuff from callbacks. You can't print from interrupt level in many cores. ESP8266 may well be one of them.

Add Serial.prints in loop() to discover where the watchdog is barking.

Can you post an annotated schematic, the partly out of focus picture does not convey enough information.

You stopped the sofware WDT and never restarted it. That will cause a hardware WDT timeout.

Thank you very much will update soon once i got my hands with them.

Thanks ! Will update to you soon sir.

There is no need to disable the watchdog. Using delay or yield in a loop that may consume a lot of time is usually all that is needed.