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);
}