Hendra Kusumah
Published © GPL3+

Stand Up Reminder!

A health-focused device that helps you fight the dangers of sitting too long

BeginnerFull instructions provided3 hours61
Stand Up Reminder!

Things used in this project

Hardware components

AWS IoT Edukit SimpleIoT Starter Bundle V1.0
M5Stack AWS IoT Edukit SimpleIoT Starter Bundle V1.0
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

core2 schematic

Code

standupreminder

Arduino
#include <M5Core2.h>
#include "esp_sleep.h"
#include <Adafruit_NeoPixel.h>

// Sleep time: 30 minutes (in microseconds)
#define SLEEP_TIME 30 * 60 * 1000000ULL

// NeoPixel setup
#define LED_PIN 25
#define LED_COUNT 10
Adafruit_NeoPixel pixels(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void strongVibrationPattern() {
  // First pulse
  M5.Axp.SetLDOEnable(3, true);
  delay(150);
  M5.Axp.SetLDOEnable(3, false);
  delay(100);

  // Second pulse (double buzz effect)
  M5.Axp.SetLDOEnable(3, true);
  delay(200);
  M5.Axp.SetLDOEnable(3, false);
}

void setup() {
  M5.begin();
  M5.Axp.ScreenBreath(6);
  pixels.begin();
  pixels.clear();
  pixels.show();

  M5.Lcd.fillScreen(TFT_BLACK);
  M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);
  M5.Lcd.setTextSize(2);

  // Check wakeup reason
  esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();

  if (wakeup_reason == ESP_SLEEP_WAKEUP_TIMER) {
    // Reminder mode
      M5.Lcd.fillScreen(TFT_RED);
      M5.Lcd.setTextColor(TFT_YELLOW, TFT_RED);
      M5.Lcd.setTextDatum(MC_DATUM);

      // Warning text block
      M5.Lcd.setFreeFont(&FreeSansBold9pt7b);
      M5.Lcd.drawString("Don't get yourself", 160, 50);
      M5.Lcd.drawString("a heart attack",     160, 100);

      // Main alert (slightly larger, but fits)
      M5.Lcd.setFreeFont(&FreeSansBold18pt7b);
      M5.Lcd.drawString("Stand up!", 160, 150);
    while (true) {
      // Vibrate + NeoPixels ON
      M5.Axp.SetLDOEnable(3, true);
      for (int i = 0; i < LED_COUNT; i++) {
        pixels.setPixelColor(i, pixels.Color(255, 0, 0));
      }
      pixels.show();
      delay(300);



      // Vibrate + NeoPixels OFF
      M5.Axp.SetLDOEnable(3, false);
      pixels.clear();
      pixels.show();
      delay(300);

      // Check touch input
      M5.update();
      if (M5.Touch.ispressed()) {
        delay(500); // debounce
        break;
      }
    
}

  } else {
    // First boot message
    M5.Lcd.setCursor(20, 120);
    M5.Lcd.println("Sitting Reminder Active");
    delay(1500);
  }

    // Prepare to sleep again
  M5.Lcd.fillScreen(TFT_BLACK);
  M5.Lcd.setFreeFont(&FreeSansBold9pt7b);
  M5.Lcd.setCursor(50, 120);
  M5.Lcd.println("Sleeping...");
  delay(1000);

  // Turn off LCD
  M5.Axp.SetDCDC3(false);

  // Make sure vibration motor is off
  M5.Axp.SetLDOEnable(3, false);

  // Turn off NeoPixels (clear + show)
  pixels.clear();
  pixels.show();

  // Set wakeup timer
  esp_sleep_enable_timer_wakeup(SLEEP_TIME);

  // Deep sleep
  esp_deep_sleep_start();

}

void loop() {
  // Not used
}

Credits

Hendra Kusumah
49 projects • 163 followers
Love hacking and making new things from IoT to robotics

Comments