user85208: 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;
    
}


user38721: The MAX1161x are 12-bit ADCs, so the problem is not related to an uint16 overflow as you seem to assume.
The ADC transmits most significant bits (MSB) first as can be seen in figure 10 on page 17. To account for that you need to change
value =  Wire.read();
value |= Wire.read() << 8;

to
value = Wire.read() << 8;
value |=  Wire.read();


85208: <p>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 <strong>from about 0 to 65535 multiple times</strong> (over 10 cycles).</p>
<p>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.</p>
<p><strong>Hardware:</strong></p>
<p><strong>Board:</strong> ESP32
<strong>ADC:</strong> MAX11613 (12 bit adc)
<a href="https://www.mouser.de/datasheet/2/256/MAX11612-MAX11617-1508955.pdf" rel="nofollow noreferrer">https://www.mouser.de/datasheet/2/256/MAX11612-MAX11617-1508955.pdf</a>
<strong>Potentiometer:</strong> 3046L - 3 - 203 <a href="https://www.mouser.de/datasheet/2/54/3046-776396.pdf" rel="nofollow noreferrer">https://www.mouser.de/datasheet/2/54/3046-776396.pdf</a></p>
<p>Part of the code that reads the adc values:</p>
<pre><code>uint8_t MAX11613::MAX11613_ADC_Read(structMAX11613* chip, uint8_t channel, uint16_t* val){
    
    uint8_t configurationByte = ( (channel&lt;&lt;1) &amp; 0x0e) | 0x61;
    MAX11613_Configuration(chip, configurationByte);

    Wire.beginTransmission(chip-&gt;devAddress);
    Wire.requestFrom(chip-&gt;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() &lt;&lt; 8;

    //This also works:
    /*uint32_t buf1;
    size_t actually_read = Wire.readBytes((uint8_t*)&amp;buf1, 2);
    *val = actually_read;
    //Serial.println(value);*/

    *val = value;
    }
    if (Wire.endTransmission() != 0){
    return 1;
    }
    return 0;
    
}
</code></pre>
 38721: <p>The MAX1161x are 12-bit ADCs, so the problem is not related to an uint16 overflow as you seem to assume.
The ADC transmits most significant bits (MSB) first as can be seen <a href="https://www.mouser.de/datasheet/2/256/MAX11612-MAX11617-1508955.pdf" rel="nofollow noreferrer">in figure 10 on page 17</a>. To account for that you need to change</p>
<pre><code>value =  Wire.read();
value |= Wire.read() &lt;&lt; 8;
</code></pre>
<p>to</p>
<pre><code>value = Wire.read() &lt;&lt; 8;
value |=  Wire.read();
</code></pre>
