Smart Shopping Cart (Curbing Cart Chaos)

What we hope to achieve is to reduce the number of carts being littered/abandoned around Singapore.

BeginnerWork in progress114
Smart Shopping Cart (Curbing Cart Chaos)

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
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

M5Stack UI Flow

Story

Read more

Schematics

Block Diagram

File missing, please reupload.

Code

Main M5Stack Code

Python
For the main application of the M5stack Fire.
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0xd1d1d1)
rfid_0 = unit.get(unit.RFID, unit.PORTA)
servo_0 = unit.get(unit.SERVO, unit.PORTB)


Card = None
Lock = None
LSec = None
Secs = None
ReadCard = None
LSec10 = None
Secs1_10 = None
LSec100 = None
Secs1_100 = None



label0 = M5TextBox(50, 107, "Please Scan Card", lcd.FONT_DejaVu24, 0xff0000, rotate=0)
title0 = M5Title(title="Welcome to C-Arty", x=100, fgcolor=0xFFFFFF, bgcolor=0x1e9500)
rectangle0 = M5Rect(194, 31, 100, 25, 0xFFFFFF, 0x108e00)
label2 = M5TextBox(50, 137, "Text", lcd.FONT_Default, 0x000000, rotate=0)
Timer = M5TextBox(200, 38, "Time:", lcd.FONT_Default, 0x000000, rotate=0)
label3 = M5TextBox(56, 219, "End", lcd.FONT_Default, 0x000000, rotate=0)
Sec = M5TextBox(238, 38, "00", lcd.FONT_Default, 0x000000, rotate=0)
Sec10 = M5TextBox(256, 38, "00", lcd.FONT_Default, 0x000000, rotate=0)
Sec100 = M5TextBox(273, 38, "00", lcd.FONT_Default, 0x000000, rotate=0)
label1 = M5TextBox(143, 219, "Time", lcd.FONT_Default, 0x000000, rotate=0)
label4 = M5TextBox(88, 137, "Text", lcd.FONT_Default, 0x000000, rotate=0)
label5 = M5TextBox(126, 137, "Text", lcd.FONT_Default, 0x000000, rotate=0)

from numbers import Number



def buttonA_wasReleased():
  global Card, Lock, LSec, Secs, ReadCard, LSec10, Secs1_10, LSec100, Secs1_100
  label0.setText('To Lock Scan Card')
  wait(5)
  while (rfid_0.isCardOn()) and Lock == 1:
    Lock = 0
    ReadCard = rfid_0.readUid()
    label0.setText('Processing...')
    rgb.setColorAll(0xffff00)
    wait(1)
    if ReadCard == Card:
      wait(1)
      label0.setText('Thanks For Shopping')
      speaker.tone(400, 200)
      rgb.setColorAll(0x33ff33)
      servo_0.write_angle(0)
      LSec = Secs
      LSec10 = Secs1_10
      LSec100 = Secs1_100
      break
    else:
      wait(1)
      label0.setText('Scan Same Card')
      speaker.tone(200, 200)
      rgb.setColorAll(0xffff00)
  pass
btnA.wasReleased(buttonA_wasReleased)

def buttonB_wasReleased():
  global Card, Lock, LSec, Secs, ReadCard, LSec10, Secs1_10, LSec100, Secs1_100
  label4.show()
  label5.show()
  label2.setText(str(LSec))
  label4.setText(str(LSec10))
  label5.setText(str(LSec100))
  wait(10)
  label4.hide()
  label5.hide()
  pass
btnB.wasReleased(buttonB_wasReleased)


servo_0.write_angle(0)
Card = '5213fc11ac'
Lock = 0
Secs = 0
Secs1_10 = 0
Secs1_100 = 0
label4.hide()
label5.hide()
while True:
  if Secs1_100 >= 59:
    Secs1_10 = (Secs1_10 if isinstance(Secs1_10, Number) else 0) + 1
    Secs1_100 = -1
    if Secs1_10 >= 59:
      Secs = (Secs if isinstance(Secs, Number) else 0) + 1
      Secs1_10 = 0
  wait(1)
  Secs1_100 = (Secs1_100 if isinstance(Secs1_100, Number) else 0) + 1
  Sec.setText(str(Secs))
  Sec10.setText(str(Secs1_10))
  Sec100.setText(str(Secs1_100))
  if (rfid_0.isCardOn()) and Lock == 0:
    Lock = 1
    ReadCard = rfid_0.readUid()
    rgb.setColorAll(0xffff00)
    label2.setText(str(rfid_0.readUid()))
    label0.setText('Processing...')
    if ReadCard == Card:
      wait(1)
      label0.setText('Unlocked')
      rgb.setColorAll(0x33ff33)
      speaker.tone(400, 200)
      wait(1)
      servo_0.write_angle(90)
      label0.setText('Enjoy Shopping!')
    else:
      wait(1)
      label0.setText('Scan Same Card')
      rgb.setColorAll(0xff0000)
      speaker.tone(200, 200)
  wait_ms(2)

Credits

Yong Xiang Teo

Yong Xiang Teo

1 project • 0 followers
Joel Chan

Joel Chan

2 projects • 0 followers
Naufal Hafiy(NYPPPP)

Naufal Hafiy(NYPPPP)

1 project • 0 followers
Gabnjw05 (NYP)

Gabnjw05 (NYP)

1 project • 0 followers

Comments