Min Phyo ThuraMohammad HabibLim Jin binAlexander Chan
Published © LGPL

Integrated Hospice Care System

How might we design an integrated IoT system to improve healthcare in remote hospices?

BeginnerFull instructions providedOver 1 day242
Integrated Hospice Care System

Things used in this project

Story

Read more

Schematics

Program Flow Chart

Powerpoint including all necessary information

Code

indoor_enviroment_unit.py

MicroPython
Python file for room environment control unit: displays ENV 2 and TVOC sensor values and upload data to Qubitro
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
from m5mqtt import M5mqtt
from libs.json_py import *
import unit


setScreenColor(0x000000)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
env2_0 = unit.get(unit.ENV2, unit.PAHUB0)
tvoc_0 = unit.get(unit.TVOC, unit.PAHUB1)
servo_0 = unit.get(unit.SERVO, unit.PORTB)


var1 = None
var2 = None
min_humidity = None
max_humidity = None
min_temp = None
max_temp = None
humid_condition = None
temp_condition = None
tvoc_condition = None
condition = None #overall condition used to control RGB bar
tvoc_limit = None
body_temp_condition = None
ac_status = None
ventilation = None



title0 = M5Title(title="Indoor Environment Control Unit", x=3, fgcolor=0x000000, bgcolor=0x45b1e8)
image0 = M5Img(5, 25, "res/default.jpg", True)
image1 = M5Img(110, 25, "res/default.jpg", True)
image2 = M5Img(215, 25, "res/default.jpg", True)
rectangle0 = M5Rect(5, 130, 100, 85, 0x000000, 0x45b1e8)
label0 = M5TextBox(60, 220, "-1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
rectangle1 = M5Rect(110, 130, 100, 85, 0x000000, 0x45b1e8)
rectangle2 = M5Rect(215, 130, 100, 50, 0x000000, 0x45b1e8)
label1 = M5TextBox(240, 220, "+1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(140, 220, "Toggle", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(25, 135, "Humidity", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(120, 135, "Room Temp", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(245, 135, "TVOC", lcd.FONT_Default, 0xFFFFFF, rotate=0)
rectangle3 = M5Rect(215, 180, 100, 35, 0x000000, 0x45b1e8)
label6 = M5TextBox(247, 182, "A/C:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label7 = M5TextBox(238, 198, "Venti:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label8 = M5TextBox(40, 155, "08", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label9 = M5TextBox(145, 155, "09", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label10 = M5TextBox(250, 155, "10", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label11 = M5TextBox(20, 190, "11", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label12 = M5TextBox(73, 190, "12", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label13 = M5TextBox(125, 190, "13", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label14 = M5TextBox(177, 190, "14", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label15 = M5TextBox(280, 182, "15", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label16 = M5TextBox(280, 198, "16", lcd.FONT_Default, 0xFFFFFF, rotate=0)
line0 = M5Line(M5Line.PLINE, 20, 205, 45, 205, 0xFFFFFF)
line1 = M5Line(M5Line.PLINE, 125, 205, 150, 205, 0xFFFFFF)
line2 = M5Line(M5Line.PLINE, 73, 190, 98, 190, 0xFFFFFF)
line3 = M5Line(M5Line.PLINE, 177, 190, 202, 190, 0xFFFFFF)
line4 = M5Line(M5Line.PLINE, 40, 190, 40, 205, 0xFFFFFF)
line5 = M5Line(M5Line.PLINE, 95, 190, 95, 205, 0xFFFFFF)
line6 = M5Line(M5Line.PLINE, 147, 190, 147, 205, 0xFFFFFF)
line7 = M5Line(M5Line.PLINE, 200, 190, 200, 205, 0xFFFFFF)
triangle0 = M5Triangle(95, 190, 92, 195, 98, 195, 0xFFFFFF, 0xFFFFFF)
triangle1 = M5Triangle(200, 190, 197, 195, 203, 195, 0xFFFFFF, 0xFFFFFF)
triangle2 = M5Triangle(40, 205, 37, 200, 43, 200, 0xFFFFFF, 0xFFFFFF)
triangle3 = M5Triangle(147, 205, 144, 200, 150, 200, 0xFFFFFF, 0xFFFFFF)

from numbers import Number


#var1 and var2 are used to toggle four variables (odd/even - four combinations for 2 var)
#change text color of the selected variable
def toggle_limits():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if var1 % 2 == 0 and var2 % 2 == 0:
    label14.setColor(0xffffff)
    label11.setColor(0x3366ff)
  elif var1 % 2 == 1 and var2 % 2 == 0:
    label11.setColor(0xffffff)
    label12.setColor(0x3366ff)
  elif var1 % 2 == 1 and var2 % 2 == 1:
    label12.setColor(0xffffff)
    label13.setColor(0x3366ff)
  else:
    label13.setColor(0xffffff)
    label14.setColor(0x3366ff)

#determine himudity, change image accordingly and change the overall conditon
def determine_humidity():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if (env2_0.humidity) < min_humidity:
    humid_condition = 'low'
    condition = False
    image0.changeImg("res/L-Humidity.png")
  elif (env2_0.humidity) > max_humidity:
    humid_condition = 'high'
    condition = False
    image0.changeImg("res/H-Humidity.png")
  else:
    humid_condition = 'normal'
    condition = True
    image0.changeImg("res/G-Humidity.png")

#determine room temperature, change image accordingly and change the overall conditon
def determine_room_temp():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if (env2_0.temperature) < min_temp:
    temp_condition = 'low'
    condition = False
    image1.changeImg("res/L-Temp.png")
  elif (env2_0.temperature) > max_temp:
    temp_condition = 'high'
    condition = False
    image1.changeImg("res/H-Temp.png")
  else:
    temp_condition = 'normal'
    condition = True
    image1.changeImg("res/G-Temp.png")

#determine air quality (tvoc) (co2 and other sensor values can be used as well), change image accordingly and change the overall conditon
def determine_tvoc():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if (tvoc_0.TVOC) > tvoc_limit:
    tvoc_condition = False
    condition = False
    image2.changeImg("res/B-TVOC.png")
  else:
    tvoc_condition = True
    condition = True
    image2.changeImg("res/G-TVOC.png")


#increase var1 and var2 accordingly to get desired format (4 odd/even combinations)
def buttonB_wasPressed():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if var1 == var2 and var1 % 2 == 0:
    var1 = (var1 if isinstance(var1, Number) else 0) + 1
  elif var1 == var2 and var1 % 2 == 1:
    var1 = (var1 if isinstance(var1, Number) else 0) + 1
  else:
    var2 = (var2 if isinstance(var2, Number) else 0) + 1
  pass
btnB.wasPressed(buttonB_wasPressed)

#decrease the selected limit by 1 
def buttonA_wasPressed():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if var1 % 2 == 0 and var2 % 2 == 0:
    min_humidity = (min_humidity if isinstance(min_humidity, Number) else 0) + -1
  elif var1 % 2 == 1 and var2 % 2 == 0:
    max_humidity = (max_humidity if isinstance(max_humidity, Number) else 0) + -1
  elif var1 % 2 == 1 and var2 % 2 == 1:
    min_temp = (min_temp if isinstance(min_temp, Number) else 0) + -1
  else:
    max_temp = (max_temp if isinstance(max_temp, Number) else 0) + -1
  pass
btnA.wasPressed(buttonA_wasPressed)

#increase the selected limit by 1
def buttonC_wasPressed():
  global var1, var2, min_humidity, max_humidity, min_temp, max_temp, humid_condition, temp_condition, tvoc_condition, condition, tvoc_limit, body_temp_condition, ac_status, ventilation
  if var1 % 2 == 0 and var2 % 2 == 0:
    min_humidity = (min_humidity if isinstance(min_humidity, Number) else 0) + 1
  elif var1 % 2 == 1 and var2 % 2 == 0:
    max_humidity = (max_humidity if isinstance(max_humidity, Number) else 0) + 1
  elif var1 % 2 == 1 and var2 % 2 == 1:
    min_temp = (min_temp if isinstance(min_temp, Number) else 0) + 1
  else:
    max_temp = (max_temp if isinstance(max_temp, Number) else 0) + 1
  pass
btnC.wasPressed(buttonC_wasPressed)


wifiCfg.doConnect('Myrios', 'abcdefghi')
if wifiCfg.wlan_sta.isconnected():
  m5mqtt = M5mqtt('env_unit', 'broker.qubitro.com', 1883, '5ad1ffd6-d9a8-4e01-9a2b-de9a0f053163', 'w2YLdJEgCOSk2mUHX5BiQjar6DD2Rr3JbEFmr5RP', 300)
  m5mqtt.start()
  min_humidity = 40
  max_humidity = 65
  min_temp = 23
  max_temp = 30
  tvoc_limit = 220
  condition = True
  tvoc_condition = True
  body_temp_condition = 'normal'
  humid_condition = 'normal'
  temp_condition = 'normal'
  ac_status = 0
  ventilation = 0
  var1 = 0
  var2 = 0
  servo_0.write_angle(0)
  while True:
    label8.setText(str(env2_0.humidity))
    label9.setText(str(env2_0.temperature))
    label10.setText(str(tvoc_0.TVOC))
    label15.setText(str(ac_status))
    label16.setText(str(ventilation))
    label11.setText(str(min_humidity))
    label12.setText(str(max_humidity))
    label13.setText(str(min_temp))
    label14.setText(str(max_temp))
    #pre-set good-condition images
    image0.changeImg("res/G-Humidity.png")
    image1.changeImg("res/G-Temp.png")
    image2.changeImg("res/G-TVOC.png")
    toggle_limits()
    determine_humidity()
    determine_room_temp()
    determine_tvoc()
    #set RGB bar to red except for normal conditions of all sensors
    if condition == False:
      rgb.setColorAll(0xff0000)
    elif humid_condition != 'normal':
      rgb.setColorAll(0xff0000)
    elif temp_condition != 'normal':
      rgb.setColorAll(0xff0000)
    elif tvoc_condition == False:
      rgb.setColorAll(0xff0000)
    else:
      rgb.setColorAll(0x33ff33)
    #turn on/off air conditioner based on humidity and room temp values
    if humid_condition == 'normal' and temp_condition == 'normal':
      ac_status = 0
    else:
      ac_status = 1
      #turn on/off air purifier and window based on air quality
    if tvoc_condition == True:
      ventilation = 0
      servo_0.write_angle(0)
    else:
      ventilation = 1
      servo_0.write_angle(90)
    #upload sensor data to qubitro using mqtt for further analysis
    m5mqtt.publish(str('env_data'), str((py_2_json({'humidity':(env2_0.humidity),'room_temp':(env2_0.temperature),'tvoc':(tvoc_0.TVOC)}))), 0)
    wait_ms(2)

health_monitoring_unit.py

MicroPython
Python file for body monitoring unit: displays mini heart rate and ncir2 sensor values and uploads data to Qubitro
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
from m5mqtt import M5mqtt
import time
from libs.json_py import *
import unit


setScreenColor(0x000000)
heart_0 = unit.get(unit.HEART, unit.PORTA)
servo_0 = unit.get(unit.SERVO, unit.PORTB)
angle_0 = unit.get(unit.ANGLE, unit.PORTB)
ncir2_1 = unit.get(unit.NCIR2, unit.PORTA)


to_validate = None
temporary = None
hr = None
sp02 = None
body_temp = None
angle = None



label6 = M5TextBox(40, 224, "Measure", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label7 = M5TextBox(197, 224, "Stop Measuring", lcd.FONT_Default, 0xFFFFFF, rotate=0)
header = M5Title(title="Body Monitoring Unit", x=3, fgcolor=0x000000, bgcolor=0x45b1e8)
image0 = M5Img(0, 20, "res/G-BTemp.png", True)
image1 = M5Img(110, 20, "res/G-Heart.png", True)
image2 = M5Img(220, 20, "res/G-SpO2.png", True)
rectangle0 = M5Rect(0, 120, 100, 100, 0x000000, 0x45b1e8)
rectangle1 = M5Rect(110, 120, 100, 100, 0x000000, 0x45b1e8)
rectangle2 = M5Rect(220, 120, 100, 100, 0x000000, 0x45b1e8)
label0 = M5TextBox(7, 129, "Temperature", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(249, 132, "SP/02", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(124, 131, "Heart Rate", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(21, 178, "text", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label4 = M5TextBox(132, 178, "text", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label5 = M5TextBox(242, 178, "text", lcd.FONT_Comic, 0xFFFFFF, rotate=0)

import math

#validating body parameters, changing image and fonts based on sensor values
# validating body temperature
def validate_body_temp(to_validate):
  global temporary, hr, sp02, body_temp, angle
  if to_validate == 1:
    label3.setFont(lcd.FONT_Comic)
    if body_temp > 37.2 or body_temp < 35.1: #sick
      image0.changeImg("res/Sick.png")
      wait(0.3)
    else:
      image0.changeImg("res/G-BTemp.png") #normal
      wait(0.3)

# validating sp/o2
def validate_sp_02(to_validate):
  global temporary, hr, sp02, body_temp, angle
  if to_validate == 1:
    hr = float(hr)
    label5.setFont(lcd.FONT_Comic)
    if sp02 <= 90: #low/bad
      image2.changeImg("res/B-SpO2.png")
      wait(0.3)
    else: #normal
      image2.changeImg("res/G-SpO2.png") 
      wait(0.3)
    hr = int(hr)

# validating heart rate
def validate_hr(to_validate):
  global temporary, hr, sp02, body_temp, angle
  if to_validate == 1:
    label4.setFont(lcd.FONT_Comic)
    sp02 = float(sp02)
    if hr > 100 or hr < 50: #normal
      image1.changeImg("res/B-Heart.png")
      wait(0.3)
    else: #bad
      image1.changeImg("res/G-Heart.png")
      wait(0.3)
    sp02 = int(sp02)

#temp variable to turn on/off heart rate sensor and ncir2
def buttonC_wasPressed():
  global temporary, hr, to_validate, sp02, body_temp, angle
  temporary = 0 #off
  heart_0.setLedCurrent(0x00, 0x00)
  pass
btnC.wasPressed(buttonC_wasPressed)

def buttonA_wasPressed():
  global temporary, hr, to_validate, sp02, body_temp, angle
  temporary = 1 #on
  heart_0.setLedCurrent(0x0F, 0x01)
  pass
btnA.wasPressed(buttonA_wasPressed)


wifiCfg.doConnect('Myrios', 'abcdefghi')
if wifiCfg.wlan_sta.isconnected():
  m5mqtt = M5mqtt('body_unit', 'broker.qubitro.com', 1883, '995ca20f-70e3-48aa-b7fe-885d6f14d7b3', 'zWXPS6G$Q6Hj3Mg8aGm-5jLx9fzCiO-IUpDLXeI6', 300)
  m5mqtt.start()
  rgb.setBrightness(100)
  heart_0.setMode(0x03)
  temporary = 0
  body_temp = 36.5
  hr = 0
  sp02 = 0
  while True:
    angle = math.ceil((angle_0.read()) / 17 + 11) #math to adjust angle value to servo angle
    servo_0.write_angle(angle) 
    body_temp = ncir2_1.temperature_measure()
    hr = heart_0.getHeartRate()
    sp02 = heart_0.getSpO2()
    if temporary == 0: #turn off sensors
      label3.setFont(lcd.FONT_DefaultSmall)
      label3.setText('Waiting...')
      label5.setFont(lcd.FONT_DefaultSmall)
      label5.setText('Waiting...')
      label4.setFont(lcd.FONT_DefaultSmall)
      label4.setText('Waiting...')
    else: #turn on sensors
      label3.setText(str(body_temp))
      label4.setText(str(hr))
      label5.setText(str(sp02))
    validate_body_temp(temporary)
    validate_hr(temporary)
    validate_sp_02(temporary)
    if hr > 0 and body_temp > 30: #upload data to qubitro using mqtt for valid valid sensor values
      m5mqtt.publish(str('body_data'), str((py_2_json({'heart_rate':hr,'spo2':sp02,'body_temp':body_temp}))), 0)
    wait_ms(2)

toilet_safety_unit.py

MicroPython
Python file for toilet safety unit: lock/unlock toilet door based on floor wetness, detect fall using gesture sensor unit and wait for 5 seconds before turning on the alarm
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
import time
import unit


setScreenColor(0x45b1e8)
servo_0 = unit.get(unit.SERVO, unit.PORTB)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
pbhub_0 = unit.get(unit.PBHUB, unit.PAHUB0)
rfid_0 = unit.get(unit.RFID, unit.PAHUB5)
gesture_0 = unit.get(unit.GESTURE, unit.PAHUB2)


get_gesture = None
Lights = None
FloorWetness = None
Fall = None
i = None

"""The earth sensor we used did not work properly when it is connected to PbHub; under normal condition (i.e., when it is not wet) it reads over 600 moisture, and when the sensor is touched with a wet finger, it reads around 400 moisture.
We tried adjusting the sensitivity, but the earth sensor works as expected only when it is connected to Port B directly, and it refuses to work properly though Port B.
"""

image0 = M5Img(110, 70, "res/16.jpg", True)
label0 = M5TextBox(40, 205, "LOCK ", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label1 = M5TextBox(209, 205, "UNLOCK", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
title0 = M5Title(title="Toilet System", x=115, fgcolor=0x000000, bgcolor=0xc7c7c7)
label2 = M5TextBox(146, 210, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image1 = M5Img(110, 70, "res/15.jpg", True)
label3 = M5TextBox(96, 40, "Have you fallen?", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(10, 50, "Click the  ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(10, 70, "middle button", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label10 = M5TextBox(134, 195, "Wetness", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label6 = M5TextBox(10, 90, "within", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label7 = M5TextBox(9, 135, "seconds not to", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label8 = M5TextBox(21, 110, "label8", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
label9 = M5TextBox(10, 155, "turn on the", lcd.FONT_Default, 0xFFFFFF, rotate=0)


#turn off toilet light after use
def Turn_Off_Lights():
  global get_gesture, Lights, FloorWetness, Fall, i
  if Lights == 1:
    rgb.setColorAll(0x000000)
    Lights = 0
  else:
    Lights = 0

#defect fall in toilet
def Fall_Detector():
  global get_gesture, Lights, FloorWetness, Fall, i
  get_gesture = gesture_0.get_gesture()
  if get_gesture == (gesture_0.GestureDown):
    #show fall instructions
    label3.show()
    label4.show()
    label5.show()
    label6.show()
    label7.show()
    label9.show()
    #count 5 seconds before turning on the alarm
    for i in range(5, -1, -1):
      label8.show()
      label8.setText(str(i))
      wait(1)
      image1.changeImg("res/16.jpg")
      if not (btnB.isPressed()) and i != 0: #continue with next iteration if the button is not pressed
        continue
      elif btnB.isPressed(): #stop the alarm and change text upon button press
        label3.hide()
        label6.hide()
        label7.hide()
        label8.hide()
        label9.hide()
        image1.changeImg("res/15.jpg")
        label4.setText('Glad that you')
        label5.setText('are safe.')
        rgb.setColorAll(0x33ff33)
        wait(3)
        rgb.setColorAll(0x000000)
        label4.hide()
        label5.hide()
        break
      elif i == 0: #counter becomes zerp; turn on fall alarm
        Fall = 0
        while not ((btnC.isPressed()) or (rfid_0.isCardOn()) == 1):
          wait(0.5)
          pbhub_0.setColor(1, 0, 3, 0xff0000)
          speaker.tone(1800, 200)
          wait(0.5)
          pbhub_0.setColor(1, 0, 3, 0x000000)
          speaker.tone(1800, 200)
          wait(0.5)


def buttonA_wasPressed(): #lock toilet after entering
  global get_gesture, Lights, FloorWetness, Fall, i
  if 600 < FloorWetness: #not wet
    servo_0.write_angle(180)
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonC_wasPressed(): #unlock toilet to go out after use
  global get_gesture, Lights, FloorWetness, Fall, i
  pbhub_0.setColor(1, 0, 3, 0x006600)
  servo_0.write_angle(90)
  wait(5)
  servo_0.write_angle(180)
  Turn_Off_Lights()
  pass
btnC.wasPressed(buttonC_wasPressed)


wifiCfg.doConnect('Myrios', 'abcdefghi')
if wifiCfg.wlan_sta.isconnected():
  gesture_0.begin()
  Fall = 0
  get_gesture = 0
  servo_0.write_angle(180)
  image0.hide()
  image1.hide()
  pbhub_0.setColor(1, 0, 3, 0x006600)
  while True:
    #hide fall texts
    label3.hide()
    label4.hide()
    label5.hide()
    label6.hide()
    label7.hide()
    label8.hide()
    label9.hide()
    label2.setText(str(pbhub_0.analogRead(0)))
    FloorWetness = pbhub_0.analogRead(0)
    #show good/bad image based on floor wetness
    if FloorWetness > 600: #not wet
      image0.hide()
      image1.show()
    if FloorWetness > 600 and (rfid_0.isCardOn()) == 1: #not wet and person comes
      wait(1)
      servo_0.write_angle(90) #unlock door
      rgb.setColorAll(0xffffff) 
      pbhub_0.setColor(1, 0, 3, 0x660000)
      Lights = 1
      wait(3)
      while (rfid_0.isCardOn()) == 0: #detect fall until RFID is read on person exiting
        rgb.setColorAll(0x33ffff)
        Fall_Detector()
      #hide text if there is no actual fall after downward gesture defection
      label3.hide()
      label4.hide()
      label5.hide()
      label6.hide()
      label7.hide()
      label8.hide()
      label9.hide()
    elif FloorWetness < 600: #floor is wet; lock the door 
      label10.setColor(0xff0000)
      label2.setColor(0xff0000)
      image1.hide()
      image0.show()
    wait_ms(2)

Credits

Min Phyo Thura

Min Phyo Thura

1 project • 2 followers
DADE Student at NYP Class of 2026
Mohammad Habib

Mohammad Habib

0 projects • 0 followers
Lim Jin bin

Lim Jin bin

0 projects • 1 follower
Alexander Chan

Alexander Chan

0 projects • 1 follower

Comments