DFR0300 Gravity Analog Electrical Conductivity Sensor Meter V2 K=1 (ESP32)
Refer to the code on the page below
In case I am using ESP 32, how should I edit the code below?
voltage = analogRead(EC_PIN)/1024.0*5000; // read the voltage
Also I am supplying 3.3V power to the converter circuit
If you are using an ESP32 board and supplying 3.3V power to the converter circuit, you can edit the code as follows:
voltage = analogRead(EC_PIN) / 4095.0 * 3300; // read the voltage (ESP32 has 12-bit ADC)
The ESP32 has a 12-bit ADC, which means it can provide 4096 (2^12) digital values for a given analog input voltage range. Therefore, to convert the analog voltage reading to a digital value, you need to use the value 4095 instead of 1024. Additionally, since you are supplying 3.3V power to the converter circuit, you should multiply the digital value by 3300 instead of 5000 to get the voltage in millivolts.
bidrohini.bidrohini