NodeMCU ESP 8266 with OLED
Arduino code
#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)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup()
{
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
// Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
// Display static text
display.println("Hello, world!");
display.display();
}
void loop()
{
}
### Add image to display code
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
static const uint8_t image_data_Saraarray[1024] = {
0xff, 0xff, 0xf8, 0x24, 0x82, 0x10, 0x88, 0x00, 0x00, 0x00, 0x0f, 0xaf, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf2, 0x95, 0x14, 0x8a, 0x42, 0x14, 0x01, 0x12, 0x8f, 0x97, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x48, 0x82, 0x51, 0x20, 0x40, 0x20, 0x40, 0x1d, 0xcf, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf2, 0x25, 0x14, 0x28, 0x88, 0x01, 0x00, 0x0a, 0x5f, 0x57, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf9, 0x4a, 0x82, 0x8a, 0x01, 0x00, 0x00, 0x20, 0x37, 0x57, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x90, 0x29, 0x54, 0x54, 0x20, 0x02, 0x02, 0x1d, 0x4f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf2, 0x4a, 0x94, 0x40, 0x01, 0x04, 0x00, 0x00, 0xbb, 0x57, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf9, 0x25, 0x02, 0xa9, 0x50, 0x00, 0x90, 0x08, 0x1f, 0xaf, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x94, 0x54, 0x01, 0x00, 0x40, 0x42, 0x40, 0x36, 0x87, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x49, 0x12, 0x90, 0x01, 0x0a, 0x88, 0x01, 0x3f, 0x5f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0xaa, 0x89, 0x05, 0x00, 0x21, 0x20, 0x00, 0x2b, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x04, 0x2a, 0x45, 0x49, 0x15, 0x48, 0x20, 0x3f, 0x57, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xa9, 0x11, 0x0b, 0x4a, 0xd5, 0x50, 0x00, 0x3b, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x08, 0x88, 0xaf, 0xad, 0x55, 0x40, 0x02, 0x3e, 0x2f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf2, 0xa5, 0x24, 0x4b, 0xf6, 0xdb, 0x59, 0x00, 0x2e, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x14, 0x12, 0x8f, 0xdb, 0x6d, 0x54, 0x00, 0x16, 0x5f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xa2, 0x88, 0x2f, 0xfd, 0xb5, 0xa0, 0x08, 0x01, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x94, 0x25, 0x4d, 0xf6, 0xda, 0xac, 0x80, 0x84, 0x4f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x49, 0x11, 0x17, 0xbb, 0x6d, 0x52, 0x00, 0x20, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf1, 0x10, 0x88, 0x8e, 0xdd, 0xaa, 0xa8, 0x00, 0x30, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x04, 0x25, 0x1b, 0xea, 0xb5, 0x54, 0x41, 0x9c, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf9, 0x25, 0x10, 0x8e, 0xad, 0x56, 0xaa, 0x08, 0x5c, 0x17, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf4, 0x08, 0x4a, 0x4b, 0xb5, 0xab, 0x54, 0x00, 0x29, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf9, 0x51, 0x10, 0xce, 0xd5, 0x5a, 0xaa, 0x04, 0x10, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x28, 0x25, 0x97, 0xaa, 0xaa, 0xd5, 0x1a, 0x82, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xa5, 0x0b, 0x3d, 0x2a, 0x81, 0x2a, 0x11, 0x08, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0xc8, 0x53, 0x14, 0x25, 0x50, 0x95, 0x24, 0x01, 0x47, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe2, 0x06, 0x38, 0x95, 0x06, 0x2a, 0x15, 0x24, 0x17, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0x78, 0x9c, 0x68, 0x45, 0x42, 0xaa, 0x8a, 0x00, 0x4f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfd, 0xbd, 0x08, 0xee, 0xab, 0x6a, 0xd5, 0x45, 0x04, 0x2f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x16, 0xf8, 0xaf, 0x57, 0xaa, 0xaa, 0xb4, 0x20, 0x87, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfe, 0x8a, 0xa1, 0x9d, 0x5e, 0xaa, 0xda, 0x95, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x53, 0x63, 0x57, 0xef, 0x5b, 0x6a, 0x68, 0x24, 0x97, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xeb, 0xa3, 0xaf, 0xfe, 0xad, 0xa9, 0x55, 0x10, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x5b, 0x47, 0x5f, 0x9b, 0x56, 0xd5, 0x58, 0x00, 0xa7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x6d, 0xce, 0xbe, 0xda, 0x55, 0x6a, 0xa2, 0x48, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xd6, 0x86, 0xed, 0x51, 0x53, 0x54, 0x50, 0x01, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0x7a, 0x9e, 0xbb, 0xdd, 0xf4, 0xaa, 0x0a, 0x44, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfd, 0xdb, 0x7d, 0xfd, 0x7a, 0xea, 0xa9, 0x20, 0x00, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x6d, 0xe7, 0x6f, 0xae, 0x3a, 0xa4, 0x44, 0x90, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfd, 0xbe, 0xb4, 0xea, 0xbf, 0xa9, 0x54, 0x10, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0x6b, 0xff, 0xbd, 0x77, 0x54, 0x51, 0x45, 0x09, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfe, 0xaf, 0xff, 0xaa, 0xdd, 0xda, 0x94, 0x00, 0x40, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xaf, 0xea, 0xbb, 0xe5, 0x6a, 0x40, 0x95, 0x01, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xde, 0xaa, 0x55, 0xf2, 0xaa, 0x28, 0x00, 0x20, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf3, 0x5d, 0x51, 0x5a, 0xf9, 0x55, 0x40, 0xaa, 0x02, 0x4f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x7f, 0xd0, 0xaf, 0x5e, 0xaa, 0x00, 0x00, 0x40, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x3d, 0xa4, 0xb5, 0xd5, 0xaa, 0x02, 0x02, 0x09, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfd, 0xba, 0x82, 0x4d, 0xd6, 0xaa, 0x80, 0x00, 0x20, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x76, 0x14, 0x29, 0x6a, 0xd5, 0x00, 0x21, 0x02, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0xe9, 0x42, 0x24, 0x52, 0xaa, 0x84, 0x00, 0x00, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x34, 0x28, 0x10, 0x5d, 0x55, 0x40, 0x04, 0x20, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0x52, 0x90, 0x0a, 0x2a, 0xaa, 0x80, 0x20, 0x02, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0x6a, 0x48, 0x21, 0x15, 0x5a, 0xa0, 0x80, 0x00, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf4, 0x55, 0x50, 0x04, 0x85, 0x6a, 0xa0, 0x00, 0x88, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf8, 0xea, 0x20, 0x40, 0x55, 0xad, 0x50, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf1, 0xea, 0x80, 0x12, 0x02, 0xb5, 0xa8, 0x02, 0x00, 0xa7, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfb, 0xea, 0x88, 0x40, 0x82, 0xaa, 0xa8, 0x40, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf3, 0xda, 0x00, 0x04, 0x11, 0x56, 0xd4, 0x00, 0x02, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xa9, 0x00, 0x82, 0x00, 0xab, 0x6e, 0x08, 0x10, 0x27, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xd4, 0x10, 0x10, 0x40, 0x5a, 0xb5, 0x00, 0x00, 0x8f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x54, 0x01, 0x04, 0x00, 0x15, 0xab, 0x00, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfe, 0xb4, 0x40, 0x10, 0x00, 0x0a, 0xdd, 0x40, 0x04, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x54, 0x02, 0x00, 0x00, 0x46, 0xaa, 0x88, 0x00, 0x4f, 0xff, 0xff, 0xff, 0xff
};
void setup()
{
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000); // Pause for 2 seconds
// Clear the buffer.
display.clearDisplay();
// Draw bitmap on the screen
display.drawBitmap(0, 0, image_data_Saraarray, 128, 64, 1);
display.display();
}
void loop()
{
}