Vanshika VashisthAman KumarPrashant YadavKashika Gupta
Published © GPL3+

StressGuard - Exam Stress Monitor using Raspberry Pi Pico

Stressed in exams? StressGuard detects rising stress in real time & alerts you before panic sets in. Built on Pi Pico. Fully offline.

BeginnerWork in progress6 hours7
StressGuard - Exam Stress Monitor using Raspberry Pi Pico

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Buzzer
Buzzer
×1
Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
Seeed Studio Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
×1
Resistor 220 ohm
Resistor 220 ohm
×1
5 mm LED: Red
5 mm LED: Red
×1

Software apps and online services

MicroPython
MicroPython
wokwi
thonny

Hand tools and fabrication machines

Breadboard, Solderless
Breadboard, Solderless
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Schematics

StressGuard

Working Image

Code

StressGuard

MicroPython
Code
from machine import Pin, ADC, PWM, I2C
import utime
from ssd1306 import SSD1306_I2C    # OLED display library

# Setup
sensor = ADC(26)
led = Pin(15, Pin.OUT)
buzzer = PWM(Pin(14))

# OLED Setup
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)   # 128x64 pixel display

def get_stress(raw):
    return int((raw / 65535) * 100)

def beep(frequency, duration):
    buzzer.freq(frequency)
    buzzer.duty_u16(30000)
    utime.sleep(duration)
    buzzer.duty_u16(0)

def blink(times, on_time, off_time):
    for i in range(times):
        led.value(1)
        utime.sleep(on_time)
        led.value(0)
        utime.sleep(off_time)

def show_display(stress, status):
    oled.fill(0)                          # Clear screen

    # Title
    oled.text("STRESS MONITOR", 0, 0)
    oled.text("--------------", 0, 10)

    # Stress percentage
    oled.text("Level: " + str(stress) + "%", 0, 22)

    # Status text
    oled.text("Status: " + status, 0, 34)

    # Progress bar (shows stress visually)
    bar_width = int((stress / 100) * 120)  # Max 120 pixels wide
    oled.rect(0, 50, 120, 10, 1)           # Outer box
    oled.fill_rect(0, 50, bar_width, 10, 1) # Filled bar

    oled.show()                            # Push to screen

while True:
    raw_value = sensor.read_u16()
    stress = get_stress(raw_value)

    print("Stress Level:", stress, "%")

    if stress < 40:
        led.value(0)
        buzzer.duty_u16(0)
        show_display(stress, "CALM")
        print("Status: CALM")
        utime.sleep(0.5)

    elif stress < 70:
        show_display(stress, "MODERATE")
        print("Status: MODERATE")
        blink(2, 0.4, 0.4)
        beep(500, 0.2)
        utime.sleep(0.3)

    else:
        show_display(stress, "HIGH!")
        print("Status: HIGH STRESS")
        blink(3, 0.1, 0.1)
        beep(1000, 0.1)
        beep(1000, 0.1)
        utime.sleep(0.2)

Credits

Vanshika Vashisth
1 project • 1 follower
Aman Kumar
1 project • 0 followers
Prashant Yadav
1 project • 0 followers
Kashika Gupta
1 project • 1 follower

Comments