Differences between ADC straight pin read() and sampler samples


I have an analogue pin which if I do a direct read(); on I get a value of 323, however if I use a sampler:

function samplesReady(buffer, length) {
    if (length > 0) {
        for (local i = 0; i < 50; ++i) {
            local rawSample = buffer.readn('w');
    else {
        // Overrun

hardware.sampler.configure(hardware.pinH, 50, [_buffer1, _buffer2], samplesReady);

I get a value of 208, which is around 115 lower.

Is there a reason for this inconsistency?


What’s the circuit attached? There’s “charge injection” where sampling an input pulls some current for every sample, as the cap internal to the chip is charged for sampling. The more you sample, the lower the value will be if your input is high impedance.

One way to address this is to put a capacitor (eg 100nF) on the ADC input to supply these current pulses, but it depends on what you’re feeding into the device… hence the first question.


It’s connected to an Operational Amplifier.

Fair enough, was just wondering. Thanks


Would like to solve the issue though; an opamp should be able to deal with the current flowing into the ADC. Can you try adding 100nF at the pin input?