#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO: A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
// On an arduino ESP32-S2-MINI1: 8(SDA), 9(SCL), ...
#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
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(115200);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
/* for (int i = 4000; i < 10000; i++) {
big_n(String(i));
} */
logo();
delay(1000); // Pause for 2 seconds
}
void loop() {}
void logo()
{
const unsigned char logo [] PROGMEM = {
// 'telemuxa', 128x64px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xe7, 0xf0, 0x7f, 0x1f, 0xcf, 0x07, 0xb8, 0x3f, 0x0e, 0x0e, 0x00, 0x01, 0xdd, 0xd4, 0x00,
0x3f, 0xe7, 0xf0, 0xff, 0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00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x11, 0x8c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00,
0x38, 0x84, 0x70, 0xf2, 0x33, 0xc7, 0x3e, 0x3c, 0x5c, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x04, 0x84, 0x08, 0x92, 0x32, 0x20, 0x88, 0x66, 0x66, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x04, 0x84, 0x08, 0x92, 0x50, 0x20, 0x88, 0x42, 0x42, 0x04, 0x02, 0x02, 0x3c, 0x00, 0x00, 0x00,
0x3c, 0xfc, 0x78, 0x92, 0xd1, 0xc7, 0x88, 0x42, 0x42, 0x04, 0x02, 0x02, 0x46, 0x00, 0x00, 0x00,
0x44, 0x84, 0x89, 0x92, 0x90, 0x28, 0x88, 0x42, 0x42, 0x06, 0x03, 0x04, 0x02, 0x00, 0x00, 0x00,
0x44, 0x84, 0x89, 0x13, 0x12, 0x28, 0x88, 0x66, 0x66, 0x03, 0x11, 0x8c, 0x02, 0x00, 0x00, 0x00,
0x3c, 0x84, 0x7b, 0x12, 0x13, 0xc7, 0x88, 0x3c, 0x5c, 0x01, 0xe0, 0xf8, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x87, 0x18, 0x30, 0x00, 0x43, 0x80, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00,
0x00, 0x00, 0x02, 0x45, 0xa4, 0x30, 0x01, 0xc2, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00,
0x00, 0x00, 0x00, 0x48, 0x84, 0x50, 0x00, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x48, 0x84, 0x50, 0x00, 0x44, 0x42, 0x47, 0x9c, 0x38, 0xe0, 0x8a, 0x00, 0x00,
0x00, 0x00, 0x00, 0x88, 0x88, 0x90, 0x00, 0x44, 0x42, 0x84, 0x82, 0x41, 0x00, 0x92, 0x00, 0x00,
0x00, 0x00, 0x01, 0x88, 0x99, 0x10, 0x00, 0x44, 0x43, 0x04, 0x8e, 0x41, 0x00, 0xa2, 0x00, 0x00,
0x00, 0x00, 0x01, 0x08, 0x91, 0xf8, 0x00, 0x44, 0x43, 0x04, 0x92, 0x41, 0x00, 0xa2, 0x00, 0x00,
0x00, 0x00, 0x02, 0x0d, 0x20, 0x10, 0x00, 0x46, 0x82, 0x88, 0x92, 0x41, 0x00, 0xc2, 0x00, 0x00,
0x00, 0x00, 0x03, 0xc7, 0x3c, 0x10, 0x00, 0x43, 0x82, 0x50, 0x8e, 0x38, 0xe0, 0xc2, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
display.clearDisplay();
display.drawBitmap(0, 0, logo, 32, 13, WHITE);
display.display();
}
String big_n (String text)
{
display.clearDisplay();
display.setTextSize(5); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(5, 10); // Start at top-left corner
display.println(text);
display.setTextSize(2);
display.setCursor(23, 48);
display.println("ppm CO2");
display.display();
}
String prn (String text)
{
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.println(text);
display.display();
}