My code compiles fine but when i try to upload it, i get this error (I haven't started the calibration yet because of this). Does the problem lie in the code or my hardware set-up?
rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
13:50:56.881 -> configsip: 0, SPIWP:0xee
13:50:56.881 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
13:50:56.881 -> mode:DIO, clock div:1
13:50:56.881 -> load:0x3fff0030,len:4916
13:50:56.881 -> load:0xd0012000,len:4109
13:50:56.881 -> ho 0 tail 9 room 7
13:50:56.881 -> load:0x20024340,len:2080833800
13:50:56.881 -> 1150 mmu set 00010000, pos 00010000
13:50:56.915 -> 1150 mmu set 00020000, pos 00020000
13:50:56.915 -> 1150 mmu set 00030000, pos 00030000
13:50:56.915 -> 1150 mmu set 00040000, pos 00040000
13:50:56.950 -> 1150 mmu set 00050000, pos 00050000
13:50:56.950 -> 1150 mmu set 00060000, pos 00060000
13:50:56.950 -> 1150 mmu set 00070000, pos 00070000
13:50:56.993 -> 1150 mmu set 00080000, pos 00080000
13:50:56.993 -> 1150 mmu set 00090000, pos 00090000
13:50:56.993 -> 1150 mmu set 000a0000, pos 000a0000
13:50:57.038 -> 1150 mmu set 000b0000, pos 000b0000
13:50:57.038 -> 1150 mmu set 000c0000, pos 000c0000
13:50:57.038 -> 1150 mmu set 000d0000, pos 000d0000
13:50:57.038 -> 1150 mmu set 000e0000, pos 000e0000
13:50:57.072 -> 1150 mmu set 000f0000, pos 000f0000
13:50:57.072 -> 1150 mmu set 00100000, pos 00100000
13:50:57.072 -> 1150 mmu set 00110000, pos 00110000
13:50:57.120 -> 1150 mmu set 00120000, pos 00120000
13:50:57.120 -> 1150 mmu set 00130000, pos 00130000
13:50:57.120 -> 1150 mmu set 00140000, pos 00140000
13:50:57.120 -> 1150 mmu set 00150000, pos 00150000
13:50:57.158 -> 1150 mmu set 00160000, pos 00160000
13:50:57.158 -> 1150 mmu set 00170000, pos 00170000
13:50:57.158 -> 1150 mmu set 00180000, pos 00180000
13:50:57.191 -> 1150 mmu set 00190000, pos 00190000
13:50:57.191 -> ets Jul 29 2019 12:21:46
Here is my code:
#include <Arduino.h>
// Pin definitions
#define PH_SENSOR_PIN 34
#define TDS_SENSOR_PIN 35
// Constants
const float VREF = 3.3; // ESP32 analog reference voltage (3.3V)
const int ADC_RESOLUTION = 4095; // dont change
//y=mx+b
float phSlope = 0.0; // change during calibration
float phIntercept = 0.0; // change during calibration
//y=mx+b
float tdsSlope = 0.0; // Slope (scaling factor)
float tdsIntercept = 0.0; // Intercept (offset)
// Global variables
float phValue = 0.0;
float tdsValue = 0.0;
void setup() {
Serial.begin(115200);
// Initialize pins
pinMode(PH_SENSOR_PIN, INPUT);
pinMode(TDS_SENSOR_PIN, INPUT);
}
void loop() {
// Small delay to stabilize ADC readings
delay(10);
// Read analog values
int rawPh = analogRead(PH_SENSOR_PIN);
delay(10);
int rawTds = analogRead(TDS_SENSOR_PIN);
// Convert to voltage
float voltagePh = (rawPh / (float)ADC_RESOLUTION) * VREF;
float voltageTds = (rawTds / (float)ADC_RESOLUTION) * VREF;
// Calculate pH and TDS using linear equation
phValue = phSlope * voltagePh + phIntercept;
tdsValue = tdsSlope * voltageTds + tdsIntercept;
phValue = max(phValue, 0.0f);
tdsValue = max(tdsValue, 0.0f);
// Print values
Serial.print("pH: "); Serial.println(phValue);
Serial.print("TDS: "); Serial.println(tdsValue);
delay(1000);
}