Xandra Ongjia xuanShane Tan
Published

EcoSmart Retail

Our aim is to reduce waste, save energy, and promote sustainability with smart inventory, lighting, and e-receipts.

BeginnerFull instructions provided51
EcoSmart Retail

Things used in this project

Story

Read more

Schematics

Circuit Diagram

Code

M5 stack code

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

setScreenColor(0x222222)
tof_3 = unit.get(unit.TOF, unit.PAHUB0)
pir_0 = unit.get(unit.PIR, unit.PORTC)
rfid_0 = unit.get(unit.RFID, unit.PAHUB1)
pahub_1 = unit.get(unit.PAHUB, unit.PORTA)


stock = None



label0 = M5TextBox(90, 66, "stock ", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label1 = M5TextBox(288, -121, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(21, 19, "Distance:          cm", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label3 = M5TextBox(162, 19, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label4 = M5TextBox(112, 159, "Receipt", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label5 = M5TextBox(134, 202, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label6 = M5TextBox(50, 118, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)




while True:
  stock = int(((tof_3.distance) / 10))
  label3.setText(str(stock))
  if stock <= 15:
    label0.setText('sufficient stock')
  elif stock > 15:
    label0.setText('low stock')
  if rfid_0.isCardOn():
    label4.setText('Receipt:')
    label6.setText('Successful Payment')
    if (rfid_0.readUid()) == 'd0ff4f9f':
      label5.setText('$4')
    if (rfid_0.readUid()) == '7096234f8a':
      label5.setText('$10')
  else:
    label5.setText('')
    label4.setText('')
    label6.setText('tap card to pay')
  if (pir_0.state) == 1:
    rgb.setColorAll(0xffffff)
  else:
    rgb.setColorAll(0x000000)
  wait_ms(2)

Credits

Xandra Ong
1 project • 0 followers
jia xuan
1 project • 0 followers
Shane Tan
1 project • 0 followers

Comments