Problems with O2 sensor and OLED display over IIC..

so starting in the traditional manner - I'm new to coding in general, and until this weekend hadn't written a line of code for Arduino...

What I have done now, however is hook up an O2 sensor via an ADS1115 and display the readings on a LED display

the O2 sensor essentially works by O2 reacting with the chemicals inside the sensor to produce a very small current in 21% O2, this is circa 10mV - and this increases linearly as the O2 being sampled increases - so you can calculate the oxygen content of an any gas sample.

All this works perfectly when I'm using the LED or serial display - but as soon as I hook up the OLED to the same pins - the sensor reading displays as 0mV

Where should I start to try and resolve this?



bit of extra info…

it looks like it could be something to do with this bit of code:

while (millis() < 5000) {
sensorValue = ads.readADC_Differential_0_1();

// record the maximum sensor value
if (sensorValue > sensorMax) {
sensorMax = sensorValue;

// record the minimum sensor value
if (sensorValue < sensorMin) {
sensorMin = sensorValue;

This is within void setup() { and should average out the readings over 5000ms to give a stable start reading.

I’ve tried a few other ways of smoothing the readings - all of which cause the same 0.00 mV reading…

If I comment out that bit of code, and replace it with a single reading, it works



it looks like it could be something to do with this bit of code:

Why don’t you post complete code? And don’t forget to use code tags (that’s the </> button in the editor)!