Build it step by step
0 of 7 doneWire the clock and screen
Both to A4, A5, 5V and GND.
Wire the buttons
D2 to D6, each button to GND.
Upload the sketch
The screen shows seven thin lines and a title.
Press button 4
Today's bar rises and fills in.
Press button 2
Today's bar drops to the new score.
Unplug and plug in the Nano
The bar is still there.
Check again tomorrow
A new solid bar appears and the old one is outlined.
How do you build a daily mood diary?
Press one of five buttons once a day to record how you felt, and the screen draws a bar chart of the last seven days, kept on the device only. A tidy way to learn about saving data and drawing charts. It is a personal reminder and not a health tool, so talk to someone you trust if you are low for long. You need Arduino Nano, DS3231 RTC module, Tactile push button 6 mm × 5, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 6
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Mood buttons 1 to 5 | Nano D2, D3, D4, D5 and D6, each to GND | 1 is a bad day and 5 is a great day |
| RTC SDA and SCL | Nano A4 and A5 | I2C data and clock, address 0x68 |
| OLED SDA and SCL | Nano A4 and A5 | Same two wires, address 0x3C |
| RTC and OLED VCC and GND | Nano 5V and GND | Power for both modules |
Code
Five buttons stand for five moods, from 1 for a bad day to 5 for a great day. Pressing one stores a score for today, and pressing another later the same day simply changes it. The screen shows the last seven days as seven bars, with the oldest on the left and today on the right as a solid bar; a day with no entry is a thin line along the bottom. The clock chip keeps the date even when the Nano is off, so the sketch can tell when midnight has passed and slides the week along by one day, dropping the oldest bar. If the diary has been off for a few days the gap is left empty, and after a week it starts afresh. The scores and the date of the last bar are kept in the Nano's EEPROM after every press, so the diary survives a power cut, and it never leaves the device. The clock is set from your computer's time when the sketch is uploaded the first time, or when its battery has been out, so check it shows the right time zone. The clock module and the screen share the same two I2C wires, which is fine because they have different addresses. Install "RTClib", "Adafruit SSD1306" and "Adafruit GFX" from the Library Manager. This is a personal reminder to notice your own patterns and not a health tool or a test of any kind. If you feel low for a long time, please talk to someone you trust, such as a family member, a teacher or a doctor. If the clock module has a coin cell, fit it with the right polarity, never charge it, and keep it away from small children.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Libraries: RTClib by Adafruit, Adafruit SSD1306 and Adafruit GFX.
#include <Wire.h>
#include <EEPROM.h>
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
RTC_DS3231 rtc;
const uint8_t BTN[5] = {2, 3, 4, 5, 6};
const uint8_t DAYS = 7;
const int EE_MAGIC = 0; // 1 byte
const int EE_DAY = 1; // 4 bytes, the day number of the last bar
const int EE_SCORES = 5; // 7 bytes, oldest first
uint8_t scores[DAYS]; // 0 means nothing logged, 1..5 is the mood
uint32_t lastDay = 0;
uint32_t dayNumber() { return rtc.now().unixtime() / 86400UL; }
void save() {
EEPROM.update(EE_MAGIC, 0xA5);
EEPROM.put(EE_DAY, lastDay);
for (uint8_t i = 0; i < DAYS; i++) EEPROM.update(EE_SCORES + i, scores[i]);
}
void load() {
if (EEPROM.read(EE_MAGIC) != 0xA5) { // first run
for (uint8_t i = 0; i < DAYS; i++) scores[i] = 0;
lastDay = dayNumber();
save();
return;
}
EEPROM.get(EE_DAY, lastDay);
for (uint8_t i = 0; i < DAYS; i++) scores[i] = EEPROM.read(EE_SCORES + i);
}
void rollToToday() { // slide the week along when a new day starts
uint32_t today = dayNumber();
if (today <= lastDay) return;
uint32_t gap = today - lastDay;
if (gap >= DAYS) {
for (uint8_t i = 0; i < DAYS; i++) scores[i] = 0;
} else {
for (uint8_t i = 0; i + gap < DAYS; i++) scores[i] = scores[i + gap];
for (uint8_t i = DAYS - gap; i < DAYS; i++) scores[i] = 0;
}
lastDay = today;
save();
}
void draw() {
oled.clearDisplay();
oled.setTextColor(SSD1306_WHITE);
oled.setTextSize(1);
oled.setCursor(0, 0);
oled.print(F("How was today? 1-5"));
for (uint8_t i = 0; i < DAYS; i++) {
int x = 4 + i * 18;
int h = scores[i] * 9; // up to 45 pixels
if (scores[i] == 0) {
oled.drawFastHLine(x, 62, 14, SSD1306_WHITE); // a thin line for no entry
} else if (i == DAYS - 1) {
oled.fillRect(x, 62 - h, 14, h, SSD1306_WHITE); // today is solid
} else {
oled.drawRect(x, 62 - h, 14, h, SSD1306_WHITE); // earlier days are outlined
}
}
oled.display();
}
void setup() {
for (uint8_t i = 0; i < 5; i++) pinMode(BTN[i], INPUT_PULLUP);
Serial.begin(9600);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
if (!rtc.begin()) { Serial.println(F("No RTC found")); while (true) {} }
if (rtc.lostPower()) rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
load();
rollToToday();
draw();
}
unsigned long lastCheck = 0;
void loop() {
for (uint8_t i = 0; i < 5; i++) {
if (digitalRead(BTN[i]) == LOW) {
scores[DAYS - 1] = i + 1; // pressing again today just changes the score
save();
Serial.print(F("Mood today: "));
Serial.println(i + 1);
draw();
delay(250);
}
}
if (millis() - lastCheck > 5000) { // look for a new day every five seconds
lastCheck = millis();
uint32_t before = lastDay;
rollToToday();
if (lastDay != before) draw();
}
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
No RTC found
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| First start | Seven thin lines, nothing logged |
| Button 1 to 5 | Today's bar grows with the number |
| Press again the same day | The score changes |
| Power cut | The week is remembered |
| Next day | The week slides left by one |
| Serial monitor | Prints each score as you press |
If it does not work
Prints No RTC found
Check the clock module's SDA and SCL wires.
Time is wrong
Remove the coin cell for a moment, or re-upload to set it.
Blank screen
Check the OLED wires and try address 0x3D.
Buttons do nothing
Check each goes to its pin and GND.
Old data shows
Change EE_MAGIC to another value to start afresh.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the daily mood diary?
Arduino Nano, DS3231 RTC module, Tactile push button 6 mm × 5, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the daily mood diary take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the daily mood diary works?
First start: Seven thin lines, nothing logged. Button 1 to 5: Today's bar grows with the number. Press again the same day: The score changes.
Prints No RTC found: what should I check?
Check the clock module's SDA and SCL wires.
Time is wrong: what should I check?
Remove the coin cell for a moment, or re-upload to set it.
Blank screen: what should I check?
Check the OLED wires and try address 0x3D.
Buttons do nothing: what should I check?
Check each goes to its pin and GND.
