Muhammad SadiqbravenGoh Joon Hong AbelTan Yong Rui
Created December 11, 2024

Safe Freezer Storage System

Our solution aims to solve the issue of unsafe freezer storage rooms by preventing people from getting trapped inside.

90
Safe Freezer Storage System

Things used in this project

Hardware components

M5Stack FIRE V2.7
M5Stack FIRE V2.7
×2
PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
M5Stack PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
×1
Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
M5Stack Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
×1
M5Stack RGB Unit with NeoPixel RGB LED (SK6812)
M5Stack RGB Unit with NeoPixel RGB LED (SK6812)
×1
Mini HUB Unit 1 to 3 HUB
M5Stack Mini HUB Unit 1 to 3 HUB
×1

Software apps and online services

M5Stack UIFlow

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Scissors, Free Fall
Scissors, Free Fall
Tape, Masking
Tape, Masking

Story

Read more

Code

ELECT-F M5Stack Code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
pir_0 = unit.get(unit.PIR, unit.PORTB)
tof_0 = unit.get(unit.TOF, unit.PORTA)
rgb_0 = unit.get(unit.RGB, unit.PORTB)


time = None
showingtime = None
dooropen = None
personinside = None
stopwatch = None
overtime = None
wasovertime = None



label8 = M5TextBox(118, 129, "X Mins", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label7 = M5TextBox(83, 90, "ARMED", lcd.FONT_DejaVu40, 0xf81f1f, rotate=0)
image0 = M5Img(0, 0, "res/m5s-min.png", True)
label0 = M5TextBox(110, 90, "(Minutes)", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label1 = M5TextBox(110, 135, "Text", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label2 = M5TextBox(150, 215, "+", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label3 = M5TextBox(245, 215, "-", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label4 = M5TextBox(25, 215, "Set Time", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label5 = M5TextBox(100, 60, "Set Time", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label6 = M5TextBox(105, 5, "Door Open", lcd.FONT_DejaVu18, 0x1fff65, rotate=0)
label9 = M5TextBox(110, 156, "Warning", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label10 = M5TextBox(110, 177, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label11 = M5TextBox(54, 182, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number




image0.show()
label0.hide()
label1.hide()
label2.show()
label3.show()
label4.show()
label5.hide()
label6.show()
label7.hide()
label8.hide()
label9.hide()
label10.hide()
label11.hide()
time = 1
showingtime = False
dooropen = True
personinside = False
stopwatch = 0
overtime = 0
wasovertime = False
rgb_0.setColorAll(0x000000)
while True:
  label1.setText(str(time))
  if dooropen == True:
    stopwatch = 0
    overtime = 0
    rgb_0.setColorAll(0x000000)
    rgb.setColorAll(0x000000)
    if btnA.isPressed():
      wait_ms(100)
      if showingtime == False:
        label0.show()
        label1.show()
        label2.show()
        label3.show()
        label5.show()
        showingtime = True
        label4.setText('Confirm')
      else:
        label0.hide()
        label1.hide()
        label5.hide()
        showingtime = False
        label4.setText('Set Time')
    if btnB.isPressed():
      wait_ms(100)
      time = (time if isinstance(time, Number) else 0) + 1
    if (btnC.isPressed()) and time > 1:
      wait_ms(100)
      time = (time if isinstance(time, Number) else 0) + -1
  if (tof_0.distance) >= 70:
    label6.setText('Door Open')
    label6.setColor(0x33ff33)
    label7.hide()
    label8.hide()
    dooropen = True
  elif (tof_0.distance) < 70:
    label6.setText('Door Closed')
    label6.setColor(0xff0000)
    dooropen = False
  if (pir_0.state) == 1:
    personinside = True
  elif (pir_0.state) == 0:
    personinside = False
  if dooropen == False and personinside == True:
    label0.hide()
    label1.hide()
    label2.hide()
    label3.hide()
    label4.hide()
    label5.hide()
    label7.show()
    label8.show()
    label11.show()
    label11.setText(str(stopwatch))
    label8.setText(str((str(time) + str('Mins'))))
    stopwatch = stopwatch + 1
    wait(1)
  if stopwatch >= time * 60:
    image0.changeImg("warning.jpg")
    rgb_0.setColorAll(0xffff00)
    rgb.setColorAll(0xffff66)
    overtime = stopwatch - time * 60
    label9.show()
    label11.hide()
    label10.setText(str((str(overtime) + str('s overtime'))))
    speaker.tone(1800, 200)
    rgb_0.setColorAll(0xff0000)
    rgb.setColorAll(0xff0000)
    wasovertime = True
  if wasovertime == True:
    image0.changeImg("defbackground.jpg")
    label9.hide()
    label10.hide()
    wasovertime = False
  wait_ms(2)

Credits

Muhammad Sadiq
1 project • 1 follower
braven
0 projects • 1 follower
Goh Joon Hong Abel
0 projects • 2 followers
Tan Yong Rui
0 projects • 2 followers

Comments