ZenoModiff
Published © Apache-2.0

Smart Easter Egg with ESP32

This Easter egg isn’t filled with candy — it hides an ESP32-powered electronic surprise with animations, making it a fun festive tech build.

IntermediateFull instructions provided1 hour222
Smart Easter Egg with ESP32

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Stl File

Schematics

Schematics

Code

Smart Easter EGG

C/C++
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

// --- CONFIGURATION ---
const char* ssid     = "Zeno-Modiff";
const char* password = "Crack_it@990";

// Target: April 5, 2026, 00:00:00 (Easter Sunday)
const long targetEpoch = 1775413800; 
const long utcOffset   = 19800; // IST (UTC +5:30)

U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffset);

// --- 32x32 BOOT ICON ---
static const unsigned char big_egg_32x32[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 
  0x00, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x01, 
  0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x03, 
  0xe0, 0x0f, 0xf0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xf0, 0x67, 0xe6, 0x0f, 
  0xf0, 0xf3, 0xcf, 0x0f, 0xf0, 0xf3, 0xcf, 0x0f, 0xf0, 0x67, 0xe6, 0x0f, 
  0xf0, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x0f, 
  0xf0, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07, 
  0xe0, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x03, 
  0x80, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfc, 0x3f, 0x00, 
  0x00, 0xf0, 0x0f, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
};

void showBootIcon() {
  float y = 0; float velocity = 0; float gravity = 0.4; float bounce = -0.7;
  int groundLevel = 32;
  unsigned long startTime = millis();
  while (millis() - startTime < 4000) {
    u8g2.clearBuffer();
    velocity += gravity; y += velocity;
    if (y > groundLevel) { y = groundLevel; velocity *= bounce; }
    u8g2.drawXBM(48, (int)y, 32, 32, big_egg_32x32);
    u8g2.sendBuffer();
    delay(10); 
  }
}

void setup() {
  u8g2.begin();
  showBootIcon();

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    u8g2.clearBuffer();
    u8g2.drawXBM(48, 16, 32, 32, big_egg_32x32); // Static egg while connecting
    u8g2.sendBuffer();
    delay(500);
  }
  timeClient.begin();
}

void loop() {
  timeClient.update();
  unsigned long currentEpoch = timeClient.getEpochTime();
  u8g2.clearBuffer();

  if (targetEpoch > currentEpoch) {
    unsigned long diff = targetEpoch - currentEpoch;
    
    int days = diff / 86400;
    int hours = (diff % 86400) / 3600;
    int mins = (diff % 3600) / 60;
    int secs = diff % 60;

    char dayStr[15];
    char timeStr[15];
    sprintf(dayStr, "%d DAYS", days);
    sprintf(timeStr, "%02d:%02d:%02d", hours, mins, secs);

    // --- LINE 1: Header ---
    u8g2.setFont(u8g2_font_6x12_tr);
    u8g2.drawStr(36, 12, "EASTER IN");

    // --- LINE 2: Days ---
    u8g2.setFont(u8g2_font_logisoso18_tr);
    u8g2.drawStr(25, 40, dayStr);

    // --- LINE 3: Time + Small "Hrs" ---
    u8g2.setFont(u8g2_font_7x14_tr);
    u8g2.drawStr(30, 62, timeStr); 

    u8g2.setFont(u8g2_font_5x7_tr);
    u8g2.drawStr(90, 62, "Hrs"); 

  } else {
    u8g2.setFont(u8g2_font_logisoso18_tr);
    u8g2.drawStr(10, 42, "HAPPY EASTER!");
  }

  u8g2.sendBuffer();
  delay(1000); 
}

Credits

ZenoModiff
18 projects • 10 followers

Comments