I have the problem, that the potentiometer goes from the range of 0 Volts to 3,3 volts. But within this range the measured value goes from about 0 to 65535 multiple times (over 10 cycles).
When I change the code from my ADC library to 32 bit I get 32 bit values (0 - 4294967296) but the same error with the beginning at 0 multiple times within the potentiometer range occurs.
Hardware:
Board: ESP32 ADC: MAX11613 (12 bit adc) https://www.mouser.de/datasheet/2/256/MAX11612-MAX11617-1508955.pdf Potentiometer: 3046L - 3 - 203 https://www.mouser.de/datasheet/2/54/3046-776396.pdf
Part of the code that reads the adc values:
uint8_t MAX11613::MAX11613_ADC_Read(structMAX11613* chip, uint8_t channel, uint16_t* val){
uint8_t configurationByte = ( (channel<<1) & 0x0e) | 0x61;
MAX11613_Configuration(chip, configurationByte);
Wire.beginTransmission(chip->devAddress);
Wire.requestFrom(chip->devAddress, (byte) 2); // request 2 bytes from slave device wireIface
while (Wire.available()) { // slave may send less than requested
//char c = Wire.read(); // receive a byte as character
uint16_t value = 0;
value = Wire.read();
value |= Wire.read() << 8;
//This also works:
/*uint32_t buf1;
size_t actually_read = Wire.readBytes((uint8_t*)&buf1, 2);
*val = actually_read;
//Serial.println(value);*/
*val = value;
}
if (Wire.endTransmission() != 0){
return 1;
}
return 0;
}