IND.I/O D21G: incorrect analog reading immediately after changing input channel. Is there another solution?
IND.I/O D21G: incorrect analog reading immediately after changing input channel
I have found a reproducible issue when reading different analog input channels sequentially on an IND.I/O D21G using Indio.analogRead().
I investigated this with assistance from ChatGPT (OpenAI, GPT-5.6 Sol), which helped with the diagnostic sketches and examination of the Indio library behaviour.
Test
The analog inputs were configured for 0–10 V at 14-bit resolution. Approximately 8.25 V was applied only to physical CH4, with the other channels at approximately 0 V.
When CH4 was read repeatedly without changing channels:
Indio.analogRead(4);
the result was correct and stable:
CH4 = 8.249 V CH4 = 8.249 V CH4 = 8.249 V
Likewise, reading CH1 alone gave approximately zero:
CH1 = 0.042 V CH1 = 0.042 V CH1 = 0.042 V
This confirms that the physical input labelling is correct: physical CH4 is software CH4.
However, when CH1–CH4 were read sequentially, the voltage applied to CH4 appeared on CH1:
CH1 = 8.269 V CH2 = 0.045 V CH3 = 0.040 V CH4 = 0.025 V
Adding 500 ms between each channel read made no difference; the same result occurred.
Workaround
I then tried discarding readings after selecting each channel:
float readAnalogReliable(int channel) { Indio.analogRead(channel); // discard Indio.analogRead(channel); // discard return Indio.analogRead(channel); }
For my application I only need CH1 and CH4, so I tested:
float ch1 = readAnalogReliable(1); float ch4 = readAnalogReliable(4);
with the measurements repeated every 10 seconds.
The result was then correct and completely stable:
CH1 = 0.007 V CH4 = 8.254 V CH1 = 0.007 V CH4 = 8.254 V CH1 = 0.007 V CH4 = 8.254 V CH1 = 0.007 V CH4 = 8.254 V
Possible cause
Looking at the Indio library with ChatGPT, this appears consistent with the MCP3424 returning conversion data associated with the previously selected channel when analogRead() changes ADC channels.
This would explain why:
-
repeatedly reading one channel works correctly;
-
the problem occurs when changing channels;
-
waiting 500 ms *before the next analogRead() does not help, because the ADC channel has not yet been changed;
-
discarding conversions after changing the channel fixes the problem.
However, I have not established that this is definitely the internal cause, so I would appreciate confirmation from Industruino.
Is this a known behaviour/issue with Indio.analogRead() when switching MCP3424 channels?
If so, is there a recommended method for reliably reading multiple analog channels, or should the library wait for/verify a completed conversion from the newly selected channel before returning the value?
For my application the workaround is acceptable because I only read CH1 and CH4 once every 10 seconds, but it could be more significant for applications scanning several analog inputs quickly.
Thanks to ChatGPT by OpenAI (GPT-5.6 Sol) for assistance with the diagnostic tests and analysis.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
| Asked: 9/22/26, 6:48 AM |
| Seen: 3 times |
| Last updated: 9/22/26, 6:48 AM |