Display Serial output from sketch on OLED display 0.96" Inch Yellow Blue White

FYI this is my first project…

I have a sparkfun red board and a keysestudio TDS sensor.
I have run the sketch from keys and get the correct serial output in “Serial Monitor”
Now I would Like to hook up my “OLED display 0.96” Inch Yellow Blue White "
LINK: https://www.amazon.com/gp/product/B07D4DMDF4/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

To read the serial output. Can someone tell me where to start LOL???

I assume from reading I need to define some stuff for this OLED to work for serial output. This is where im stuck.

I also would like to slow down the scrolling of the TDS reading significantly like to every 10 seconds.
The main goal is to run this on my HELTEC ESP32 wifi dev board and send TDS to its screen and wirelessly to my phone using blynk

Here is my sketch: If you modify can you please use BOLD type

#define TdsSensorPin A1
#define VREF 5.0 // analog reference voltage(Volt) of the ADC
#define SCOUNT 30 // sum of sample point
int analogBuffer[SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0,copyIndex = 0;
float averageVoltage = 0,tdsValue = 0,temperature = 25;
void setup()
void loop()
static unsigned long analogSampleTimepoint = millis();
if(millis()-analogSampleTimepoint > 40U) //every 40 milliseconds,read the analog value from the ADC
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin); //read the analog value and store into the buffer
if(analogBufferIndex == SCOUNT)
analogBufferIndex = 0;
static unsigned long printTimepoint = millis();
if(millis()-printTimepoint > 800U)
printTimepoint = millis();
analogBufferTemp[copyIndex]= analogBuffer[copyIndex];
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF/ 1024.0; // read the analog value more stable by the median filtering algorithm, and convert to voltage value
float compensationCoefficient=1.0+0.02*(temperature-25.0); //temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(fTP-25.0));
float compensationVolatge=averageVoltage/compensationCoefficient; //temperature compensation
tdsValue=(133.42compensationVolatgecompensationVolatgecompensationVolatge - 255.86compensationVolatgecompensationVolatge + 857.39compensationVolatge)0.5; //convert voltage value to tds value
//Serial.print("V ");
Serial.print(“TDS Value:”);
int getMedianNum(int bArray[], int iFilterLen)
int bTab[iFilterLen];
for (byte i = 0; i<iFilterLen; i++)
bTab _= bArray
int i, j, bTemp;
for (j = 0; j < iFilterLen - 1; j++)
for (i = 0; i < iFilterLen - j - 1; i++)
if (bTab > bTab[i + 1])
_bTemp = bTab;
bTab = bTab[i + 1];
bTab[i + 1] = bTemp;
if ((iFilterLen & 1) > 0)
bTemp = bTab[(iFilterLen - 1) / 2];
bTemp = (bTab[iFilterLen / 2] + bTab[iFilterLen / 2 - 1]) / 2;
return bTemp;

I assume if I change this the scroll will slow down.... if(millis()-analogSampleTimepoint > 40U)

For a start find the correct library for that display and get the display to work on its own using the examples from the library. Once you do that you should have a better understanding of how the display works and how to integrate it into your code.

I assume if I change this the scroll will slow down.... if(millis()-analogSampleTimepoint > 40U)

Right, a larger number will slow the scroll.

Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Thanks a bunch for the starter points … will research and post back