UNO + OLED 0.91 can't clear display

Hi
I'm building an incubator following this github.

However When I'm trying to compile everything, the oled 0.91 with Uno R3 didn't clear the display and stills on the first picture on bitmap.

Any ideas?

//    FILE: Nitrogen Calibration_Meatcubator
//  AUTHOR: Jonah Hoppenheim & Thethoughtemporium on youtube
// PURPOSE: C02 incubator
//     URL: https://www.youtube.com/@thethoughtemporium
#include <OneButton.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <EEPROM.h>
#include "Arduino.h"
#include "cozir.h"
#include "SoftwareSerial.h"
#define SCREEN_WIDTH 128     // OLED display width, in pixels
#define SCREEN_HEIGHT 32     // OLED display height, in pixels
#define OLED_RESET -1        // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C  ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
#define BUTTON_PIN 8
OneButton btn = OneButton(
  BUTTON_PIN,  // Input pin for the button
  true,        // Button is active LOW
  true         // Enable internal pull-up resistor
);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
unsigned long previousMillis = 0;  // will store last time the value was opened
int interval = 5000;               //How long between C02 level checks for basic control
int CO2InitialCalibrationAvg = 0;
int Relay = 7;
OneButton button(8, true);
SoftwareSerial nss(3, 4);  // RX, TX, optional inverse logic
COZIR czr(&nss);

// 'TheThought Emporium(2)', 128x32px
const unsigned char epd_bitmap_TheThought_Emporium_2_[] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xfb, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xfb, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfc, 0xfb, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfc, 0xfb, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfe, 0xfb, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfe, 0x7b, 0x1d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfe, 0x73, 0x1d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x73, 0x39, 0xc1, 0x3f, 0xe0, 0xbf, 0xff, 0xfe, 0x7f, 0x87, 0xff, 0xff, 0xfd, 0xff, 0xff,
  0xff, 0x33, 0x39, 0xc1, 0x3f, 0xe0, 0xbf, 0xff, 0xfe, 0x79, 0x87, 0xff, 0xff, 0xfd, 0xff, 0xff,
  0xff, 0x3b, 0x33, 0xf3, 0x3f, 0xf3, 0xbf, 0xff, 0xfe, 0x79, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xe3, 0x23, 0xf3, 0x0e, 0x73, 0x86, 0x34, 0xc2, 0x10, 0x9c, 0x24, 0x38, 0xc5, 0xa4, 0x27,
  0xff, 0x82, 0x27, 0xf3, 0x04, 0x33, 0x84, 0x34, 0x82, 0x18, 0x9c, 0x04, 0x10, 0x85, 0xa4, 0x07,
  0xff, 0x82, 0x07, 0xf3, 0x25, 0xb3, 0xa4, 0xb4, 0x96, 0x59, 0x8c, 0xb4, 0x92, 0x9d, 0xa4, 0x97,
  0x9f, 0x82, 0x0f, 0xf3, 0x24, 0x33, 0xa4, 0xb4, 0x96, 0x59, 0x8c, 0xb4, 0x96, 0x9d, 0xa4, 0x97,
  0xdf, 0x02, 0x0f, 0xf3, 0x24, 0x33, 0xa4, 0xb4, 0x96, 0x59, 0x9c, 0xb4, 0x96, 0x9d, 0xa4, 0x97,
  0xe7, 0x02, 0x0f, 0xf3, 0x25, 0xf3, 0xa4, 0xb4, 0x86, 0x59, 0x9c, 0xb4, 0x96, 0x9d, 0xa4, 0x97,
  0xf3, 0x06, 0x0f, 0xf3, 0x25, 0xb3, 0xa4, 0xb4, 0xc6, 0x59, 0x9c, 0xb4, 0x92, 0x9d, 0xa4, 0x97,
  0xf9, 0x04, 0x0f, 0xf3, 0x24, 0x33, 0xa4, 0xb0, 0x9e, 0x59, 0x84, 0xb4, 0x90, 0x9d, 0x84, 0x97,
  0xf9, 0x04, 0x0f, 0xf3, 0x24, 0x33, 0xa6, 0x30, 0x86, 0x5c, 0x84, 0xb4, 0x10, 0x9d, 0x84, 0x97,
  0xfc, 0x0c, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x08, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x18, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x30, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x80, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};

// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 528)
const int epd_bitmap_allArray_LEN = 1;
const unsigned char* epd_bitmap_allArray[1] = {
  epd_bitmap_TheThought_Emporium_2_
};

void setup() {

  nss.begin(9600);
  czr.setOperatingMode(CZR_POLLING);
  pinMode(Relay, OUTPUT);
  pinMode(6, INPUT);
  int c = czr.CO2();
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
  display.clearDisplay();
  display.drawBitmap(0, 0, epd_bitmap_TheThought_Emporium_2_, 128, 32, INVERSE);
  display.display();
  delay(2500);
  display.clearDisplay();
}


void loop() {
  int c = czr.CO2();
  czr.calibrateNitrogen();
  ScreenConfigtextco2(2, 2000, "Calibrat..", c / 1000, "%");
}


void delaydisplay(float delaytotal) {
  float c = czr.CO2();
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
  ScreenConfigtextco2nodelay(2, 1, "Wait ", delaytotal * 0.001, 's', c / 1000, "%");
  delay(delaytotal / 20);
}

Zeroes out the display buffer.

Transfers the display buffer to the display.

void setup() {

  nss.begin(9600);
  czr.setOperatingMode(CZR_POLLING);
  pinMode(Relay, OUTPUT);
  pinMode(6, INPUT);
  int c = czr.CO2();
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
  display.clearDisplay();
  display.drawBitmap(0, 0, epd_bitmap_TheThought_Emporium_2_, 128, 32, INVERSE);
  display.display();
  delay(2500);
  display.clearDisplay();
  display.display(); // <===== ADD THIS LINE
}

What are you expecting to be on the screen after the first bitmap ?

What does the ScreenConfigtextco2nodelay() do ?

Hi it's the logo of the "company". refers i think to the other code

OK, but what are you expecting to see on teh display after the initial bitmap has been cleared ?

the datas from the cO2 sensor

Where did you get the code from ?

Click on github on the 1st post

Have you added this line to setup() ?

  display.display(); // <===== ADD THIS LINE

That should cause the screen to clear and the loop() function will run

However, there is no code in the loop() function to display the CO2 values as the delaydisplay() function is never called

It's because it's inside another window.(look to the link) i opened all the windows together

What is inside another window ?

Do you mean that there are multiple tabs open in the IDE, each holding code ? That would make good sense, but the loop() function would still not call the delaydisplay() function

Where in your code, in the main .ino file or in a file on another tab, is the code to display the CO2 values and how is it called ?

You have not answered whether you have added the line of code to clear the screen in setup()

Not yet for the code.

The code for co2 is inside "valve"

The code may be there but where in your sketch is it called from ?

Hum i supposed in loop

void loop()
{
    int c = czr.CO2();
    czr.calibrateNitrogen();
    ScreenConfigtextco2(2, 2000, "Calibrat..", c / 1000, "%");
}

I am afraid not

It looks like there ought to be a call to delaydisplay() in loop() but that function looks nonsense too. It reads the CO2 value once then displays the same value about 20 times

What is that all about ?

It supposed to activate the valve if co2 is to much. (5% inside)

Did you write this sketch ?
If not, then where did you get it from ?

Why would the delaydisplay() function do exactly the same thing 20 times using the same CO2 value ?

No i said. Go to my 1st post and click on "github". It's a tutorial i followed

Sorry, but I can't see a link to a tutorial on that GitHub page. Maybe I missed it

I see an image of a "Meatcubator", a parts list and a sentence saying "See full build video here:" but no actual link and the word "tutorial" is not on that page

Please post the link to the tutorial that you are following

Hi, @al64

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Can you post some images of your project?
So we can see your component layout.

You may not have communications with the OLED.
Is you OLED 182x32 or 128 x 64?

Have you tried some example codes that come with the <Adafruit_SSD1306.h> library?

That would be a very good place to start and learn how to program the display.

Tom.... :smiley: :+1: :coffee: :australia: