Irfan Rehan
Published

Self dispensing hand sanitizer

The device monitors people entering malls, checks vaccination & temperature. Access granted only to those meeting safety requirements.

AdvancedFull instructions providedOver 6 days150
Self dispensing hand sanitizer

Things used in this project

Story

Read more

Code

M5Stack 1

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

setScreenColor(0xffffff)
env2_0 = unit.get(unit.ENV2, unit.PAHUB0)
pahub_1 = unit.get(unit.PAHUB, unit.PORTA)
tof_1 = unit.get(unit.TOF, unit.PAHUB1)
rfid_1 = unit.get(unit.RFID, unit.PAHUB5)
light_1 = unit.get(unit.LIGHT, unit.PORTB)


people = None



label1 = M5TextBox(120, 210, "0", lcd.FONT_UNICODE, 0xab00ff, rotate=0)
label2 = M5TextBox(0, 77, "Text", lcd.FONT_UNICODE, 0x000000, rotate=0)
label3 = M5TextBox(0, 29, "Text", lcd.FONT_UNICODE, 0x000000, rotate=0)
image0 = M5Img(170, 0, "res/chart.png", True)
label4 = M5TextBox(0, 167, "Temparature:", lcd.FONT_UNICODE, 0xff0000, rotate=0)
label5 = M5TextBox(0, 210, "Capacity:", lcd.FONT_UNICODE, 0x00fff4, rotate=0)
label6 = M5TextBox(249, 167, "℃", lcd.FONT_UNICODE, 0xff0000, rotate=0)
label0 = M5TextBox(170, 167, "0", lcd.FONT_UNICODE, 0x49ff00, rotate=0)

from numbers import Number




people = 0
image0.show()
while True:
  if rfid_1.isCardOn():
    if (rfid_1.readUid()) == 'c255fc117a':
      label2.setText('Vaccinated')
      label3.setText(str(rfid_1.readUid()))
      speaker.tone(1800, 200)
      rgb.setColorAll(0x33ff33)
      wait(1)
  else:
    label2.setText('Scan card')
    label3.setText('Card ID')
    wait(1)
  if (env2_0.temperature) <= 37:
    label0.setText(str(env2_0.temperature))
    rgb.setColorAll(0x33ff33)
    wait(1)
  else:
    speaker.tone(1800, 200)
    rgb.setColorAll(0xff0000)
    wait(1)
  if (tof_1.distance) < 400:
    people = (people if isinstance(people, Number) else 0) + 1
    label1.setText(str(people))
    rgb.setColorAll(0x33ff33)
    speaker.tone(1800, 200)
    wait(1)
  if people >= 300:
    rgb.setColorAll(0xff0000)
    speaker.tone(1800, 200)
    wait(1)
  if (light_1.analogValue) < 300:
    speaker.tone(1800, 200)
    lcd.setBrightness(0)
    rgb.setColorAll(0x000000)
    wait(1)
  wait_ms(2)

M5Stack 2

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

setScreenColor(0x222222)
servo_15 = unit.get(unit.SERVO, unit.PORTA)
servo_16 = unit.get(unit.SERVO, unit.PORTB)
pir_7 = unit.get(unit.PIR, unit.PORTA)






label0 = M5TextBox(139, 103, "Text", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)


while True:
  if (pir_7.state) == 1:
    label0.setText('Welcome')
    servo_15.write_angle(180)
    wait(1)
    servo_15.write_angle(0)
    wait(1)
  else:
    label0.hide()
    servo_15.write_angle(90)
    wait(1)
  if btnA.isPressed():
    servo_16.write_angle(180)
    wait(1)
  else:
    servo_16.write_angle(0)
    wait(1)
  wait_ms(2)

Credits

Irfan Rehan

Irfan Rehan

1 project • 0 followers

Comments