Jerryl LooChiah Hao EnEdmund Oh
Published

Automated Covid-19 prevention station at libraries

A small simple station made out of 2 M5 Stack devices to be installed in libraries

BeginnerFull instructions provided55
Automated Covid-19 prevention station at libraries

Story

Read more

Schematics

Crowd Control and Sanitizing Gate Circuit Diagram

Code

Check out and Crowd Monitoring System

Python
In the second m5stack fire device, a light unit will track the number of people checking in through an LED system on the right side of the first m5stack. While doing that, the tof unit, which is also connected to the second m5stack fire device, helps to track the number of people leaving. When the device tracks that 50 people are in the library, it will display "Library is FULL" on its screen and informing newcomers to "Please come back after 10 minutes". During this period, if people were to still check in, this m5stack fire device will beep 3 times to alert the librarians. This device will also display the number of people in the library as well as green, orange and red LED to display the level of crowd. The first button is to set the number of people to 0, second button is to -1 from the total number of people and third button to alert librarians of a need of help by user.
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
light1 = unit.get(unit.LIGHT, unit.PORTB)
tof1 = unit.get(unit.TOF, unit.PORTA)


count = None


label0 = M5TextBox(66, 19, "Level of Crowd", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(14, 78, "No. of People: ", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
noOfpeople = M5TextBox(200, 78, "0", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label3 = M5TextBox(14, 162, "Library still allow entry", lcd.FONT_DejaVu24, 0xfff400, rotate=0)
label2 = M5TextBox(39, 219, "Set to 0", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label4 = M5TextBox(153, 219, "-1", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label6 = M5TextBox(0, 106, "Library is FULL", lcd.FONT_DejaVu40, 0xff0000, rotate=0)
label5 = M5TextBox(200, 219, "Press for Help!", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)

from numbers import Number



def buttonA_wasPressed():
  global count
  count = 0
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonC_wasPressed():
  global count
  speaker.sing(889, 1)
  pass
btnC.wasPressed(buttonC_wasPressed)

def buttonB_wasPressed():
  global count
  count = (count if isinstance(count, Number) else 0) + -1
  pass
btnB.wasPressed(buttonB_wasPressed)


count = 0
while True:
  label6.hide()
  noOfpeople.setText(str(count))
  if (tof1.distance) < 300 and (light1.analogValue) <= 300:
    wait(1)
  elif count == 50 and (light1.analogValue) <= 300:
    wait(1)
    count = (count if isinstance(count, Number) else 0) + 1
    speaker.sing(220, 1/4)
    label6.show()
    wait(0.7)
    label6.hide()
    speaker.sing(220, 1/4)
    label6.show()
    wait(0.7)
    label6.hide()
    speaker.sing(220, 1/4)
    label6.show()
    wait(0.7)
    label6.hide()
  elif (tof1.distance) < 300:
    count = (count if isinstance(count, Number) else 0) + -1
    wait(1)
  elif (light1.analogValue) <= 300:
    wait(1)
    count = (count if isinstance(count, Number) else 0) + 1
  elif count >= 25 and count < 50:
    rgb.setColorFrom(6 , 10 ,0xff9900)
    rgb.setColorFrom(1 , 5 ,0xff9900)
    label3.setText('Library still allow entry')
  elif count < 25:
    rgb.setColorFrom(6 , 10 ,0x33ff33)
    rgb.setColorFrom(1 , 5 ,0x33ff33)
    label3.setText('Library still allow entry')
  elif count >= 50:
    label6.show()
    label3.setText('Please come back after 10 minutes')
    rgb.setColorFrom(6 , 10 ,0xff0000)
    rgb.setColorFrom(1 , 5 ,0xff0000)
  wait_ms(2)

Check in System (Gate) and Sanitizer Dispenser

Python
In the first m5stack fire device, we have a check in system to allow people to scan to register their entry using newly produced library cards. After that, the device will display green LED on the left side of the device to signal to the user that they can proceed. Then, the device will also display a countdown timer for the dispensing of the sanitizer followed by the opening of the gate.
from m5stack import *
from m5ui import *
from uiflow import *
import machine
import time
import unit

setScreenColor(0xffffff)
servo4 = unit.get(unit.SERVO, unit.PORTB)
rfid1 = unit.get(unit.RFID, unit.PORTA)


i = None
PWM0 = machine.PWM(26, freq=50, duty=3, timer=0)


rectangle0 = M5Rect(10, 155, 300, 70, 0xFFFFFF, 0xff0000)
rectangle1 = M5Rect(85, 75, 150, 50, 0xFFFFFF, 0xff0000)
label1 = M5TextBox(22, 25, "Card Read: ", lcd.FONT_DejaVu24, 0x000000, rotate=0)
label2 = M5TextBox(129, 87, "Status", lcd.FONT_DejaVu24, 0x322d2d, rotate=0)
label0 = M5TextBox(22, 161, "Place hand under ", lcd.FONT_DejaVu24, 0xf20a0a, rotate=0)
label3 = M5TextBox(22, 189, "the sanitizer in: ", lcd.FONT_DejaVu24, 0xf50000, rotate=0)
label4 = M5TextBox(261, 161, "3", lcd.FONT_DejaVu56, 0xfc0000, rotate=0)




while True:
  label2.setText(str(rfid1.isCardOn()))
  if rfid1.isCardOn():
    label2.setText(str(rfid1.isCardOn()))
    rgb.setColorFrom(6 , 10 ,0x33ff33)
    rgb.setColorFrom(1 , 5 ,0x000000)
    wait(0.7)
    rgb.setColorFrom(1 , 5 ,0xff0000)
    for i in range(3, -1, -1):
      label4.setText(str(i))
      wait(0.7)
    PWM0.duty(12)
    wait(5)
    PWM0.duty(3)
    rgb.setColorFrom(6 , 10 ,0x000000)
    i = 3
    label4.setText(str(i))
  wait_ms(2)

Credits

Jerryl Loo

Jerryl Loo

1 project • 0 followers
Chiah Hao En

Chiah Hao En

1 project • 0 followers
Edmund Oh

Edmund Oh

0 projects • 0 followers

Comments