Jack ChngEric Zhouxin yuanchu zheng yu
Published

Grp_4_EepFinalProject

We help stores reduce food waste with RGB expiry tracking and shelf analytics for a better inventory plan.

ExpertProtipOver 4 days24
Grp_4_EepFinalProject

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×1
Mini RFID Unit RC522 Module Sensor
M5Stack Mini RFID Unit RC522 Module Sensor
×1
Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
M5Stack Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
×1
I2C Hub 1 to 6 Expansion TCA9548A Module
M5Stack I2C Hub 1 to 6 Expansion TCA9548A Module
×1

Software apps and online services

M5Stack Uiflow
This served as the primary platform for developing and programming our code.
discord
We utilized Discord for collaboration, file sharing, idea exchange, and communication through calls.
EMQX MQTT Broker
This is the MQTT broker we used to transfer our information
Node-RED
Node-RED
MQTT client with web dashboard

Hand tools and fabrication machines

Cardboard
Scissors, Free Fall
Scissors, Free Fall
Hot glue gun (generic)
Hot glue gun (generic)
Tape, Electrical
Tape, Electrical
milk bottles

Story

Read more

Code

Main M5 Stack code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
from m5mqtt import M5mqtt
from libs.json_py import *
import unit


setScreenColor(0x141414)
rfid_0 = unit.get(unit.RFID, unit.PAHUB0)
tof_2 = unit.get(unit.TOF, unit.PAHUB1)


sold = None
previousstockleft = None
stockleft = None



label0 = M5TextBox(10, 37, "Product Name:", lcd.FONT_DejaVu18, 0xb9b9b9, rotate=0)
label2 = M5TextBox(51, 59, "Text", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label3 = M5TextBox(10, 103, "Expiry Date:", lcd.FONT_DejaVu18, 0xb9b9b9, rotate=0)
label4 = M5TextBox(139, 103, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label5 = M5TextBox(10, 128, "Expiry Status:", lcd.FONT_DejaVu18, 0xb9b9b9, rotate=0)
label6 = M5TextBox(153, 128, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label7 = M5TextBox(28, 67, "Text", lcd.FONT_DejaVu24, 0xff0000, rotate=0)
label8 = M5TextBox(165, 37, "Milk", lcd.FONT_DejaVu24, 0x009cff, rotate=0)
image0 = M5Img(104, 174, "res/milk smal.jpg", True)
image1 = M5Img(126, 174, "res/milk smal.jpg", True)
image2 = M5Img(147, 174, "res/milk smal.jpg", True)
label9 = M5TextBox(28, 184, "Stock Left:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label10 = M5TextBox(28, 217, "Total Sold:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label11 = M5TextBox(230, 217, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label13 = M5TextBox(110, 217, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
title0 = M5Title(title="INVENTORY INSIGHTS", x=10, fgcolor=0x000000, bgcolor=0xff601c)

from numbers import Number




wifiCfg.doConnect('TP-Link A', '93800589@tt')
m5mqtt = M5mqtt('', 'broker.emqx.io', 1883, '', '', 300)
m5mqtt.start()
sold = 0
previousstockleft = 0
while True:
  if (rfid_0.readUid()) == '60f1d4f3d':
    label2.setText('$4.00')
    label4.setText('16/2/25')
    label0.show()
    label3.show()
    label5.show()
    label7.hide()
    label8.show()
    label9.show()
    label10.show()
    label11.show()
    label13.show()
    label6.setText('Far from Expiry')
    rgb.setColorAll(0x33ff33)
  elif (rfid_0.readUid()) == 'e0db1e4f6a':
    label2.setText('$3.00')
    label4.setText('10/2/25')
    label0.show()
    label3.show()
    label5.show()
    label7.hide()
    label8.show()
    label9.show()
    label10.show()
    label11.show()
    label13.show()
    label6.setText('Close to expiry')
    rgb.setColorAll(0xffff00)
  elif (rfid_0.readUid()) == '204144f7f':
    label2.setText('Not for Sale')
    label4.setText('6/2/25')
    label0.show()
    label3.show()
    label5.show()
    label7.hide()
    label0.show()
    label8.show()
    label9.show()
    label10.show()
    label11.show()
    label13.show()
    label6.setText('Expired')
    rgb.setColorAll(0xff0000)
  else:
    label7.setText('Scan Valid Product')
    label0.hide()
    label0.hide()
    label2.hide()
    label3.hide()
    label4.hide()
    label5.hide()
    label6.hide()
    label8.hide()
    rgb.setColorAll(0x000000)
  if (tof_2.distance) < 65:
    stockleft = 3
  elif (tof_2.distance) > 75 and (tof_2.distance) < 90:
    stockleft = 2
  elif (tof_2.distance) > 105 and (tof_2.distance) < 190:
    stockleft = 1
  elif (tof_2.distance) > 200:
    stockleft = 0
  if stockleft < previousstockleft:
    sold = (sold if isinstance(sold, Number) else 0) + 1
  if stockleft == 3:
    image0.show()
    image1.show()
    image2.show()
  elif stockleft == 2:
    image0.show()
    image1.show()
    image2.hide()
  elif stockleft == 1:
    image0.show()
    image1.hide()
    image2.hide()
  elif stockleft == 0:
    image0.hide()
    image1.hide()
    image2.hide()
  previousstockleft = stockleft
  label13.setText(str(sold))
  label11.setText(str(tof_2.distance))
  m5mqtt.publish(str('m5stack/test2'), str((py_2_json({'sold':sold}))), 0)
  m5mqtt.publish(str('m5stack/test2'), str((py_2_json({'id':(rfid_0.readUid())}))),0)
wait_ms(2)

Credits

Jack Chng
1 project • 0 followers
Eric Zhou
1 project • 1 follower
waht the sigma
xin yuan
1 project • 1 follower
chu zheng yu
1 project • 1 follower
Im a sigma

Comments