Carol Chesney
Published

Lunch monitor

Monitors the temperature of your lunch box and alerts if it has been too warm.

BeginnerFull instructions provided724
Lunch monitor

Things used in this project

Story

Read more

Code

Lunchbox monitor

Arduino
Uses Bean's onboard temp sensor to monitor time above 40 degrees F. When it reaches the 2 hour limit, it alerts with flashing light. Also lets a connected device read the temperature and time above the temp limit. Don't expect to read it when it's in the fridge.
/*** lunch Alert:
  Puts following data in scratch
     current temp
     minutes > 5*C
  Also: Change onboard LED to flash if spoilt
***/
//Only check (and integrate) every 5 minutes
#define TTINTERVAL 300000
#define TICK 5
#define FLASH_PER_TICK 200
// Time above Temp limit 120 min or 2 hours
#define TTLIMIT 120

void setup() {
  // Blink Bean to denote start
  Bean.setLed(0, 200, 0);
  Bean.sleep(100);
  Bean.setLed(0, 0, 0);
}

void loop() {
  static uint8_t minAbove5C = 0;    //minutes above 40F or 5C
  int8_t lTemp = Bean.getTemperature();

  if ( lTemp >= 5 ) {
    minAbove5C += TICK;
  }

  //put current temp and minAbove5C in scratch here
  Bean.setScratchData (1, (uint8_t *) &lTemp, 1);
  Bean.setScratchData (2, &minAbove5C, 1);

  if ( minAbove5C >= TTLIMIT)
    for (int i = 0; i < FLASH_PER_TICK; i++) {
      Bean.setLed(110, 0, 0);
      Bean.sleep(100);
      Bean.setLed(0, 0, 0);
      Bean.sleep(1400);
    }
  else
    Bean.sleep(TTINTERVAL);
}

Credits

Carol Chesney

Carol Chesney

5 projects • 9 followers
Mechanical engineer and teacher

Comments

Add projectSign up / Login