Caleb
Published

Automated Pet Feeder

Our automatic pet feeder can detect a pet in the vicinity and dispense food according to its needs to ensure a consistent and balanced diet

BeginnerFull instructions provided446
Automated Pet Feeder

Things used in this project

Hardware components

PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Mini Weight Unit HX711 Module Sensor
M5Stack Mini Weight Unit HX711 Module Sensor
×1
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×1

Software apps and online services

m5 stack ui flow

Story

Read more

Code

M5STACK_PROJECT.m5f

Python
{"components":[{"id":"____screen","createTime":1543457102057,"name":"screen","x":0,"y":0,"width":320,"height":240,"backgroundColor":"#111111","backgroundImage":"","size":0,"type":"screen"},{"id":"____buttonA","createTime":1543457102057,"name":"ButtonA","buttonIndex":0,"x":35,"y":216,"width":64,"height":24,"text":"H+","visibility":false,"type":"button"},{"id":"____buttonB","createTime":1543457102057,"name":"ButtonB","buttonIndex":1,"x":125,"y":216,"width":64,"height":24,"text":"ButtonB","visibility":false,"type":"button"},{"id":"____buttonC","createTime":1543457102057,"name":"ButtonC","buttonIndex":2,"x":215,"y":216,"width":64,"height":24,"text":"ButtonC","visibility":false,"type":"button"},{"id":"6tPKsuQu$!mShhny","createTime":1674108749043,"isCoreTwo":false,"isPaper":false,"name":"label0","x":137,"y":72,"color":"#FFFFFF","text":"label0","font":"lcd.FONT_Ubuntu","rotation":0,"type":"label","layer":5},{"id":"%PTUqce=EF9a&Scs","createTime":1675317891143,"isCoreTwo":false,"isPaper":false,"name":"label1","x":13,"y":8,"color":"#FFFFFF","text":"label1","font":"lcd.FONT_Ubuntu","rotation":0,"type":"label","layer":6},{"id":"uKhgDrjC$oi`NQJP","createTime":1675317922297,"isCoreTwo":false,"isPaper":false,"name":"label2","x":13,"y":33,"color":"#FFFFFF","text":"label2","font":"lcd.FONT_Ubuntu","rotation":0,"type":"label","layer":8},{"id":"+S8@I8_&Q-wah8ga","createTime":1675397988902,"isCoreTwo":false,"isPaper":false,"name":"Label3","x":131,"y":44,"color":"#FFFFFF","text":"Weight","font":"lcd.FONT_Ubuntu","rotation":0,"type":"label","layer":9}],"type":"fire","versions":"Beta","units":[{"id":"K1#ytaIXimMKqZgp","createTime":1676215480167,"type":"weigh","name":"weigh_1","port":"A","default":["A","B","E","Custom"],"user_port":["21","22"],"icon":"weigh.png","url":"https://docs.m5stack.com/en/unit/weight"},{"id":"HFnLR*J+rKT@1998","createTime":1676215480167,"type":"servo","name":"servo_0","port":"B","default":["A","B","E","Custom"],"user_port":["21","22"],"icon":"servo.png","url":"https://docs.m5stack.com/en/accessory/servo_kit"},{"id":"pj3c8vFJ5jzxZvEX","createTime":1676215480167,"type":"pir","name":"pir_0","port":"Custom","default":["A","B","E","Custom"],"user_port":["17","16"],"icon":"pir.png","url":"https://docs.m5stack.com/en/unit/pir"}],"hats":[],"stamps":[],"blockly":"<variables><variable id=\"f_L:6o@0|VyKO|=A2Dev\">x</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"650\" y=\"-190\"><next><block type=\"servo_init\" id=\"Qnr}x.)5=jm`[)NS!$Fu\"><field name=\"VARNAME\">servo0</field><value name=\"PIN\"><shadow type=\"math_number\" id=\"jF]Z~~601eR~:hcbZH2X\"><field name=\"NUM\">26</field></shadow></value><value name=\"FREQ\"><shadow type=\"math_number\" id=\"08Qb0J6`cf6_N!NtE,pH\"><field name=\"NUM\">50</field></shadow></value><value name=\"MIN_US\"><shadow type=\"math_number\" id=\"cLRCSDhKsyH,eV*@e/hp\"><field name=\"NUM\">500</field></shadow></value><value name=\"MAX_US\"><shadow type=\"math_number\" id=\",OW@}f#GzK,4e]?+Z?0a\"><field name=\"NUM\">2500</field></shadow></value><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"Fgas63Opx~C%.dk+7Lv-\"><field name=\"NUM\">180</field></shadow></value><next><block type=\"weigh_zero\" id=\"hH6YKJ~Jk9,ARz3mn_Dp\"><field name=\"VARNAME\">weigh_1</field><next><block type=\"remote_set_qrcode\" id=\";ZwvB4I~?hfGc26IMnkj\"><value name=\"X\"><shadow type=\"math_number\" id=\"6iav$?gk]#=w_0|HjQ^r\"><field name=\"NUM\">110</field></shadow></value><value name=\"Y\"><shadow type=\"math_number\" id=\"4DZv|V.Eyuim+DE#kjf2\"><field name=\"NUM\">110</field></shadow></value><value name=\"SIZE\"><shadow type=\"math_number\" id=\"7a0hz#v2nlx~5/Qdnb$h\"><field name=\"NUM\">110</field></shadow></value><next><block type=\"label_set_text\" id=\"L+Gr?:=VPq@_2E!^Y0nQ\"><field name=\"COMPONENT\">label1</field><value name=\"TEXT\"><shadow type=\"text\" id=\"xOKGqZ3,.eW--IJGb?Vd\"><field name=\"TEXT\">CAT DETECTED</field></shadow></value><next><block type=\"label_set_text\" id=\"m358VNyFX`JPMr+}o{}]\"><field name=\"COMPONENT\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"H,+yVgj]iNqo_,EV+_Sp\"><field name=\"TEXT\">DETECTING</field></shadow></value><next><block type=\"label_set_mode\" id=\"-ytY~=d/s^so2pMySrx^\"><field name=\"COMPONENT\">label1</field><field name=\"MODE\">True</field><next><block type=\"label_set_mode\" id=\"uF1XZ|JLJ~ltTuWEGp2{\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">True</field><next><block type=\"controls_ifelse\" id=\"|_z@qgju%uQUilkXhT$`\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"dnwsleF:PNz[`mHQ4]l9\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"pir_read\" id=\")aW!`hKYROmsyNOpku.Y\"><field name=\"VARNAME\">pir_0</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"K32*e}[JjL/Tt{E61gKH\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"rgb_set_all\" id=\"|F}f}(#6@,A#/WDM%cng\"><field name=\"COLOR\">#33cc00</field><next><block type=\"label_set_mode\" id=\"DY~ZzAoO4qY=%Sd(5i36\"><field name=\"COMPONENT\">label1</field><field name=\"MODE\">False</field><next><block type=\"label_set_mode\" id=\"E*Y@+XeZ0/_`CMJyV5~F\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">True</field><next><block type=\"servo_unit_write_angle\" id=\"|vpsX#2yjs(+Z|Se1Sc/\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"5QLa.ad:~7g^nnz~gJC7\"><field name=\"NUM\">90</field></shadow></value><next><block type=\"timer_delay\" id=\"Lt=R3m(Y@)^hLsIYCyOF\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"-FQm5Bx|`UJA~a#EM$(#\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"servo_unit_write_angle\" id=\"Qi^,e8$:6*aI!x5[FoBf\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"wHvXkI.yYG;xw|Pn@AOo\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"timer_delay\" id=\"0]@R9Y,wyrm:M%8($uN6\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"bNH{7u;)YPXIaS)brE);\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"rgb_set_all\" id=\"HAdr1(;iYqd,{0uS3yGU\"><field name=\"COLOR\">#000000</field><next><block type=\"controls_if\" id=\"g6Ix/8|m{:S)a5g9JVsG\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"_.(L@caOq~_Xj~-+sU6$\"><field name=\"OP\">LTE</field><value name=\"A\"><block type=\"weigh_get_weight\" id=\"4BA#W#/jM6LsEr3Ta%/C\"><field name=\"VARNAME\">weigh_1</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"nfY#[5/4KJ`Sf]%Hgrei\"><field name=\"NUM\">50</field></block></value></block></value><statement name=\"DO0\"><block type=\"controls_repeat\" id=\"9]7)nb5r?QIzPc6S=G:n\"><field name=\"TIMES\">1</field><statement name=\"DO\"><block type=\"servo_unit_write_angle\" id=\"ee2g`X1YQK]l1-y6b[mo\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"_1gdL6I/Di@_iuO4KcL@\"><field name=\"NUM\">90</field></shadow></value><next><block type=\"timer_delay\" id=\"GzoPv*iEumF}*Xjid!Dw\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"qdbc9yTTx)`:9lSR3=x}\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"servo_unit_write_angle\" id=\"AZ;T^1CcauDPeheQz(}^\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"N$g/0tUF%-pXn1;7W5fA\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"timer_delay\" id=\"pC(;qlRLz}@hm/8:kUvU\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"+f}{%d:[(/o0Qg;IhCYu\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></next></block></statement></block></statement></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=\"tFY^[ZmWYI4X=9n9%@kj\"><field name=\"COMPONENT\">label1</field><field name=\"MODE\">True</field><next><block type=\"label_set_mode\" id=\"I(N(C69-$IAUb5mxiX3u\"><field name=\"COMPONENT\">label2</field><field name=\"MODE\">False</field></block></next></block></statement><next><block type=\"basic_on_loop\" id=\"7ab/{8]yaI+hM%CqdiVG\"><statement name=\"LOOP\"><block type=\"label_set_text\" id=\"i[GM:wSW[{RY)ni~!,n!\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"E8(){,=AOYGJ$IX,S^5a\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"weigh_get_weight\" id=\"Pc3DO.DJ^dDY0u]R8Rto\"><field name=\"VARNAME\">weigh_1</field></block></value><next><block type=\"timer_delay\" id=\"-9{xk!#).KLtId!a?BXk\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"PF$DmGfx._Bkx.JWqOeq\"><field name=\"NUM\">0.1</field></shadow></value><next><block type=\"controls_if\" id=\"slz*bO?cmyo5,i/tASR9\"><value name=\"IF0\"><block type=\"button_ispressed\" id=\"y?]q~6h3o=8r*iSh~Jqs\"><field name=\"BUTTON\">A</field><field name=\"EVENT\">isPressed</field></block></value><statement name=\"DO0\"><block type=\"timer_delay\" id=\"cK?Q]:a_)}L;?ZkhIets\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"sN/bM@6Z6%v7stUf#D?2\"><field name=\"NUM\">0.1</field></shadow></value><next><block type=\"weigh_zero\" id=\"kX@ELwrOoD~wlo;b_H3i\"><field name=\"VARNAME\">weigh_1</field></block></next></block></statement></block></next></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type=\"remote_add_switch\" id=\"9?c!g-X|G/#T:9+tq:;P\" x=\"-90\" y=\"410\"><mutation><arg name=\"x\" varid=\"f_L:6o@0|VyKO|=A2Dev\"></arg></mutation><field name=\"NAME\">Dispense Food</field><field name=\"index\">0</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"servo_init\" id=\"ZGMrA;.QYBr5s,#i^S1e\"><field name=\"VARNAME\">servo0</field><value name=\"PIN\"><shadow type=\"math_number\" id=\"{}1m04ibswi1yH)_ABN%\"><field name=\"NUM\">26</field></shadow></value><value name=\"FREQ\"><shadow type=\"math_number\" id=\"UFY)?WFgtL?SgQd/U{kr\"><field name=\"NUM\">50</field></shadow></value><value name=\"MIN_US\"><shadow type=\"math_number\" id=\"u;e[]E`#rO[?jdF|OS7+\"><field name=\"NUM\">500</field></shadow></value><value name=\"MAX_US\"><shadow type=\"math_number\" id=\"Hr!jDq[$3-BP;BfHo,To\"><field name=\"NUM\">2500</field></shadow></value><value name=\"ANGLE\"><shadow type=\"math_number\" id=\".m5K+-1sN,/L2Vo@xSar\"><field name=\"NUM\">180</field></shadow></value><next><block type=\"controls_if\" id=\",!^ch{`,+@sgm!J|7IyW\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"-+)Ibl))Or[Y(+=44T`S\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get\" id=\"T=KrB$XxKy4)z(7Gw@Sy\"><field name=\"VAR\" id=\"f_L:6o@0|VyKO|=A2Dev\">x</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"c$H;kl{p7$-ZZO(-./ng\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"servo_unit_write_angle\" id=\"Aj/P/MAL+AQkv^SZXEi7\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"yLFQa}Bz:nA#g8J]lKpz\"><field name=\"NUM\">90</field></shadow></value><next><block type=\"timer_delay\" id=\"r|9:ZP]+fq6Um833Ig;.\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"i8ijQ[J2{)pP8WnRB9uX\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"servo_unit_write_angle\" id=\"6|qJHPA:6Z;w-_t}T.a]\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"*-E*mAU3+]0LfG4*Vpty\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"timer_delay\" id=\"-1,apK9Ye(H`OAIz$GI_\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"%YOpi+uWaR1+1}8~WyY8\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></next></block></statement></block></next></block></statement></block>","Blockly.Remotes":[{"id":"9?c!g-X|G/#T:9+tq:;P","event":"_remote_Dispense_Food","code":"def _remote_Dispense_Food(x):\n  global weigh_1, servo_0, pir_0 \n  servo0 = Servo(26,50,500,2500,180)\n  if x == 1:\n    servo_0.write_angle(90)\n    wait(1)\n    servo_0.write_angle(0)\n    wait(1)\n","name":"Dispense Food","type":"switch","index":"0"}],"Blockly.RemotePlus":[{"id":"__title","blockId":"","createTime":1676215480167,"name":"M5RemoteTitle","dragAndDrop":false,"resizable":false,"options":{"minWidth":1,"minHeight":1,"maxWidth":6,"maxHeight":10,"defaultWidth":2,"defaultHeight":1},"w":2,"h":1,"bgColor":"#0080FF","color":"#fff","fontsize":"M","label":"M5Remote","interval":3000,"code":"","event":"","dataSource":"none","ezdataToken":"9smFYW9LnIo30IZU3RJUHQWuooM12JEb","topic":"","needShadow":false,"type":"title","x":0,"y":0}],"modules":["remote","rgb","remotePlus"],"cbIdList_":[],"eventCBIdList_":[],"uuid":"946b92ef-85d5-4598-a3b6-e4fecdfbbae1"}

Credits

Caleb

Caleb

1 project • 0 followers

Comments