Tun Myat AungChen ken wei
Published

Tag Recorder For Cloth Retail

An automated tag recording system for cloth retailer that prevents shoplifting, and help the shop know the trendy clothes for better display

BeginnerFull instructions provided73
Tag Recorder For Cloth Retail

Things used in this project

Story

Read more

Schematics

Main M5Stack Block Diagram

Secondary M5Stack Block Diagram

Main M5Stack Flow Chart

Secondary M5Stack Flow Chart

Main M5Stack Blocky Code

Secondary M5Stack Blocky Code

Code

Main M5Stack Python Code

Python
This is to ensure the user tap the cloth tag to RFID sensor.
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
pir_1 = unit.get(unit.PIR, unit.PORTC)
servo_1 = unit.get(unit.SERVO, unit.PORTB)
pahub_1 = unit.get(unit.PAHUB, unit.PORTA)
rfid_2 = unit.get(unit.RFID, unit.PAHUB2)
rfid_3 = unit.get(unit.RFID, unit.PAHUB4)


rfid = None



label0 = M5TextBox(0, 112, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(78, 112, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)


# Describe this function...
def occupyroom():
  global rfid
  servo_1.write_angle(90)
  rgb.setColorAll(0xcc0000)
  label1.setText('The room is occupied')
  label1.show()
  label0.hide()

# Describe this function...
def occupyroom2():
  global rfid
  servo_1.write_angle(90)



while True:
  label0.setText('Please tap the tag to enter the fitting room')
  rgb.setColorAll(0x009900)
  servo_1.write_angle(0)
  label0.show()
  label1.hide()
  while True:
    if rfid_2.isCardOn():
      rfid = rfid_2.readUid()
      occupyroom()
      wait(3)
      servo_1.write_angle(0)
    if (rfid_3.readUid()) == rfid:
      servo_1.write_angle(90)
    if (pir_1.state) == 1:
      wait(3)
      rgb.setColorAll(0x009900)
      label1.setText('Please tap the tag to enter the fitting room')
      label0.show()
      label1.hide()
      servo_1.write_angle(0)
    wait_ms(2)
  wait_ms(2)

Secondary M5Stack Python Code

Python
This is the secondary M5Stack to ask the user to tap the cloth tag to second RFID sensor.
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
rgb_7 = unit.get(unit.RGB, unit.PORTB)
tof_9 = unit.get(unit.TOF, unit.PORTA)


tof = None



label1 = M5TextBox(0, 43, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
triangle0 = M5Triangle(68, 226, 37, 194, 97, 194, 0xb84242, 0x000000)
label2 = M5TextBox(22, 133, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(95, 151, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label0 = M5TextBox(15, 18, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)


# Describe this function...
def saveenergy():
  global tof
  tof = int((tof_9.distance)) / 10
  if tof < 12:
    rgb_7.setBrightness(20)
    rgb_7.setColorFrom(1, 3, 0xffffff)
  else:
    rgb_7.setBrightness(1)
    rgb_7.setColorFrom(1, 3, 0xffffff)


def buttonA_wasPressed():
  global tof
  speaker.tone(1800, 1000)
  pass
btnA.wasPressed(buttonA_wasPressed)


while True:
  label0.setText('Please tap the cloth tag to  ')
  label1.setText('reader on left to open the door')
  label2.setText('*Press this button to beep a buzzer')
  label3.setText('for assistance')
  while True:
    saveenergy()
    wait_ms(2)
  wait_ms(2)

Credits

Tun Myat Aung
1 project • 0 followers
Chen ken wei
1 project • 0 followers

Comments