Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Mathi MalarchelynAnatasia TanRhian Tan
Published

Retail System

Retail crowd and security system with Stocks management system.

BeginnerFull instructions provided318
Retail System

Things used in this project

Story

Read more

Schematics

Our Video

The video gives an introduction to our project and a demo of how our system works

Flowchart for Crowd Control and Robber Alert

Flowchart for Stocks Monitoring

Block Diagram for Restocking System

Block Diagram for Crowd Control and Security Management

Our Slides

our video

The video gives an introduction to our project and a demo of how our system works

Code

RFID_ToF_Light

Python
Crowd Control and Security Management
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)
rfid_1 = unit.get(unit.RFID, unit.PAHUB1)
tof_0 = unit.get(unit.TOF, unit.PAHUB0)
light_0 = unit.get(unit.LIGHT, unit.PORTB)


people = None



label0 = M5TextBox(260, 58, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(19, 123, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label2 = M5TextBox(19, 64, "Number of people in store:", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label3 = M5TextBox(19, 12, "*********************", lcd.FONT_Comic, 0x20c8ea, rotate=0)
label4 = M5TextBox(19, 205, "**********************", lcd.FONT_Comic, 0x20c8ea, rotate=0)
label5 = M5TextBox(19, 151, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
label6 = M5TextBox(80, 107, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)


# Describe this function...
def labelshow():
  global people
  label0.setText(str(people))
  label1.setText('Store capacity: Normal.')
  label5.setText('You may enter now!')
  label0.show()
  label2.show()
  label3.show()
  label4.show()
  label5.show()
  label6.hide()

# Describe this function...
def card():
  global people
  for count in range(3):
    speaker.sing(932, 1)
    wait(0.5)
    rgb.setColorAll(0xff0000)
    wait(0.5)
    speaker.sing(932, 1)
    wait(0.5)
    rgb.setColorAll(0x000000)
    wait(0.5)

# Describe this function...
def label_hide():
  global people
  label0.hide()
  label1.hide()
  label2.hide()
  label3.hide()
  label4.hide()
  label5.hide()
  label6.show()
  label6.setText('Robber Alert!!')



people = 0
labelshow()
while True:
  if rfid_1.isCardOn():
    label_hide()
    card()
    labelshow()
  else:
    if (light_0.analogValue) < 500:
      people = people + 1
      wait(0.5)
      label0.setText(str(people))
    if (tof_0.distance) < 75:
      people = people - 1
      wait(0.5)
      label0.setText(str(people))
    if people >= 5:
      label1.setText('Store capacity: Maximum!')
      label5.setText('Please wait till someone exits')
      rgb.setColorAll(0xff6600)
    elif people < 0:
      label0.setText(str(0))
    else:
      label1.setText('Store capacity: Normal. ')
      label5.setText('You may enter now!')
      rgb.setColorAll(0x33cc00)
  wait_ms(2)

ToF_RGB_stocks

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

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


object2 = None



label1 = M5TextBox(63, 107, "Text", lcd.FONT_DejaVu24, 0x16cedd, rotate=0)




while True:
  object2 = int(((tof_0.distance) / 10))
  if object2 >= 15:
    label1.setText('LOW STOCKS')
    rgb_0.setColorAll(0xff0000)
  elif object2 > 10 and object2 < 15:
    label1.setText('MEDIUM STOCKS')
    rgb_0.setColorAll(0xffff00)
  elif object2 <= 10:
    label1.setText('HIGH STOCKS')
    rgb_0.setColorAll(0x33ff33)
  wait_ms(2)

Credits

Mathi Malar

Mathi Malar

1 project • 0 followers
chelyn

chelyn

1 project • 0 followers
Anatasia Tan

Anatasia Tan

1 project • 0 followers
Rhian Tan

Rhian Tan

0 projects • 0 followers

Comments