Mcn0b
Created February 6, 2024

Smart Retail Entry Tracker

(Very) Simple Circuit that can be modified to allow specific or any card to gain access to shops, while tracking entry counts.

BeginnerShowcase (no instructions)1 hour6
Smart Retail Entry Tracker

Things used in this project

Story

Read more

Code

M5stack code

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

setScreenColor(0x222222)
pir_0 = unit.get(unit.PIR, unit.PORTB)
rfid_0 = unit.get(unit.RFID, unit.PORTA)


v_count = None
c_reads = None
detect_c = None
detect = None
status = None



label0 = M5TextBox(80, 46, "Visitor Count", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(189, 46, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(80, 99, "Card Reads", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(80, 147, "Entry Status", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(186, 100, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(184, 147, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number




v_count = 0
c_reads = 0
detect_c = False
detect = False
status = str('Denied')
label1.setText(str(v_count))
label4.setText(str(c_reads))
label5.setText(str(status))
while True:
  if detect_c == 0 and (rfid_0.isCardOn()) == True:
    c_reads = (c_reads if isinstance(c_reads, Number) else 0) + 1
    status = 'Allowed'
    rgb.setColorAll(0x33ff33)
    detect_c = rfid_0.isCardOn()
  else:
    detect_c = rfid_0.isCardOn()
  if detect == 0 and (pir_0.state) == 1:
    if status == 'Denied':
      detect = pir_0.state
      speaker.tone(1800, 200)
      rgb.setColorAll(0xffcc00)
    else:
      v_count = (v_count if isinstance(v_count, Number) else 0) + 1
      detect = pir_0.state
      status = 'Denied'
  else:
    detect = pir_0.state
  if status == 'Denied':
    rgb.setColorAll(0xff0000)
  label1.setText(str(v_count))
  label6.setText(str(detect))
  label4.setText(str(c_reads))
  label5.setText(str(status))
  wait_ms(2)

Credits

Mcn0b

Mcn0b

0 projects • 0 followers

Comments