Color E-Ink Dashboard – ESP32 Project
This project features a colorful dashboard powered by an ESP32 and a color E-Ink display.
It was developed using the R1BBIT cloud platform, making it easy for beginners, even without prior programming experience, to build and run their own projects.
The complete project script is available in the R1BBIT template library. Simply download it to your device and run it.
Want to customize the dashboard or add new features? The built-in AI assistant can help you modify the code and adapt the interface to your needs.
CONFIG
// ==========================================================
// Display Configuration
// 800x480 Spectra 6-Color E-Paper (native landscape).
// Portrait rotation is applied at runtime - see ROT below
// ==========================================================
DISPLAY_DRIVER SPECTRA6
DISPLAY_BUS SPI
SPI_MOSI 11
SPI_CLK 10
DISPLAY_CS 9
DISPLAY_DC 8
DISPLAY_RST 12
DISPLAY_BUSY 13
DISPLAY_PWR 6
SPI_FREQ 10000000
DISPLAY_W 800
DISPLAY_H 480
DISPLAY_ROTATION 0
// ==========================================================
// I2C Bus
// ==========================================================
I2C_SDA 47
I2C_SCL 48
I2C_FREQ 400000
// ==========================================================
// Power Management IC
// ==========================================================
PMIC AXP2101
// ==========================================================
// Audio Codec Configuration
// ==========================================================
CODEC ES8311
CODEC_I2C 0
CODEC_ADDR 0x18
CODEC_PA_PIN 7
CODEC_PA_ACTIVE_LOW 0
// ==========================================================
// I2S Audio Bus
// ==========================================================
I2S_MCLK 14
I2S_BCLK 15
I2S_WS 16
I2S_DOUT 17
I2S_DIN 18
AUDIO_OUT CODEC
AUDIO_IN CODEC
MIC_GAIN 30
// ==========================================================
// Imperial units + time zone (US Eastern)
// ==========================================================
UNITS IMPERIAL
TIMEZONE "EST5EDT,M3.2.0,M11.1.0"
END_CONFIG
// ==========================================================
// USER SETTINGS — edit this block to personalize the dashboard.
// Names, location, news feed, screen timing, rotation and calendar
// marker position are configured here. The rest of the script can
// normally remain unchanged.
// ==========================================================
CONST NAME1 = "Emily Johnson"
CONST NAME2 = "Michael Carter"
CONST PET_NAME = "Leo"
CONST CITY = "New York"
CONST LAT = "40.71"
CONST LON = "-74.01"
CONST NEWS_URL = "https://feeds.bbci.co.uk/news/world/rss.xml"
CONST SCREEN_SEC = 20 // seconds each screen stays on
CONST ROT = 90 // portrait: 90 or 270 (if upside down)
CONST MK_DY = 5 // date squares: center = text top + MK_DY (bigger = lower squares)
// Spectra 6 palette — use only the six colors supported by the panel.
// Avoid intermediate RGB colors because the display cannot reproduce them directly.
CONST C_BLK = 0x000000
CONST C_WHT = 0xFFFFFF
CONST C_RED = 0xFF0000
CONST C_YEL = 0xFFFF00
CONST C_GRN = 0x00FF00
CONST C_BLU = 0x0000FF
// ----- Calendar events -----
// EVN is the number of active events. The arrays store each event's
// month, day, marker style and marker color. Update all four arrays together.
// EV_S: 2 = filled square (1 = ring, 3 = filled circle)
// NAME1 birthday date was not given - set to 5, change it
VAR EVN = 4
VAR EV_M[8] = {11, 11, 11, 11}
VAR EV_D[8] = {5, 10, 18, 26}
VAR EV_S[8] = {2, 2, 2, 2}
VAR EV_C[8] = {0x0000FF, 0xFF0000, 0xFFFF00, 0xFF0000}
// ----- To-do notes -----
// A month or day value of 0 makes the note recurring. NOTE_X marks
// completed items (1 = checked, 0 = still pending).
// Note texts are in the NoteText subroutine below
// NOTE_X: 1 = done (checked)
VAR NN = 11
VAR NOTE_M[16] = {0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11}
VAR NOTE_D[16] = {0, 0, 0, 9, 9, 9, 10, 10, 10, 10, 10}
VAR NOTE_X[16] = {1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0}
// ==========================================================
// Global variables
// These variables are shared by the display pages and helper routines.
// Arrays MD, QP and QO hold month lengths and market quote data.
// ==========================================================
VAR MD[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
VAR scr = 1
VAR i, k, t, e, d, a, x, y, ry, cnt, ok1, ok2, ne, dd, ed, dgx
VAR today, curM, curY, dim, fw0, fwm, wd, mi, tD, tM
VAR col, row, cx, cy, tc
VAR T$, TL, TW, TX, TY, TSZ, TCOL, CX, RX
VAR P2$, PN, tm$
VAR FID$, FST, wt
VAR u$
VAR WOK, WT, WHM, WTX, WTN, WCODE, WWIND, WI, IX, IY
VAR WD$, M$, MG$, WDN$
VAR E1$, E2$, EI
VAR MX, MY, MR, ms, mc
VAR SX, SY, SR, r1, r2, CLX, CLY
VAR W$, WX, WY, WMAX, WSZ, WC, WLH, WML, WN
VAR wl$, wlc, ww$, wwc, wi, wdone, wtr, ch
VAR nt$, ny0, nc
VAR N$, NI, NCOL
VAR TK$, TN$, MP, MO, MCH, sg$
VAR F$, FV, FD, fi, ff, g, p$
VAR px, py, hx, ndone, qa, qb, bc
VAR QP[8], QO[8]
// ==========================================================
// PROGRAM STARTUP
// Initialize the display, apply portrait rotation and create a
// 480 x 800 drawing canvas. Wait briefly for the system clock to sync.
// ==========================================================
DISPLAY_INIT()
DISPLAY_ROTATE(ROT)
DISPLAY_INIT_CANVAS(0, 0, 480, 800)
// wait for clock sync (up to 60 s)
t = 0
WHILE YEAR() < 2025 AND t < 600
PAUSE 100
t = t + 1
WEND
WHILE 1
DISPLAY_CLIP(0, 0, 0, 0)
GOSUB CalcDate
IF scr = 1 THEN
GOSUB Screen1
ELSEIF scr = 2 THEN
GOSUB Screen2
ELSEIF scr = 3 THEN
GOSUB Screen3
ELSEIF scr = 4 THEN
GOSUB Screen4
ELSEIF scr = 5 THEN
GOSUB Screen5
ELSE
GOSUB Screen6
ENDIF
GOSUB DrawDots
DISPLAY_UPDATE()
PAUSE SCREEN_SEC * 1000
scr = scr + 1
IF scr > 6 THEN scr = 1
WEND
END
// ==========================================================
// SCREEN 1 — date, weather, calendar, events
// ==========================================================
Screen1:
u$ = "https://api.open-meteo.com/v1/forecast?latitude=" + LAT + "&longitude=" + LON
u$ = u$ + "¤t=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m"
u$ = u$ + "&daily=temperature_2m_max,temperature_2m_min"
u$ = u$ + "&temperature_unit=fahrenheit&wind_speed_unit=mph&timezone=auto"
HTTP_GET("wx", u$, 3600)
FID$ = "wx"
GOSUB WaitFeed
WOK = 0
IF FST = 200 THEN
WOK = 1
JSON_GET("wx", "current.temperature_2m", WT)
JSON_GET("wx", "current.relative_humidity_2m", WHM)
JSON_GET("wx", "current.weather_code", WCODE)
JSON_GET("wx", "current.wind_speed_10m", WWIND)
JSON_GET("wx", "daily.temperature_2m_max[0]", WTX)
JSON_GET("wx", "daily.temperature_2m_min[0]", WTN)
GOSUB WxDesc
ENDIF
HTTP_FREE("wx")
CANVAS_COLOR(C_WHT)
// ---------- Date tile (top left) ----------
// Shows the current month, year, day number and weekday.
DISPLAY_FILL_RECT(16, 16, 184, 48, C_RED, 16)
DISPLAY_FILL_RECT(16, 44, 184, 20, C_RED)
DISPLAY_RECT(16, 16, 184, 160, C_BLK, 2, 16)
T$ = M$ + " " + curY
CX = 108
TY = 28
TSZ = 20
TCOL = C_WHT
GOSUB TextC
T$ = "" + today
TY = 88
TSZ = 48
TCOL = C_BLK
GOSUB TextC
CX = 109
GOSUB TextC
T$ = WDN$
CX = 108
TY = 144
TSZ = 20
TCOL = C_RED
GOSUB TextC
// ---------- Weather (left) ----------
// Requests current conditions and today's high/low from Open-Meteo.
DISPLAY_RECT(16, 192, 184, 208, C_BLK, 2, 16)
DISPLAY_TEXT(32, 204, CITY, C_BLK, 16)
IF WOK = 1 THEN
IX = 54
IY = 256
GOSUB DrawWx
T$ = "" + ROUND(WT)
TX = 84
TY = 232
TSZ = 48
TCOL = C_BLK
GOSUB TextB
GOSUB TextW
dgx = (84 + TW + 10)
DISPLAY_CIRCLE(dgx, 241, 7, C_BLK, 3)
T$ = "F"
TX = (dgx + 10)
GOSUB TextB
DISPLAY_TEXT(32, 296, WD$, C_BLK, 20)
DISPLAY_FILL_TRIANGLE(32, 344, 46, 344, 39, 330, C_RED)
T$ = "" + ROUND(WTX)
GOSUB CharCount
DISPLAY_TEXT(52, 326, T$, C_BLK, 20)
TSZ = 20
GOSUB TextW
DISPLAY_CIRCLE(52 + TW + 6, 331, 3, C_BLK, 2)
DISPLAY_FILL_TRIANGLE(106, 330, 120, 330, 113, 344, C_BLU)
T$ = "" + ROUND(WTN)
GOSUB CharCount
DISPLAY_TEXT(126, 326, T$, C_BLK, 20)
GOSUB TextW
DISPLAY_CIRCLE(126 + TW + 6, 331, 3, C_BLK, 2)
DISPLAY_TEXT(32, 356, "Humidity " + ROUND(WHM) + "%", C_BLK, 16)
DISPLAY_TEXT(32, 376, "Wind " + ROUND(WWIND) + " mph", C_BLK, 16)
ELSE
DISPLAY_TEXT(32, 280, "No weather", C_RED, 20)
DISPLAY_TEXT(32, 310, "data yet", C_BLK, 16)
ENDIF
// ---------- Calendar (right) ----------
// Draws the month grid. Weekends are highlighted and configured
// events receive colored markers; today is highlighted in green.
DISPLAY_RECT(212, 16, 252, 384, C_BLK, 2, 16)
T$ = M$ + " " + curY
TX = 230
TY = 28
TSZ = 24
TCOL = C_BLK
GOSUB TextB
TY = 66
TSZ = 16
TCOL = C_BLK
TCOL = C_RED
T$ = "Su"
CX = 236
GOSUB TextC
TCOL = C_BLK
T$ = "Mo"
CX = 270
GOSUB TextC
T$ = "Tu"
CX = 304
GOSUB TextC
T$ = "We"
CX = 338
GOSUB TextC
T$ = "Th"
CX = 372
GOSUB TextC
T$ = "Fr"
CX = 406
GOSUB TextC
TCOL = C_RED
T$ = "Sa"
CX = 440
GOSUB TextC
DISPLAY_LINE(226, 92, 450, 92, C_BLK, 1)
FOR d = 1 TO dim
k = (fwm + d - 1)
row = FLOOR(k / 7)
col = (k - row * 7)
cx = (236 + col * 34)
cy = (120 + row * 46)
tc = C_BLK
IF col = 0 OR col = 6 THEN tc = C_RED
ms = 0
FOR e = 0 TO EVN - 1
IF EV_M[e] = curM AND EV_D[e] = d THEN
ms = EV_S[e]
mc = EV_C[e]
ENDIF
NEXT
TY = (cy - 11)
MX = cx
MY = (TY + MK_DY + 1)
MR = 16
IF d = today THEN
ms = 2
mc = C_GRN
ENDIF
IF ms > 0 THEN
GOSUB DrawMark
tc = C_WHT
IF mc = C_YEL THEN tc = C_BLK
ENDIF
T$ = "" + d
CX = cx
TSZ = 20
TCOL = tc
GOSUB TextC
NEXT
// ---------- Event legend (bottom) ----------
// Lists this month's events and shows how many days remain.
T$ = M$ + " events"
TX = 24
TY = 418
TSZ = 24
TCOL = C_BLK
GOSUB TextB
DISPLAY_FILL_RECT(24, 450, 48, 4, C_RED, 2)
cnt = 0
FOR e = 0 TO EVN - 1
IF EV_M[e] = curM AND cnt < 4 THEN
ry = (470 + cnt * 74)
MX = 44
MY = (ry + 13 + MK_DY)
MR = 20
ms = EV_S[e]
mc = EV_C[e]
GOSUB DrawMark
ed = EV_D[e]
T$ = "" + ed
CX = 44
TY = (ry + 13)
TSZ = 20
TCOL = C_WHT
IF mc = C_YEL THEN TCOL = C_BLK
GOSUB TextC
EI = e
GOSUB EvText
DISPLAY_TEXT(80, ry + 2, E1$, C_BLK, 24)
T$ = M$ + " " + ed
IF STRLEN(E2$) > 0 THEN T$ = T$ + " - " + E2$
DISPLAY_TEXT(80, ry + 34, T$, C_BLK, 16)
// day countdown
dd = (ed - today)
CX = 404
TY = (ry + 13)
TSZ = 16
IF dd = 0 THEN
DISPLAY_FILL_RECT(344, ry + 4, 120, 32, C_RED, 16)
T$ = "today"
TCOL = C_WHT
ELSEIF dd = 1 THEN
DISPLAY_FILL_RECT(344, ry + 4, 120, 32, C_RED, 16)
T$ = "tomorrow"
TCOL = C_WHT
ELSEIF dd > 1 THEN
DISPLAY_RECT(344, ry + 4, 120, 32, C_BLK, 2, 16)
T$ = "in " + dd + " days"
TCOL = C_BLK
ELSE
T$ = "passed"
TCOL = C_BLK
ENDIF
GOSUB TextC
IF cnt < 3 THEN DISPLAY_LINE(80, ry + 64, 464, ry + 64, C_BLK, 1)
cnt = cnt + 1
ENDIF
NEXT
IF cnt = 0 THEN DISPLAY_TEXT(24, 480, "No events this month", C_BLK, 20)
RETURN
// ==========================================================
// SCREEN 2 — WORLD NEWS
// Downloads the BBC World RSS feed and displays up to eight headlines.
// A colored stripe beside each headline helps visually separate stories.
// ==========================================================
Screen2:
HTTP_GET("news", NEWS_URL, 3600)
FID$ = "news"
GOSUB WaitFeed
CANVAS_COLOR(C_WHT)
// header
DISPLAY_FILL_RECT(0, 0, 480, 104, C_BLU)
T$ = "World News"
TX = 24
TY = 20
TSZ = 32
TCOL = C_WHT
GOSUB TextB
GOSUB NowTime
DISPLAY_TEXT(24, 66, WDN$ + ", " + M$ + " " + today + " | " + tm$, C_WHT, 16)
DISPLAY_TEXT(392, 66, "BBC", C_WHT, 20)
IF FST <> 200 THEN
DISPLAY_TEXT(24, 140, "Could not load news.", C_BLK, 24)
DISPLAY_TEXT(24, 176, "Will retry later.", C_BLK, 24)
ELSE
DISPLAY_CLIP(16, 108, 448, 668)
FOR i = 0 TO 7
JSON_GET("news", "rss.channel.item[" + i + "].title", nt$)
IF STRLEN(nt$) = 0 THEN BREAK
y = (120 + i * 82)
// stripe color cycles: blue, red, green, black
k = (i - FLOOR(i / 4) * 4)
nc = C_BLU
IF k = 1 THEN nc = C_RED
IF k = 2 THEN nc = C_GRN
IF k = 3 THEN nc = C_BLK
// headline
W$ = nt$
WX = 40
WY = y
WMAX = 31
WSZ = 24
WC = C_BLK
WLH = 30
WML = 2
GOSUB WrapText
DISPLAY_FILL_RECT(20, y + 2, 6, WY - y - 6, nc, 3)
IF i < 7 THEN DISPLAY_LINE(40, y + 70, 464, y + 70, C_BLK, 1)
NEXT
DISPLAY_CLIP(0, 0, 0, 0)
ENDIF
HTTP_FREE("news")
RETURN
// ==========================================================
// SCREEN 3 — TO-DO LIST
// Displays tasks scheduled for today and tomorrow, completion status,
// and the next upcoming calendar event.
// ==========================================================
Screen3:
CANVAS_COLOR(C_WHT)
T$ = "Today's To-Do"
TX = 24
TY = 24
TSZ = 32
TCOL = C_BLK
GOSUB TextB
DISPLAY_TEXT(24, 68, WDN$ + ", " + M$ + " " + today, C_RED, 20)
DISPLAY_FILL_RECT(24, 100, 56, 4, C_RED, 2)
// --- today ---
y = 120
cnt = 0
ndone = 0
NCOL = C_BLK
FOR NI = 0 TO NN - 1
ok1 = 0
IF NOTE_M[NI] = 0 THEN ok1 = 1
IF NOTE_M[NI] = curM THEN ok1 = 1
ok2 = 0
IF NOTE_D[NI] = 0 THEN ok2 = 1
IF NOTE_D[NI] = today THEN ok2 = 1
IF ok1 = 1 AND ok2 = 1 THEN GOSUB DrawNote
NEXT
IF cnt = 0 THEN
DISPLAY_TEXT(24, y, "Nothing planned!", C_BLK, 20)
y = (y + 36)
ELSE
T$ = "" + ndone + " of " + cnt + " done"
RX = 456
TY = 72
TSZ = 16
TCOL = C_GRN
GOSUB TextR
ENDIF
// --- tomorrow ---
tD = (today + 1)
tM = curM
IF tD > dim THEN
tD = 1
tM = (curM + 1)
IF tM > 12 THEN tM = 1
ENDIF
cnt = 0
FOR NI = 0 TO NN - 1
IF NOTE_D[NI] = tD AND NOTE_M[NI] = tM THEN cnt = cnt + 1
IF NOTE_D[NI] = tD AND NOTE_M[NI] = 0 THEN cnt = cnt + 1
NEXT
IF cnt > 0 AND y < 540 THEN
y = (y + 14)
mi = tM
GOSUB MonthName
T$ = "Tomorrow, " + M$ + " " + tD
TX = 24
TY = y
TSZ = 24
TCOL = C_BLU
GOSUB TextB
mi = curM
GOSUB MonthName
DISPLAY_FILL_RECT(24, y + 32, 40, 3, C_BLU, 2)
y = (y + 46)
NCOL = C_BLU
FOR NI = 0 TO NN - 1
ok1 = 0
IF NOTE_M[NI] = 0 THEN ok1 = 1
IF NOTE_M[NI] = tM THEN ok1 = 1
IF ok1 = 1 AND NOTE_D[NI] = tD THEN GOSUB DrawNote
NEXT
ENDIF
// --- next event (bottom card, green) ---
ne = -1
FOR e = 0 TO EVN - 1
IF ne < 0 AND EV_M[e] = curM AND EV_D[e] >= today THEN ne = e
NEXT
DISPLAY_FILL_RECT(16, 632, 448, 136, C_GRN, 20)
DISPLAY_TEXT(40, 648, "NEXT EVENT", C_WHT, 16)
IF ne >= 0 THEN
EI = ne
GOSUB EvText
T$ = E1$
IF STRLEN(E2$) > 0 THEN T$ = E1$ + ": " + E2$
TX = 40
TY = 676
TSZ = 24
TCOL = C_WHT
GOSUB TextB
ed = EV_D[ne]
dd = (ed - today)
T$ = M$ + " " + ed
IF dd = 0 THEN T$ = T$ + " - today!"
IF dd = 1 THEN T$ = T$ + " - tomorrow"
IF dd > 1 THEN T$ = T$ + " - in " + dd + " days"
DISPLAY_TEXT(40, 718, T$, C_WHT, 20)
ELSE
DISPLAY_TEXT(40, 680, "No more events", C_WHT, 24)
DISPLAY_TEXT(40, 714, "this month", C_WHT, 24)
ENDIF
RETURN
// ==========================================================
// SCREEN 4 — CRYPTOCURRENCY AND STOCK MARKET
// Retrieves Bitcoin and seven stock quotes, then displays current prices
// and percentage changes compared with the previous close/open value.
// ==========================================================
Screen4:
FOR i = 0 TO 7
QP[i] = 0
QO[i] = 0
NEXT
// max 5 feeds at once -> two batches
qa = 0
qb = 4
GOSUB FetchBatch
qa = 5
qb = 7
GOSUB FetchBatch
CANVAS_COLOR(C_WHT)
T$ = "Markets"
TX = 24
TY = 18
TSZ = 32
TCOL = C_BLK
GOSUB TextB
GOSUB NowTime
DISPLAY_TEXT(24, 58, "Prices in USD | " + tm$, C_RED, 16)
DISPLAY_FILL_RECT(24, 82, 56, 4, C_RED, 2)
FOR i = 0 TO 7
GOSUB TickInfo
MP = QP[i]
MO = QO[i]
GOSUB DrawTicker
NEXT
RETURN
// FetchBatch downloads quotes in small groups to stay within the
// platform's limit on simultaneous HTTP feeds. It then parses each reply.
FetchBatch:
FOR i = qa TO qb
GOSUB TickInfo
HTTP_HEADER(TK$, "User-Agent", "Mozilla/5.0")
IF i = 0 THEN
HTTP_GET("BTC", "https://api.exchange.coinbase.com/products/BTC-USD/stats", 3600)
ELSE
u$ = "https://query1.finance.yahoo.com/v8/finance/chart/" + TK$ + "?range=1d&interval=1d"
HTTP_GET(TK$, u$, 3600)
ENDIF
NEXT
FOR i = qa TO qb
GOSUB TickInfo
FID$ = TK$
GOSUB WaitFeed
MP = 0
MO = 0
IF FST = 200 THEN
IF i = 0 THEN
JSON_GET("BTC", "last", MP)
JSON_GET("BTC", "open", MO)
ELSE
JSON_GET(TK$, "chart.result[0].meta.regularMarketPrice", MP)
JSON_GET(TK$, "chart.result[0].meta.chartPreviousClose", MO)
ENDIF
ENDIF
QP[i] = MP
QO[i] = MO
HTTP_FREE(TK$)
NEXT
RETURN
DrawTicker:
y = (96 + i * 84)
MCH = 0
IF MO > 0 THEN MCH = ((MP - MO) / MO * 100)
mc = C_GRN
IF MCH < 0 THEN mc = C_RED
IF MP <= 0 THEN mc = C_BLK
// icon: round badge with the ticker initial
k = (i - FLOOR(i / 4) * 4)
bc = C_BLU
IF k = 1 THEN bc = C_RED
IF k = 2 THEN bc = C_GRN
IF k = 3 THEN bc = C_BLK
DISPLAY_FILL_CIRCLE(46, y + 38, 24, bc)
T$ = CHR$(ASC(TK$))
CX = 47
TY = (y + 38 - 10)
TSZ = 24
TCOL = C_WHT
GOSUB TextC
// ticker + company
T$ = TK$
TX = 84
TY = (y + 12)
TSZ = 24
TCOL = C_BLK
GOSUB TextB
DISPLAY_TEXT(84, y + 46, TN$, C_BLK, 16)
IF MP > 0 THEN
FV = MP
FD = 2
IF i = 0 THEN FD = 0
GOSUB FmtNum
T$ = "$" + F$
RX = 458
TY = (y + 10)
TSZ = 24
TCOL = C_BLK
GOSUB TextR
px = 350
py = (y +
1
0 replies