Maker.io main logo

Smart Retail record products stocks

2023-02-08 | By M5Stack

License: General Public License Bluetooth / BLE Wifi Arduino

* Thanks for the source code and project information provided by @Ray Xiang

 

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit (PSRAM 2.0) x 1

M5Stack Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/) × 1

M5Stack I2C Hub 1 to 6 Expansion TCA9548A Module ×1

M5Stack RGB Unit with NeoPixel RGB LED (SK6812) × 1

M5Stack Mini RFID Unit RC522 Module Sensor × 1

 

Story
 
 
 
 
FlowChart

 

22

 

Block Diagrams

11

Code

Python

Copy Code
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
rgb_0 = unit.get(unit.RGB, unit.PORTB)
tof_0 = unit.get(unit.TOF, unit.PAHUB5)
rfid_0 = unit.get(unit.RFID, unit.PAHUB0)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)


Detector1 = None



label0 = M5TextBox(24, 14, "Text", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
label1 = M5TextBox(132, 16, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label2 = M5TextBox(76, 128, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)




while True:
Detector1 = tof_0.distance
label0.setText(str(tof_0.distance))
if Detector1 <= 50:
label1.setText('Stock is full')
rgb_0.setColorAll(0x33cc00)
elif Detector1 < 50 and Detector1 <= 70:
label1.setText('Stock level is high')
rgb_0.setColorAll(0xffff00)
elif Detector1 > 70 and Detector1 <= 150:
label1.setText('Stock level is moderate')
rgb_0.setColorAll(0xcc9933)
elif Detector1 > 200:
label1.setText('Stock level is low')
rgb_0.setColorAll(0xcc0000)
speaker.tone(1800, 200)
else:
label1.setText('No stock detected')
if rfid_0.isCardOn():
rgb.setColorAll(0x33cc00)
wait(1)
if (rfid_0.readUid()) == '8ada8b53':
label0.setText('Hi There!')
label1.setText(str(rfid_0.readUid()))
speaker.tone(1800, 200)
wait(0.25)
else:
label2.setText('Please scan your card ID')
rgb.setColorAll(0x000000)
wait_ms(2)
Mfr Part # K007-V26
DEV KIT FIRE IOT PSRAM V2.6
M5Stack Technology Co., Ltd.
More Info
View More Details
Mfr Part # U010
TIME-OF-FLIGHT UNIT VL53L0X
M5Stack Technology Co., Ltd.
More Info
View More Details
Mfr Part # U040-B
I2C HUB 1 ~ 6 EXPANSION PCA9548A
M5Stack Technology Co., Ltd.
More Info
View More Details
Mfr Part # U003
RGB LED UNIT (SK6812)
M5Stack Technology Co., Ltd.
More Info
View More Details
Mfr Part # U031-B
MINI RFID UNIT 2 WS1850S
M5Stack Technology Co., Ltd.
More Info
View More Details
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.