Payment Detecting Smart Shelf
2022-02-24 | By M5Stack
License: General Public License
* Thanks for the source code and project information provided by @Team 1: Tiffany Sim, Mr kang, Marcus211348n
This project is about preventing theft and maximizing staff's attention to providing good customer service. As luxury larceny is on the rise, we decided to create a smart shelf which can retain items by sounding an alarm to alert staff of any potential crime. This will deter thieves effectively.
Video Presentation
Schematics
Circuit Diagram
Code
{"components":[{"id":"____screen","createTime":1637469804846,"name":"screen","x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","backgroundImage":"","type":"screen"},{"id":"____buttonA","createTime":1637469804846,"name":"ButtonA","buttonIndex":0,"x":35,"y":216,"width":64,"height":24,"text":"ButtonA","visibility":false,"type":"button"},{"id":"____buttonB","createTime":1637469804846,"name":"ButtonB","buttonIndex":1,"x":125,"y":216,"width":64,"height":24,"text":"ButtonB","visibility":false,"type":"button"},{"id":"____buttonC","createTime":1637469804846,"name":"ButtonC","buttonIndex":2,"x":215,"y":216,"width":64,"height":24,"text":"ButtonC","visibility":false,"type":"button"},{"id":"mDnXEh@-0d5`7$%b","createTime":1637469931845,"isCoreTwo":false,"isPaper":false,"name":"label0","x":40,"y":107,"color":"#FFFFFF","text":"Text","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":4},{"id":"jL$`55OaJb7m0Okz","createTime":1642473786259,"isCoreTwo":false,"isPaper":false,"name":"label1","x":129,"y":50,"color":"#FFFFFF","text":"Text","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":16}],"type":"fire","versions":"Beta","units":[{"id":"rU8J8sF%mF6UQEvr","createTime":1643863992408,"type":"rfid","name":"rfid0","port":"PAHUB","default":["A","E","PAHUB","Custom"],"pb_port":[0,1,2,3,4,5],"new_pb_port":"0","user_port":["21","22"],"icon":"rfid.png","new_port":"PAHUB","new_default":["A","E","PAHUB","Custom"]},{"id":"#2*ozqDsFC05Iofn","createTime":1643863992408,"type":"pahub","name":"pahub1","port":"A","default":["A","E","Custom"],"user_port":["21","22"],"icon":"pa_hub.png"},{"id":"I%*ergL%Yd73zQ3N","createTime":1643863992409,"stickNone":"stick","type":"tof","name":"tof1","port":"PAHUB","default":["A","E","PAHUB","Custom"],"pb_port":[0,1,2,3,4,5],"new_pb_port":"1","user_port":["21","22"],"icon":"tof.png"},{"id":"v!1ic*QB$3ZAH+CO","createTime":1643863992409,"type":"pir","name":"pir3","port":"B","default":["A","B","E","Custom"],"user_port":["21","22"],"icon":"pir.png","new_port":"B","new_default":["A","B","E","Custom"]}],"hats":[],"blockly":"<variables><variable id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"250\" y=\"190\"><next><block type=\"basic_on_loop\" id=\"6$3S[C~xU+cFB|m7ukO6\"><statement name=\"LOOP\"><block type=\"label_set_text\" id=\"wX!JlPt|8[Zm0{8VubBS\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"!zWrhF}A${wO-U-``*:[\"><field name=\"TEXT\">Please Scan your card</field></shadow></value><next><block type=\"rgb_set_all\" id=\"R{V%|}MY0#*Ly,!ol;T)\"><field name=\"COLOR\">#3366ff</field><next><block type=\"variables_set\" id=\";@fF~e]sK`C:AaY+uh*]\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field><value name=\"VALUE\"><block type=\"convent_int\" id=\"2QSDa[D4n+jltWj{O]|M\"><value name=\"VALUE\"><block type=\"math_arithmetic\" id=\"9ULtRs5cGb/5N!(pC`l3\"><field name=\"OP\">DIVIDE</field><value name=\"A\"><block type=\"unit_tof_state\" id=\"5?2MnanYQlj5/Czbq;^o\"><field name=\"TOF\">tof1</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"Xkx^0-VA0~]0_U-Slnm^\"><field name=\"NUM\">5</field></block></value></block></value></block></value><next><block type=\"controls_repeat\" id=\"uEh=0=(;V{+M1(]yV|2w\"><field name=\"TIMES\">1</field><statement name=\"DO\"><block type=\"controls_if\" id=\"jBgr_Y_a_}Rcn]%bIL%g\"><mutation elseif=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\":Hyu1}NC[r55e{wH(`k;\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"variables_get\" id=\"H_Vj=G10{j-yC8w7bUz-\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"``zWq%Y=:Yukm/+X}0[;\"><field name=\"NUM\">15</field></block></value></block></value><statement name=\"DO0\"><block type=\"label_set_text\" id=\"P%#Qua7BHOg9imeh]%n=\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\" id=\"F)b{xSq??!L9:bV;*qmb\"><field name=\"TEXT\">Please Scan your card</field></shadow><block type=\"variables_get\" id=\"o[cjM/nBIh1pce6v2$%=\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field></block></value><next><block type=\"label_set_text\" id=\"7WcQ!/%:IG`dvS@XQK/!\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"NXkle�+2mpRpm3M#`o\"><field name=\"TEXT\">Please put back the item!</field></shadow></value><next><block type=\"speaker_tone\" id=\"{X]ti2[#Sn|8p,VmXypV\"><value name=\"FREQ\"><shadow type=\"math_number\" id=\"MYFVT7WC]+hDAJa1LF(r\"><field name=\"NUM\">1800</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"9D|ozKqkssoM9vsn}B]$\"><field name=\"NUM\">200</field></shadow></value><next><block type=\"rgb_set_all\" id=\"0kx35]F~P(w3c:.Jr=p%\"><field name=\"COLOR\">#ff0000</field><next><block type=\"timer_delay\" id=\"xeMNe#oL(G~~UGnvSQH.\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"Ms,NkP;G||7zg:JPJP]M\"><field name=\"NUM\">2</field></shadow></value></block></next></block></next></block></next></block></next></block></statement><value name=\"IF1\"><block type=\"logic_compare\" id=\"g0KyWd6D+WS#M}f|,*[z\"><field name=\"OP\">LT</field><value name=\"A\"><block type=\"variables_get\" id=\"Zmhok!56p4cv*cj=qX3s\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"Rx{6aS6pl0S.QffGn~Uh\"><field name=\"NUM\">15</field></block></value></block></value><statement name=\"DO1\"><block type=\"label_set_text\" id=\"X(#/g}`mP`31=3w:efdx\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\"><field name=\"TEXT\">Please Scan your card</field></shadow><block type=\"variables_get\" id=\"f4Q6S$;D03Ofq}3WQ_#f\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field></block></value><next><block type=\"rgb_set_all\" id=\"a=s{,*$EgUW5V~N22ICj\"><field name=\"COLOR\">#3366ff</field></block></next></block></statement><next><block type=\"controls_ifelse\" id=\"GW2.PAu[OdnwP3FzJ}=M\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"e(64H/z)$c`M-KFzEl(R\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"pir_read\" id=\"YV~:61jXV1/Z71DcX,~s\"><field name=\"VARNAME\">pir3</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"aNuUs1C|yu~Y,F%[R~*_\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"label_set_text\" id=\"[+9=J/cQ{?r6m?_BxbgL\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\"><field name=\"TEXT\">Please Scan your card</field></shadow><block type=\"variables_get\" id=\"k*/YVNkHDe(6j@n/X+Ez\"><field name=\"VAR\" id=\"%!}-);?`6YF0/`q`%Sb=\">item_distance</field></block></value><next><block type=\"label_set_text\" id=\"7j^_hE#HcI7BWk}L7g;z\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"5^[f9}Bxf@S@-|ZZJw(y\"><field name=\"TEXT\">Please put back the item!</field></shadow></value><next><block type=\"speaker_tone\" id=\"`TrZlP{SIkwW^Bi:CFrL\"><value name=\"FREQ\"><shadow type=\"math_number\" id=\"c?I0E{IDb{vk@H#(tSBn\"><field name=\"NUM\">1800</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"l.a0pzd$~kE`W[!.!^/?\"><field name=\"NUM\">200</field></shadow></value><next><block type=\"rgb_set_all\" id=\"5w7WF$dDf@1Yp%1#+|Q_\"><field name=\"COLOR\">#ff0000</field><next><block type=\"timer_delay\" id=\"t7o49_JJ,g*aC#d5rjK7\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"_becI-/L/LaejCZgRXe]\"><field name=\"NUM\">0.5</field></shadow></value></block></next></block></next></block></next></block></next></block></statement></block></next></block></statement><next><block type=\"controls_if\" id=\"G3T[m4`soQhA|f(:9�\"><value name=\"IF0\"><block type=\"rfid_cardOn\" id=\"xb#W=^e7]U+*;/3IvfgE\"><field name=\"RFID\">rfid0</field></block></value><statement name=\"DO0\"><block type=\"controls_ifelse\" id=\"t^Uk/FsDGy6u_]K?[9yy\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"u]?ZR8L~dc3u[phP:}@.\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"rfid_uid\" id=\"Xq);Op3mA5?f8GitUh65\"><field name=\"RFID\">rfid0</field></block></value><value name=\"B\"><block type=\"text\" id=\"kTe)[eKDm]HFhk$ZF6]B\"><field name=\"TEXT\">d08f3ca69</field></block></value></block></value><statement name=\"DO0\"><block type=\"label_set_text\" id=\"b`un?Vwx.#a[__a`:KA1\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"b%s/{Zr3ip}ZLWhxY,}:\"><field name=\"TEXT\">Payment Successful</field></shadow></value><next><block type=\"speaker_tone\" id=\"5U3/lv!oRW(|:%Vx8bf@\"><value name=\"FREQ\"><shadow type=\"math_number\" id=\"/g2)9^{=x=+cg:Tk}V6u\"><field name=\"NUM\">1800</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"cTK+wOV@96f:%%d=cASR\"><field name=\"NUM\">200</field></shadow></value><next><block type=\"rgb_set_all\" id=\"=LccE+q+C{u}*AiL0HGN\"><field name=\"COLOR\">#33ff33</field><next><block type=\"timer_delay\" id=\"8Qg9vH`+0aCW#MMfxizu\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"nLIYr?H?%Ys_SKnVHRQ}\"><field name=\"NUM\">2</field></shadow></value><next><block type=\"rgb_set_all\" id=\"EMr]EtUe;rbyt%.#u:Wi\"><field name=\"COLOR\">#000000</field><next><block type=\"label_set_text\" id=\"gw;QWL=;rPX�wzW8wx\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"Z-~pzOYs78#A2ZpeuOrZ\"><field name=\"TEXT\">Please wait for fill in </field></shadow></value><next><block type=\"timer_delay\" id=\"7@R5.KLqMYLvDJ%+~8FY\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"uQN^VkL1}_/nu@x|SW01\"><field name=\"NUM\">20</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"controls_if\" id=\"zx9oOz!Kuv5Nxf*vl0sD\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"|45tOyQDg4v4:VZOljp#\"><field name=\"OP\">NEQ</field><value name=\"A\"><block type=\"rfid_uid\" id=\"v4D,Qj@1[7(~eF=45D@J\"><field name=\"RFID\">rfid0</field></block></value><value name=\"B\"><block type=\"text\" id=\"EzaXYh.n=z9sJySU4a:=\"><field name=\"TEXT\">d08f3ca69</field></block></value></block></value><statement name=\"DO0\"><block type=\"label_set_text\" id=\"VU:HZ)]CVA+5pJ1,xT{I\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\"><field name=\"TEXT\">Payment Successful</field></shadow><block type=\"rfid_uid\" id=\"a~Gp?J)1H$xI5QACL8\"><field name=\"RFID\">rfid0</field></block></value><next><block type=\"label_set_text\" id=\"S#d[H4KYE]5UqNE+m3)J\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"[4a!h9Aj9}z*8]nw3qZ9\"><field name=\"TEXT\">Payment Failed</field></shadow></value><next><block type=\"rgb_set_all\" id=\"h~8eD9z^c!}RhFhstkqK\"><field name=\"COLOR\">#ff0000</field><next><block type=\"speaker_tone\" id=\"l/!VyH76WwkE;$b+zXN(\"><value name=\"FREQ\"><shadow type=\"math_number\" id=\"b*Ryj$?rR%vDODb2^0Yd\"><field name=\"NUM\">1800</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"Jd5K2H;Nz{uImr._QD1t\"><field name=\"NUM\">200</field></shadow></value><next><block type=\"timer_delay\" id=\"[itZ{z}93jd;%b^AH5YC\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"0NP#]o;4SUz)))|ay}]D\"><field name=\"NUM\">2</field></shadow></value></block></next></block></next></block></next></block></next></block></statement></block></statement></block></statement></block></next></block></next></block></next></block></next></block></statement></block></next></block>","Blockly.Remotes":[],"modules":["rgb"]}
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum