Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Bradley SohJadonHoωєиѕ 08lennon
Published

Smart counter

This program is able to keep count of how many people are inside a building currently, and how many people visited the building on that day.

BeginnerFull instructions provided1 hour391
Smart counter

Things used in this project

Hardware components

RFID reader (generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×1

Story

Read more

Code

Smart counter code

Python
Using the uiflow app associated with the M5stack, you can program the M5stack to do a ton of things.
{"components":[{"id":"____screen","createTime":1638928471525,"name":"screen","x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","backgroundImage":"","type":"screen"},{"id":"____buttonA","createTime":1638928471525,"name":"ButtonA","buttonIndex":0,"x":35,"y":216,"width":64,"height":24,"text":"ButtonA","visibility":false,"type":"button"},{"id":"____buttonB","createTime":1638928471525,"name":"ButtonB","buttonIndex":1,"x":125,"y":216,"width":64,"height":24,"text":"ButtonB","visibility":false,"type":"button"},{"id":"____buttonC","createTime":1638928471525,"name":"ButtonC","buttonIndex":2,"x":215,"y":216,"width":64,"height":24,"text":"ButtonC","visibility":false,"type":"button"},{"id":"Eeacl98!U8kM&RUx","createTime":1638928630977,"isCoreTwo":false,"isPaper":false,"name":"Peopletext","x":6,"y":17,"color":"#FFFFFF","text":"People Inside:","font":"lcd.FONT_DejaVu24","rotation":0,"type":"label","layer":4},{"id":"RzJOZIsWk&RQko6k","createTime":1638928656495,"isCoreTwo":false,"isPaper":false,"name":"Peoplecounter","x":240,"y":17,"color":"#FFFFFF","text":"Text","font":"lcd.FONT_DejaVu18","rotation":0,"type":"label","layer":5},{"id":"@8JCZz3jP4&X5#lf","createTime":1638929239088,"isCoreTwo":false,"isPaper":false,"name":"Customer","x":26,"y":73,"color":"#FFFFFF","text":"A customer just left !","font":"lcd.FONT_DejaVu24","rotation":0,"type":"label","layer":6},{"id":"ZfI3j3ZrF_VugrMt","createTime":1638932026195,"isCoreTwo":false,"isPaper":false,"name":"Max_people","x":32,"y":133,"color":"#FFFFFF","text":"Sorry the venue is at max capacity !","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":7},{"id":"rAaXdn`J`Y*Hq1H6","createTime":1641954026044,"isCoreTwo":false,"isPaper":false,"name":"label0","x":15,"y":189,"color":"#FFFFFF","text":"Total People:","font":"lcd.FONT_DejaVu24","rotation":0,"type":"label","layer":28},{"id":"@-p2ZcrBgwdQz4gm","createTime":1643186357232,"isCoreTwo":false,"isPaper":false,"name":"label1","x":240,"y":189,"color":"#FFFFFF","text":"Text","font":"lcd.FONT_DejaVu18","rotation":0,"type":"label","layer":17,"width":null,"height":null,"radius":null},{"id":"7GJlIFhYxhxnY2c6","createTime":1643191347884,"isCoreTwo":false,"isPaper":false,"name":"label2","x":32,"y":153,"color":"#FFFFFF","text":"No people inside at the moment","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":19,"width":null,"height":null,"radius":null}],"type":"fire","versions":"Beta","units":[{"id":"xQNBsa-&mfl_5KY`","createTime":1643185964350,"type":"pir","name":"pir0","port":"B","default":["A","B","E","Custom"],"user_port":["21","22"],"icon":"pir.png","new_port":"B","new_default":["A","B","E","Custom"]},{"id":"ypX$K7VM9zN-Q^@r","createTime":1643185964350,"type":"rfid","name":"rfid0","port":"A","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":"A","new_default":["A","E","PAHUB","Custom"]}],"hats":[],"blockly":"<variables><variable id=\"oiUDg,f!9%UK=GUjIycP\">Total</variable><variable id=\"E%E~D1y5uYu)5TboB5?P\">People</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"350\" y=\"-70\"><next><block type=\"label_set_mode\" id=\"y,d.zVqR,kD7r(K``/)x\"><field name=\"COMPONENT\">Max_people</field><field name=\"MODE\">hide</field><next><block type=\"rgb_set_all\" id=\"9LR[rctvK^DhM51Wq`0M\"><field name=\"COLOR\">#000000</field><next><block type=\"label_set_mode\" id=\"#iLHW;]O_WmW*9N:)*qH\"><field name=\"COMPONENT\">Customer</field><field name=\"MODE\">hide</field><next><block type=\"label_set_mode\" id=\"Xns{S@*2mi:livnY`RgU\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">hide</field><next><block type=\"variables_set\" id=\"N1J/mxM6{p_sx8h]YMDi\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field><value name=\"VALUE\"><block type=\"math_number\" id=\"C3c|p~m(R},85zq!IyC6\"><field name=\"NUM\">0</field></block></value><next><block type=\"variables_set\" id=\"s7/+El0^[Wk6I}7$]~],\"><field name=\"VAR\" id=\"oiUDg,f!9%UK=GUjIycP\">Total</field><value name=\"VALUE\"><block type=\"math_number\" id=\"rR;`8!$}1Z1)[`n[=:i}\"><field name=\"NUM\">0</field></block></value><next><block type=\"basic_on_loop\" id=\"U!=mpT[g:3Tr!)#g$IWF\"><statement name=\"LOOP\"><block type=\"procedures_callnoreturn\" id=\"oh1{?;fZ=.nDjx1UiA1a\"><mutation name=\"dosomething\"></mutation><next><block type=\"controls_if\" id=\"^jYI#zvsi8Fj0kq_p+d5\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"yW/x%^S?*x0,M{IY_e#4\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"pir_read\" id=\"tQNSL:kQW*b|3hxGJfM]\"><field name=\"VARNAME\">pir0</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"jLXFCI8oH,]Q~mE.tBy0\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"controls_if\" id=\"^+J^dqsbfDnJ#hU=l1e!\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"o$%tGbtYigOj3o|X)3=%\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"variables_get\" id=\".^n)2$C]9,ii85O%ikaq\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field></block></value><value name=\"B\"><block type=\"math_number\" id=\";gyCy(-]dzd#yM73xFoK\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"rgb_set_all\" id=\"2c5VZt(DSIR%)0+mk3gY\"><field name=\"COLOR\">#ff6600</field><next><block type=\"timer_delay\" id=\"i/.xOoy;MJDO)0FrYJ|k\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"z|,ZkWVyqVJ?AZZ]DE$[\"><field name=\"NUM\">2</field></shadow></value><next><block type=\"label_set_mode\" id=\"H2ftUC2*y;YZTe.Q61,T\"><field name=\"COMPONENT\">Customer</field><field name=\"MODE\">show</field><next><block type=\"math_change\" id=\"^Q=#*4zP{VrlIm/#w-!g\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field><value name=\"DELTA\"><shadow type=\"math_number\" id=\"(Y]V4b6-N*o#eY(U,xEx\"><field name=\"NUM\">-1</field></shadow></value><next><block type=\"rgb_set_all\" id=\"#ABNNWPOsnthh4}RYJ)B\"><field name=\"COLOR\">#33ff33</field><next><block type=\"label_set_text\" id=\"m8G1IFq!Ozk/ak7Khtb-\"><field name=\"COMPONENT\">Peoplecounter</field><value name=\"TEXT\"><shadow type=\"text\" id=\"$0bx(w8LKhR^+t|Rqc6y\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"mkTjE?gTdz12#{OQEbO@\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field></block></value><next><block type=\"timer_delay\" id=\"CQDk+k7ZbiY(I!1b~%E#\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"dATx[yp;.X[[DK^=RCR.\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"label_set_mode\" id=\"_{i,{FFTm77MzdOJe?);\"><field name=\"COMPONENT\">Customer</field><field name=\"MODE\">hide</field><next><block type=\"rgb_set_all\" id=\"|`4LeHvVU`m[BD2[sFsL\"><field name=\"COLOR\">#000000</field></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"label_set_mode\" id=\"zhe4!}~,y*J[YH%uOsRv\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">show</field><next><block type=\"rgb_set_all\" id=\"pPKt@y7_Lf5WC?QJWI(c\"><field name=\"COLOR\">#ff0000</field></block></next></block></statement></block></statement></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type=\"procedures_defnoreturn\" id=\"-O7WipN$5D%S_v3jSB73\" x=\"-130\" y=\"90\"><field name=\"NAME\">dosomething</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"controls_if\" id=\"tv5p|sTTWPu5y~7A:hGA\"><value name=\"IF0\"><block type=\"rfid_cardOn\" id=\"-_c=efJQICGrP@Zmo{gH\"><field name=\"RFID\">rfid0</field></block></value><statement name=\"DO0\"><block type=\"speaker_tone\" id=\"1okJMv0zho;O:IhA:FVj\"><value name=\"FREQ\"><shadow type=\"math_number\" id=\"%8}#vfZUh3FRS6LLFy~j\"><field name=\"NUM\">1800</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"U[MRx3CkGQ#Y}!l!?RI;\"><field name=\"NUM\">50</field></shadow></value><next><block type=\"math_change\" id=\"bp,trs`ljrzsh1*rMsRD\"><field name=\"VAR\" id=\"oiUDg,f!9%UK=GUjIycP\">Total</field><value name=\"DELTA\"><shadow type=\"math_number\" id=\"wY%MjIz,C$U.qS%}l/w1\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"controls_if\" id=\"wU7x?_41)-|Sbi.s?$Ew\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"wyUsXr)xbq0ggnO:MucK\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get\" id=\"46:yP?|U5G.gge2:Txf1\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"TeRY;+)r6_t/`A*~eJ$9\"><field name=\"NUM\">5</field></block></value></block></value><statement name=\"DO0\"><block type=\"label_set_mode\" id=\"aEW]#9PCXN-CA1of)qEf\"><field name=\"COMPONENT\">Max_people</field><field name=\"MODE\">show</field><next><block type=\"rgb_set_all\" id=\"*3rqbkXF5]%WGpR+PxBp\"><field name=\"COLOR\">#ff0000</field><next><block type=\"timer_delay\" id=\"adV%_Zq}EF*(UF;H]Fe|\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"c.BOw_TlK=Iz,#Mtb63y\"><field name=\"NUM\">2</field></shadow></value><next><block type=\"rgb_set_all\" id=\"/5`SbqWR|SLp3;#lu_g^\"><field name=\"COLOR\">#000000</field><next><block type=\"label_set_mode\" id=\"@QEbjQ@cpRU#I[0V-z:u\"><field name=\"COMPONENT\">Max_people</field><field name=\"MODE\">hide</field></block></next></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"label_set_mode\" id=\"2~bA#(XSUIL.OL6c@?,v\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">hide</field><next><block type=\"rgb_set_all\" id=\"ZOvI3YEgj^JguO9Gtd?^\"><field name=\"COLOR\">#33ff33</field><next><block type=\"math_change\" id=\"=oA6W%M$daqT84_w,}v?\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field><value name=\"DELTA\"><shadow type=\"math_number\" id=\":0d5(BQ|$X|BCS{v[]ej\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"label_set_text\" id=\"$7ekQs@*jjuZV;o]D$B3\"><field name=\"COMPONENT\">Peoplecounter</field><value name=\"TEXT\"><shadow type=\"text\" id=\"^~,=l%x~8D*{!djm6sH%\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"81~h?]:1ICsgkMNoxXyY\"><field name=\"VAR\" id=\"E%E~D1y5uYu)5TboB5?P\">People</field></block></value><next><block type=\"label_set_text\" id=\"8cg]!EvZ.68}oC{8EB(s\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"C*tGa4Uc[~~oL6/Zeoqs\"><field name=\"VAR\" id=\"oiUDg,f!9%UK=GUjIycP\">Total</field></block></value><next><block type=\"timer_delay\" id=\"55B;(9,)-Z3bZ3?UPtI,\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"O(95R|Cm=_BFCr5E7^8-\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"rgb_set_all\" id=\"lYbO#ySbuNw5T%eV]2O5\"><field name=\"COLOR\">#000000</field></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></next></block></next></block></statement></block></statement></block>","Blockly.Remotes":[],"modules":["rgb"]}

Credits

Bradley Soh
1 project • 0 followers
Contact
JadonHo
1 project • 0 followers
Contact
ωєиѕ 08
1 project • 0 followers
Contact
lennon
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.