{"id":318281,"date":"2021-02-19T15:00:41","date_gmt":"2021-02-19T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=318281"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=318281","title":{"rendered":"\u041f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u044b\u0442 \u0441 Raspberry Pi \u0438\u043b\u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u0434\u043e\u043c\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0436\u0434\u0435 \u043d\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 Raspberry, \u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u043c\u0443 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0422\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u044f \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u043c\u0443 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u044d\u043f\u0438\u0442\u0435\u0442 \u00ab\u0443\u043c\u043d\u044b\u0439\u00bb \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0430, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u043f\u043e\u0433\u0435\u044f (\u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f). \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u043e\u0438\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043d\u0435 \u0438\u0437 IT-\u0441\u0444\u0435\u0440\u044b \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0430\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0432\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0436\u0438\u0432\u0435\u0442 \u0432 \u0441\u0430\u043c\u043e\u043c \u00ab\u0443\u043c\u043d\u043e\u043c\u00bb \u0434\u043e\u043c\u0435 \u0432\u043e \u0432\u0441\u0451\u043c \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0435\u043d \u2014 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u0441\u0442\u0435\u043d\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u0438\u043d\u0441\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u0430 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0432\u044b\u0433\u0443\u043b\u0438\u0432\u0430\u0435\u0442 \u00ab\u0443\u043c\u043d\u0443\u044e\u00bb \u0441\u043e\u0431\u0430\u043a\u0443 \u0438\u0437 Boston Dynamics. \u0414\u0430\u0431\u044b \u043d\u0435 \u043e\u0442\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u043e\u0442 \u044d\u0442\u0438\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432, \u043c\u044b \u0441 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u043c \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u00ab\u0443\u043c\u043d\u043e\u0435\u00bb, \u043d\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0448\u043a\u043e\u043b\u0435 \u0441\u0445\u0435\u043c\u043e\u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u043e\u0431\u043e\u0448\u043b\u0438 \u043d\u0430\u0441 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043c\u0435\u0440\u0443 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 aka \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0445\u0440\u0430\u043d\u044b. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0444\u0442\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0438\u0434\u0435\u044f \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d08\/dd4\/172\/d08dd41722cccfb571431fbb9149a7e1.jpg\" width=\"2560\" height=\"926\"><figcaption><\/figcaption><\/figure>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Raspberry Pi, \u0441\u043d\u0430\u0440\u044f\u0436\u0451\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e. \u0415\u0441\u0442\u044c MQTT \u0431\u0440\u043e\u043a\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 Raspberry \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Data Analyzer. \u0412\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 Object Storage. DB \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0430\u0448 \u043f\u0430\u0440\u0430\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 REST API \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f. \u0417\u0435\u043b\u0435\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/company\/megafon\/blog\/540334\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u041f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<h2>Raspberry Pi<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0447\u044c\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u043b\u0430\u0441\u044c \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0436\u0435\u043b\u0435\u0437\u044f\u043a, \u043c\u044b\u0441\u043b\u0438 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u043b\u0438\u0448\u044c Raspberry Pi \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0435\u044f\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0436\u0435 \u044d\u043c\u043e\u0446\u0438\u0438, \u043a\u0430\u043a\u0438\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0443\u0432\u0438\u0434\u0435\u0432\u0448\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u2014 \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0445\u0430\u043e\u0441 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0439 (\u043d\u0430 \u0434\u0435\u043b\u0435 \u0431\u0435\u0441\u043f\u043e\u0447\u0432\u0435\u043d\u043d\u044b\u0445). \u041f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0449\u0443\u0449\u0430\u043b \u0438 \u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0436\u0435\u043b\u0435\u0437\u0430 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u043f\u043e\u043a\u043e\u044f.&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u0438\u0434\u0435\u0439 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:&nbsp;<\/p>\n<ul>\n<li>\n<p>Raspberry Pi 4 \u0441 \u0434\u0432\u0443\u043c\u044f \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>SD-\u043a\u0430\u0440\u0442\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u0436\u0451\u0441\u0442\u043a\u0438\u0439 \u0434\u0438\u0441\u043a \u0434\u043b\u044f Raspberry). \u041a \u0441\u043b\u043e\u0432\u0443, \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 SD-\u043a\u0430\u0440\u0442\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \/ \u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e Raspberry (\u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u044d\u043c\u043f\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438).<\/p>\n<\/li>\n<li>\n<p>PIR-\u0441\u0435\u043d\u0441\u043e\u0440, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043d\u0438\u043a \u0441 microHDMI \u043d\u0430 HDMI<\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0447\u043a\u0430 \u043f\u0440\u043e\u0432\u043e\u0434\u043e\u0432 \u0442\u0438\u043f\u0430 \u00ab\u041c\u0430\u043c\u0430-\u041c\u0430\u043c\u0430\u00bb.&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043c\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/635\/e4b\/75a\/635e4b75a1ced647f83fa7f53965c17f.jpg\" alt=\"\" title=\"\" width=\"1920\" height=\"1440\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u2013 \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043b\u044e\u0431\u043e\u0435 \u0437\u0430\u0440\u044f\u0434\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u0442 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 5V\/1A.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Raspberry \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u041e\u0421. \u0412\u0437\u044f\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.raspberrypi.org\/software\/operating-systems\/\">\u0442\u0443\u0442<\/a>. \u042f \u0431\u044b\u043b \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f IDE \u043a\u0430\u043a \u0434\u043b\u044f Python, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f Java. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u0445\u0435\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0412 Raspberry \u0435\u0441\u0442\u044c GPIO \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u043d\u0441\u043e\u0440\u043e\u0432. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0438\u043d\u043e\u0432 (\u0442\u043e, \u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043d \u041e\u0421 \u043c\u0430\u043b\u0438\u043d\u044b) \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e21\/3e3\/c5a\/e213e3c5ac9358214854fac7bf053e85.jpg\" width=\"828\" height=\"678\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u00ab\u041c\u0430\u043c\u0430-\u041c\u0430\u043c\u0430\u00bb \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0444\u043e\u0442\u043e. \u041e\u0434\u0438\u043d \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u043a 5-\u0432\u043e\u043b\u044c\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u0438\u043d\u0443 (5V \u043d\u0430 \u0441\u0445\u0435\u043c\u0435) \u043d\u0430 \u043c\u0430\u043b\u0438\u043d\u0435 \u0438 \u043a \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u043d\u0430 \u0441\u0435\u043d\u0441\u043e\u0440\u0435, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0437\u0435\u043c\u043b\u0435 (\u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0430 GND \u043d\u0430 \u0441\u0445\u0435\u043c\u0435) \u043d\u0430 \u043c\u0430\u043b\u0438\u043d\u0435 \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0430\u043a\u0436\u0435 \u043a \u0437\u0435\u043c\u043b\u0435 \u043d\u0430 \u0434\u0430\u0442\u0447\u0438\u043a\u0435 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u0438\u043d\u0438\u0439 \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043f\u0438\u043d, \u0441 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 GPIO + \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043d\u043e\u043c\u0435\u0440. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u0435\u043d\u0441\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e GPIO26.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb5\/530\/426\/fb55304262b725d5595e61edf077d414.jpg\" width=\"2560\" height=\"2003\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e python-\u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0438 \u043a\u0430\u043c\u0435\u0440\u044b. \u0412\u044b\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Raspberry.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PIR-\u0441\u0435\u043d\u0441\u043e\u0440\u0430:<\/p>\n<pre><code class=\"python\">from gpiozero import MotionSensor from datetime import timezone  pir = MotionSensor(26) while True:         pir.wait_for_motion()         dt = datetime.datetime.utcnow()         st = dt.strftime('%d.%m.%Y %H:%M:%S')         print(\"Motion Detected at : \" + st)<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0431\u044b\u043b\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Wi-Fi \u0441\u0438\u0433\u043d\u0430\u043b\u044b, \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u044f \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c false-positive \u043e\u0448\u0438\u0431\u043a\u0438 \u2014 \u043b\u043e\u0436\u043d\u043e\u0435 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438, \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u0440\u043e\u0432\u043d\u043e \u0440\u0430\u0437 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443. \u041f\u043e\u0447\u0438\u0442\u0430\u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u0443\u043c\u044b, \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u043b\u044c\u0433\u043e\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24d\/253\/a55\/24d253a5536abe46a1e0312f2aa41fa8.jpg\" alt=\"\u041a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e.\" title=\"\u041a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e.\" width=\"1920\" height=\"1440\"><figcaption>\u041a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e.<\/figcaption><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0436\u0435 \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430.&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u043c\u0430\u043b\u0438\u043d \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0438 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e), \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0442\u0443\u0442 \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c UUID. \u041f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0444\u0430\u0439\u043b device_uuid. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"python\">import uuid  def getDeviceId():     try:         deviceUUIDFile  = open(\"device_uuid\", \"r\")         deviceUUID = deviceUUIDFile.read()         print(\"Device UUID : \" + deviceUUID)         return deviceUUID     except FileNotFoundError:         print(\"Configuring new UUID for this device...\")         deviceUUIDFile = open(\"device_uuid\", \"w\")         deviceUUID = str(uuid.uuid4())         print(\"Device UUID : \" + deviceUUID)         deviceUUIDFile.write(deviceUUID)         return deviceUUID<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a MQTT \u0431\u0440\u043e\u043a\u0435\u0440\u0443:<\/p>\n<pre><code class=\"python\">import paho.mqtt.client as mqtt  mqttClient = mqtt.Client(\"P1\") mqttClient.loop_start() # \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0435\u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432  mqttClient.connect(BROKER_ADDRESS)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 while-true \u0446\u0438\u043a\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c json \u0432\u0438\u0434\u0430:&nbsp;<\/p>\n<pre><code class=\"json\">{   \"device_id\": \"123e4567-e89b-12d3-a456-426614174000\",   \"id\": \"133d4167-18ds-11d1-b446-826314134110\",   \"place\": \"office_room\",   \"filename\": \"133d4167-18ds-11d1-b446-826314134110_alarm.mp4\",   \"type\": \"detected_motion\",   \"occurred_at\": \"01.01.2021 20:19:56\u00bb }<\/code><\/pre>\n<p>\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 MQTT \u0431\u0440\u043e\u043a\u0435\u0440:<\/p>\n<pre><code class=\"python\">MP4_VIDEO_EXT = '.mp4'  alarmUUID = str(uuid.uuid4())         filename = '{}_alarm'.format(alarmUUID)         message = json.dumps({                                 'device_id': deviceUUID,                                 'id': alarmUUID,                                 'place': 'office_room',                                 'filename': filename + MP4_VIDEO_EXT,                                 'type': 'detected_motion',                                 'occurred_at': st                                 }, sort_keys=True)         mqttClient.publish(\"raspberry\/main\", message)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e. \u0421\u0440\u0430\u0437\u0443 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043c\u0435\u0440\u044b.<\/p>\n<pre><code class=\"python\">import picamera  VIDEO_TIME_SEC = 15 FILE_DIR = 'snapshots\/' MP4_VIDEO_EXT = '.mp4' H264_VIDEO_EXT = '.h264' camera = picamera.PiCamera() camera.resolution = 640,480  def record(filename):     h264_file = filename + H264_VIDEO_EXT     print(\"Recording : \" + h264_file)     camera.start_recording(h264_file)     camera.wait_recording(VIDEO_TIME_SEC)     camera.stop_recording()     print(\"Recorded\")          # \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u043e\u0434\u043d\u043e\u043c mp4     mp4_file = filename + MP4_VIDEO_EXT     command = \"MP4Box -add \" + h264_file + \" \" + mp4_file     print(\"Converting from .h264 to mp4\")          call([command], shell=True)     print(\u00abConverted\")<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0438\u0434\u0435\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 MinIO. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 MinIO, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430. \u041e \u0441\u0430\u043c\u043e\u043c MinIO \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<pre><code class=\"python\">from minio import Minio from minio.error import S3Error  MINIO_HOST = \u00ab0.0.0.0:443\u00bb BUCKET_NAME = \u2018raspberrycamera\u2019 client = Minio(         MINIO_HOST,         access_key=\"minio\",         secret_key=\"minio123\",         secure=False     ) found = client.bucket_exists(BUCKET_NAME) if not found:     client.make_bucket(BUCKET_NAME) else:     print(\"Bucket {} already exists\u00bb.format(BUCKET_NAME))  def sendToMinio(filename):     try:         print(\"Sending to minio\")         client.fput_object(             BUCKET_NAME, filename, FILE_DIR + filename         )         print(\"Video has been sent\")     except Exception as e:         print(e)         print(\"Couldn't send to Minio\u00bb) <\/code><\/pre>\n<h2>\u0421\u0435\u0440\u0432\u0438\u0441 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0447\u0430\u0441\u0442\u043a\u0443 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2013 \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u043e\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0444\u0438\u043a\u0430 \u043e\u0442 Rasbperry \u0438 \u00ab\u0443\u043a\u043b\u0430\u0434\u043a\u0430\u00bb \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u043c\u0443 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0443\u043b\u043e\u0436\u0438\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 Docker \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e docker-compose:<\/p>\n<pre><code class=\"python\">version: '3.1' services:   app:     restart: on-failure     build:       context: .       dockerfile: Dockerfile     environment:       POSTGRES_URL: \"jdbc:postgresql:\/\/database:5432\/alarms\"       POSTGRES_USER: \"postgres\"       POSTGRES_PASSWORD: \"changeme\"        MQTT_BROKER_HOST: \"mosquitto\"       MQTT_BROKER_PORT: \"1883\"       MQTT_BROKER_TOPICS: \"raspberry\/main\"        MINIO_HOST: \"https:\/\/minio\"       MINIO_PORT: \"443\"       MINIO_ACCESS_KEY: \"minio\"       MINIO_SECRET_KEY: \"minio123\"       MINIO_BUCKET: \"raspberrycamera\"     ports:       - \"8080:8080\"     depends_on:       - database     links:       - database   database:     container_name: database     image: postgres     ports:       - \"5432:5432\"     environment:       - POSTGRES_PASSWORD=changeme       - POSTGRES_USER=postgres       - POSTGRES_DB=alarms    mosquitto:     image: eclipse-mosquitto     ports:       - 1883:1883       - 8883:8883     restart: unless-stopped    minio:     image: minio\/minio     command: server --address \":443\" \/data     ports:       - \"443:443\"     environment:       MINIO_ACCESS_KEY: \"minio\"       MINIO_SECRET_KEY: \"minio123\"     volumes:       - \/tmp\/minio\/data:\/data       - \/tmp\/.minio:\/root\/.minio<\/code><\/pre>\n<h2>MQTT-\u0431\u0440\u043e\u043a\u0435\u0440<\/h2>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u0437\u043b\u0430 \u0441\u0432\u044f\u0437\u0438 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 MQTT-\u0431\u0440\u043e\u043a\u0435\u0440. MQTT \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c-\u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u043f\u043e\u0432\u0435\u0440\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 TCP\/IP, \u0433\u0434\u0435 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u2014 MQTT-\u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438 \u0436\u0435 \u0431\u0440\u043e\u043a\u0435\u0440. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 MQTT \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043e \u043f\u043e \u0440\u044f\u0434\u0443 \u043f\u0440\u0438\u0447\u0438\u043d. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043d \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u0435\u043d \u0441\u0432\u043e\u0435\u0439 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u0433\u043e \u043f\u043e \u0441\u0435\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u043e\u0431\u044a\u0435\u043c \u0442\u0440\u0430\u0444\u0444\u0438\u043a\u0430, \u0430 \u044d\u0442\u043e, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u0435\u0434\u0451\u0442 \u043a \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u0430\u043a \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u0442\u0430\u043a \u0438 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u044d\u043d\u0435\u0440\u0433\u043e\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043e\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u2013 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430 (\u0442\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e Raspberry \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u043d\u0430\u0449\u0451\u043d \u0442\u0430\u043a\u0436\u0435 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0435\u0441\u0442\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438). \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0435\u0442\u0438. \u041d\u0443 \u0430 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u044e \u0432 \u0442\u043e\u043c, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u0443\u044e \u043a\u0430\u043c\u0435\u0440\u0443 \u2013 \u0434\u0430\u043d\u043d\u043e\u0435 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0433\u0440\u0430\u0435\u0442 \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0440\u043e\u043b\u044c, \u0440\u043e\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e (\u043a\u0430\u043a \u043d\u0438\u043a\u0430\u043a, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u0445\u0440\u0430\u043d\u044b). \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 MQTT-\u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d open-source \u0431\u0440\u043e\u043a\u0435\u0440 <a href=\"https:\/\/mosquitto.org\/\">Mosquitto<\/a>.<\/p>\n<h2>\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 MinIO<\/h2>\n<p>\u041f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f\u0441\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043a\u0438\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. \u0427\u0442\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0442\u0430\u043b\u043e open-source \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <a href=\"https:\/\/min.io\/\">MinIO<\/a>. \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u043d\u043e, \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u0440\u0430\u0439\u043d\u0435 \u0443\u0434\u043e\u0431\u0435\u043d.&nbsp;<br \/>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043b\u044e\u0431\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 bucket\u2019\u044b (\u0438\u043b\u0438 \u0436\u0435 \u043a\u043e\u0440\u0437\u0438\u043d\u044b):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e1\/88a\/fa9\/7e188afa9ebaf3ff35527dd83d799986.jpg\" width=\"2540\" height=\"1340\"><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0442\u043e \u0436, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0435\u0440\u0432\u0438\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 Java \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Spring \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MQTT-\u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.integration&lt;\/groupId&gt;     &lt;artifactId&gt;spring-integration-mqtt&lt;\/artifactId&gt;     &lt;version&gt;5.4.2&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u0421\u0430\u043c\u0430 \u0436\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">@Configuration public class MqttConfiguration {      @Value(\"${mqtt.broker.host}\")     private String brokerHost;      @Value(\"${mqtt.broker.port}\")     private String brokerPort;      @Value(\"${mqtt.broker.topics}\")     private String topics;      @Bean     public MessageChannel mqttInputChannel() {         return new DirectChannel();     }      @Bean     public MessageProducer inbound() {         String[] parsedTopics = parseTopics();         MqttPahoMessageDrivenChannelAdapter adapter =                 new MqttPahoMessageDrivenChannelAdapter(                         \"tcp:\/\/\" + brokerHost + \":\" + brokerPort,                         UUID.randomUUID().toString(),                         parsedTopics);         adapter.setCompletionTimeout(5000);         adapter.setConverter(new DefaultPahoMessageConverter());         adapter.setQos(1);         adapter.setOutputChannel(mqttInputChannel());         return adapter;     }      private String[] parseTopics() {         return topics.split(\",\");     }      @Bean     @ServiceActivator(inputChannel = \"mqttInputChannel\")     public MessageHandler handler() {         return new MqttMessageHandler();     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u043c <em>MqttMessageHandler<\/em>:<\/p>\n<pre><code class=\"java\">public class MqttMessageHandler implements MessageHandler {      @Autowired     private AlarmRepository alarmRepository;      @Autowired     private DeviceRepository deviceRepository;      private Gson gson = new GsonBuilder().create();      private DateFormat sdf = new SimpleDateFormat(\"dd.MM.yyyy H:m:s\");      @Override     public void handleMessage(Message&lt;?&gt; message) throws MessagingException {         String payload = (String) message.getPayload();         Map&lt;String, String&gt; parsedMessage = (Map&lt;String, String&gt;) gson.fromJson(payload, Map.class);         long occurredAt = 0L;         try {             occurredAt = sdf.parse(parsedMessage.get(\"occurred_at\")).getTime();         } catch (ParseException e) {             e.printStackTrace();             return;         }         UUID deviceID = UUID.fromString(parsedMessage.get(\"device_id\"));         Device device = new Device(deviceID, \"\", new Date().getTime(), occurredAt);         deviceRepository.saveAndFlush(device);          Alarm alarm = new Alarm(                 UUID.fromString(parsedMessage.get(\"id\")),                 parsedMessage.get(\"place\"),                 parsedMessage.get(\"filename\"),                 parsedMessage.get(\"type\"),                 device,                 occurredAt,                 false         );         alarmRepository.saveAndFlush(alarm);     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;io.minio&lt;\/groupId&gt;     &lt;artifactId&gt;minio&lt;\/artifactId&gt;     &lt;version&gt;8.0.3&lt;\/version&gt; &lt;\/dependency&gt; <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f MinIO:<\/p>\n<pre><code class=\"java\">@Configuration public class MinioConfiguration {      @Value(\"${minio.host}\")     private String host;      @Value(\"${minio.port}\")     private String port;      @Value(\"${minio.access.key}\")     private String accessKey;      @Value(\"${minio.secret.key}\")     private String secretKey;      @Value(\"${minio.bucket}\")     private String bucket;      @Bean     public MinioClient getClient() {         return MinioClient.builder()                 .endpoint(host, Integer.parseInt(port), false)                 .credentials(accessKey, secretKey)                 .build();     }      @Bean     public MinioFileManager getManager(MinioClient client) {         return new MinioFileManager(client);     } }<\/code><\/pre>\n<p>\u0418\u0437\u044f\u0449\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438?&nbsp;<\/p>\n<p><em>MinioFileManager<\/em> \u2014 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f&nbsp; \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u0445 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0430\u043c\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MinIO \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435 \u2014 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u0430\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u0435\u0434\u0438\u0430-\u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043f\u043e\u0432\u0435\u0440\u0445 HTTP \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<h2>HTTP video streaming<\/h2>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0438\u0434\u0435\u043e-\u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430.&nbsp;<\/p>\n<p>\u041f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u0443. \u0412\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u044d\u0442\u0438\u0445 \u0441\u0430\u043c\u044b\u0445 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u0432 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 Range. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0442\u0430\u043a: bytes=0-1000000. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u00ab\u0432\u044b\u0440\u0435\u0437\u0430\u0435\u0442\u00bb \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0431\u0430\u0439\u0442 \u0438\u0437 \u0432\u0438\u0434\u0435\u043e \u0438 \u0432\u044b\u0434\u0430\u0451\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441 \u043a\u043e\u0434\u043e\u043c HTTP = 203 (Partial content). \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043e\u0442\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0438 \u0432\u0441\u0451 \u0432\u0438\u0434\u0435\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u0435\u043d 200. \u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430&nbsp; \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e:<\/p>\n<ul>\n<li>\n<p><strong>Content-Type<\/strong>. \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f video\/mp4<\/p>\n<\/li>\n<li>\n<p><strong>Accept-Ranges<\/strong>. \u0414\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e, \u0432 \u0447\u0451\u043c \u0436\u0435\u043b\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445: Accept-Ranges: bytes.<\/p>\n<\/li>\n<li>\n<p><strong>Content-Length<\/strong>. \u041d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0434\u0438\u0430-\u0444\u0430\u0439\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u0432\u0438\u0434\u0435\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0443 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u044b).<\/p>\n<\/li>\n<li>\n<p><strong>Content-Range<\/strong>. \u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0434\u0435\u0441\u044c \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043a\u043b\u0438\u0435\u043d\u0442\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0439\u0442 \u0432 \u0432\u0438\u0434\u0435\u043e: Content-Range: bytes 1000-15000\/250000.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043e\u0434. \u041c\u0435\u0442\u043e\u0434 readFile \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 MinIO \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442. \u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 Range \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 slice \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u043a\u0443\u0441\u043e\u043a \u0438\u0437 \u0432\u0438\u0434\u0435\u043e \u0438\u043b\u0438 \u0436\u0435 \u043e\u0442\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0431\u044b\u043b \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<pre><code class=\"java\">public class MinioFileManager implements FileManager {      @Value(\"${minio.bucket}\")     private String bucket;      private final MinioClient client;      public MinioFileManager(MinioClient mc) {         client = mc;     }      public Video getVideo(String filename, VideoRange range) throws Exception {         byte[] data = readFile(filename);         Video video = new Video(data);         return slice(video, range);     }      private Video slice(Video video, VideoRange range) {         if (range.wholeVideo()) {             return video;         }         int finalSize;         if (video.shorterThan(range.getEnd()) || range.withNoEnd()) {             finalSize = video.getSize() - (int) range.getStart();         } else {             finalSize = (int) range.difference();         }         byte[] result = new byte[finalSize];         System.arraycopy(video.asArray(), (int) range.getStart(), result, 0, result.length);         return new Video(result, false, video.getSize());     }      private byte[] readFile(String filename) throws Exception {         try (InputStream is = client.getObject(                 GetObjectArgs.builder()                         .bucket(bucket)                         .object(filename)                         .build())) {             ByteArrayOutputStream bufferedOutputStream = new ByteArrayOutputStream();             byte[] data = new byte[1024];             int nRead;             while ((nRead = is.read(data, 0, data.length)) != -1) {                 bufferedOutputStream.write(data, 0, nRead);             }             int resultLength = bufferedOutputStream.size();             bufferedOutputStream.flush();             byte[] result = new byte[resultLength];             System.arraycopy(bufferedOutputStream.toByteArray(), (int) 0, result, 0, result.length);             return result;         }     }      public void removeFile(String filename) {         List&lt;DeleteObject&gt; objects = new LinkedList&lt;&gt;();         objects.add(new DeleteObject(filename));         Iterable&lt;Result&lt;DeleteError&gt;&gt; results =                 client.removeObjects(                         RemoveObjectsArgs.builder().bucket(bucket).objects(objects).build());         try {             for (Result&lt;DeleteError&gt; result : results) {                 DeleteError error = result.get();                 System.out.println(                         \"Error in deleting object \" + error.objectName() + \"; \" + error.message());             }         } catch (Exception e) {             e.printStackTrace();         }     }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u044f\u0434\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432. \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 VideoResponseFactory, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0440\u0435\u0441\u043f\u043e\u043d\u0441\u0430: \u043b\u0438\u0431\u043e \u0441 \u0446\u0435\u043b\u044b\u043c \u0432\u0438\u0434\u0435\u043e-\u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c, \u043b\u0438\u0431\u043e \u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b.<\/p>\n<pre><code class=\"java\">public class VideoResponseFactory {      private final String contentType = \"video\/mp4\";      private final String CONTENT_TYPE = \"Content-Type\";      private final String ACCEPT_RANGES = \"Accept-Ranges\";      private final String CONTENT_LENGTH = \"Content-length\";      private final String CONTENT_RANGE = \"Content-Range\";      private ResponseEntity&lt;byte[]&gt; toPartialResponse(Video video, String stringRanges) {         long[] ranges = parseRanges(stringRanges);         long start = ranges[0];         long end = ranges[1];         long rangeEnd = end;         if (end == -1) {             rangeEnd = video.originalSize() - 1;         }          return ResponseEntity.status(HttpStatus.PARTIAL_CONTENT)                 .header(CONTENT_TYPE, contentType)                 .header(ACCEPT_RANGES, \"bytes\")                 .header(CONTENT_LENGTH, String.valueOf(video.getSize()))                 .header(CONTENT_RANGE, \"bytes\" + \" \" + start + \"-\" + rangeEnd + \"\/\" + video.originalSize())                 .body(video.asArray());     }      private long[] parseRanges(String stringRanges) {         String[] ranges = stringRanges.split(\"-\");         long start = Long.parseLong(ranges[0].substring(6));         long end;         if (ranges.length &gt; 1) {             end = Long.parseLong(ranges[1]);         } else {             end = -1;         }         return new long[] {start, end};     }      public ResponseEntity&lt;byte[]&gt; toResponse(Video video, String ranges) {         if (video.isFull()) {             return toFullResponse(video.asArray());         } else {             return toPartialResponse(video, ranges);         }     }      private ResponseEntity&lt;byte[]&gt; toFullResponse(byte[] video) {         return ResponseEntity.status(HttpStatus.OK)                 .header(CONTENT_TYPE, contentType)                 .header(CONTENT_LENGTH, String.valueOf(video.length))                 .header(ACCEPT_RANGES, \"bytes\")                 .body(video);     } }<\/code><\/pre>\n<p>\u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code class=\"java\">\t\t@GetMapping(\"\/stream\/{filename}\/{filetype}\")     public Mono&lt;ResponseEntity&lt;byte[]&gt;&gt; streamVideo(@RequestHeader(value = \"Range\", required = false) String httpRangeList,                                                     @PathVariable(\"filename\") String filename,                                                     @PathVariable(\"filetype\") String fileType) throws Exception {         Video video = fm.getVideo(filename, VideoRange.of(httpRangeList));         ResponseEntity&lt;byte[]&gt; response = rf.toResponse(video, httpRangeList);         Optional&lt;Alarm&gt; stored = repository.findAlarmByFilename(filename);         if (stored.isPresent()) {             Alarm alarm = stored.get();             alarm.seen();             repository.saveAndFlush(alarm);         }         return Mono.just(response);     }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f IoT-\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0449\u0430\u044f \u0432\u0438\u0434\u0435\u043e\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439.&nbsp; TODO-\u043b\u0438\u0441\u0442 \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u0439\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0441\u0435\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u0421\u0440\u0435\u0434\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: WiFi, \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f MinIO, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438, \u0430\u0434\u0440\u0435\u0441 \u0438 \u0442\u043e\u043f\u0438\u043a\u0438 \u0434\u043b\u044f \u0431\u0440\u043e\u043a\u0435\u0440\u0430.<\/p>\n<ol>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0432\u0438\u0434\u0435\u043e \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435.<\/p>\n<p>Stay tuned!&nbsp;<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/megafon\/blog\/543316\/\"> https:\/\/habr.com\/ru\/company\/megafon\/blog\/543316\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0436\u0434\u0435 \u043d\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441 Raspberry, \u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u043c\u0443 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0422\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u044f \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u043c\u0443 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u044d\u043f\u0438\u0442\u0435\u0442 \u00ab\u0443\u043c\u043d\u044b\u0439\u00bb \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0430, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u043f\u043e\u0433\u0435\u044f (\u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f). \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u043e\u0438\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043d\u0435 \u0438\u0437 IT-\u0441\u0444\u0435\u0440\u044b \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0430\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0432\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0436\u0438\u0432\u0435\u0442 \u0432 \u0441\u0430\u043c\u043e\u043c \u00ab\u0443\u043c\u043d\u043e\u043c\u00bb \u0434\u043e\u043c\u0435 \u0432\u043e \u0432\u0441\u0451\u043c \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0435\u043d \u2014 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0435 \u0441\u0442\u0435\u043d\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u0438\u043d\u0441\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u0430 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0432\u044b\u0433\u0443\u043b\u0438\u0432\u0430\u0435\u0442 \u00ab\u0443\u043c\u043d\u0443\u044e\u00bb \u0441\u043e\u0431\u0430\u043a\u0443 \u0438\u0437 Boston Dynamics. \u0414\u0430\u0431\u044b \u043d\u0435 \u043e\u0442\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u043e\u0442 \u044d\u0442\u0438\u0445 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432, \u043c\u044b \u0441 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0435\u043c \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u00ab\u0443\u043c\u043d\u043e\u0435\u00bb, \u043d\u043e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0448\u043a\u043e\u043b\u0435 \u0441\u0445\u0435\u043c\u043e\u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u043e\u0431\u043e\u0448\u043b\u0438 \u043d\u0430\u0441 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043c\u0435\u0440\u0443 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 aka \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0445\u0440\u0430\u043d\u044b. \u0418\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0444\u0442\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0438\u0434\u0435\u044f \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Raspberry Pi, \u0441\u043d\u0430\u0440\u044f\u0436\u0451\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e. \u0415\u0441\u0442\u044c MQTT \u0431\u0440\u043e\u043a\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 Raspberry \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Data Analyzer. \u0412\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0438, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 Object Storage. DB \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0430\u0448 \u043f\u0430\u0440\u0430\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 REST API \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f. \u0417\u0435\u043b\u0435\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/company\/megafon\/blog\/540334\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u041f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<h2>Raspberry Pi<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0447\u044c\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u043b\u0430\u0441\u044c \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0436\u0435\u043b\u0435\u0437\u044f\u043a, \u043c\u044b\u0441\u043b\u0438 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u043b\u0438\u0448\u044c Raspberry Pi \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0435\u044f\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0436\u0435 \u044d\u043c\u043e\u0446\u0438\u0438, \u043a\u0430\u043a\u0438\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0443\u0432\u0438\u0434\u0435\u0432\u0448\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u2014 \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0445\u0430\u043e\u0441 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0439 (\u043d\u0430 \u0434\u0435\u043b\u0435 \u0431\u0435\u0441\u043f\u043e\u0447\u0432\u0435\u043d\u043d\u044b\u0445). \u041f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0449\u0443\u0449\u0430\u043b \u0438 \u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0436\u0435\u043b\u0435\u0437\u0430 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u043f\u043e\u043a\u043e\u044f.&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u0438\u0434\u0435\u0439 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:&nbsp;<\/p>\n<ul>\n<li>\n<p>Raspberry Pi 4 \u0441 \u0434\u0432\u0443\u043c\u044f \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>SD-\u043a\u0430\u0440\u0442\u0430 (\u043e\u043d\u0430 \u0436\u0435 \u0436\u0451\u0441\u0442\u043a\u0438\u0439 \u0434\u0438\u0441\u043a \u0434\u043b\u044f Raspberry). \u041a \u0441\u043b\u043e\u0432\u0443, \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 SD-\u043a\u0430\u0440\u0442\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \/ \u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e Raspberry (\u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u044d\u043c\u043f\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438).<\/p>\n<\/li>\n<li>\n<p>PIR-\u0441\u0435\u043d\u0441\u043e\u0440, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0438\u0434\u0435\u043e\u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043d\u0438\u043a \u0441 microHDMI \u043d\u0430 HDMI<\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0447\u043a\u0430 \u043f\u0440\u043e\u0432\u043e\u0434\u043e\u0432 \u0442\u0438\u043f\u0430 \u00ab\u041c\u0430\u043c\u0430-\u041c\u0430\u043c\u0430\u00bb.&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043c\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u2013 \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043b\u044e\u0431\u043e\u0435 \u0437\u0430\u0440\u044f\u0434\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u0442 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 5V\/1A.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Raspberry \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u041e\u0421. \u0412\u0437\u044f\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.raspberrypi.org\/software\/operating-systems\/\">\u0442\u0443\u0442<\/a>. \u042f \u0431\u044b\u043b \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u0435\u043d, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f IDE \u043a\u0430\u043a \u0434\u043b\u044f Python, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f Java. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u0445\u0435\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0412 Raspberry \u0435\u0441\u0442\u044c GPIO \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u043d\u0441\u043e\u0440\u043e\u0432. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0438\u043d\u043e\u0432 (\u0442\u043e, \u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043d \u041e\u0421 \u043c\u0430\u043b\u0438\u043d\u044b) \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u00ab\u041c\u0430\u043c\u0430-\u041c\u0430\u043c\u0430\u00bb \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0444\u043e\u0442\u043e. \u041e\u0434\u0438\u043d \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u043a 5-\u0432\u043e\u043b\u044c\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u0438\u043d\u0443 (5V \u043d\u0430 \u0441\u0445\u0435\u043c\u0435) \u043d\u0430 \u043c\u0430\u043b\u0438\u043d\u0435 \u0438 \u043a \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u043d\u0430 \u0441\u0435\u043d\u0441\u043e\u0440\u0435, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0437\u0435\u043c\u043b\u0435 (\u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0430 GND \u043d\u0430 \u0441\u0445\u0435\u043c\u0435) \u043d\u0430 \u043c\u0430\u043b\u0438\u043d\u0435 \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0430\u043a\u0436\u0435 \u043a \u0437\u0435\u043c\u043b\u0435 \u043d\u0430 \u0434\u0430\u0442\u0447\u0438\u043a\u0435 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u0438\u043d\u0438\u0439 \u043f\u0440\u043e\u0432\u043e\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043f\u0438\u043d, \u0441 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 GPIO + \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043d\u043e\u043c\u0435\u0440. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u0435\u043d\u0441\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e GPIO26.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e python-\u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0438 \u043a\u0430\u043c\u0435\u0440\u044b. \u0412\u044b\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Raspberry.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PIR-\u0441\u0435\u043d\u0441\u043e\u0440\u0430:<\/p>\n<pre><code class=\"python\">from gpiozero import MotionSensor from datetime import timezone  pir = MotionSensor(26) while True:         pir.wait_for_motion()         dt = datetime.datetime.utcnow()         st = dt.strftime('%d.%m.%Y %H:%M:%S')         print(\"Motion Detected at : \" + st)<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0431\u044b\u043b\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Wi-Fi \u0441\u0438\u0433\u043d\u0430\u043b\u044b, \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u044f \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c false-positive \u043e\u0448\u0438\u0431\u043a\u0438 \u2014 \u043b\u043e\u0436\u043d\u043e\u0435 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438, \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u0440\u043e\u0432\u043d\u043e \u0440\u0430\u0437 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443. \u041f\u043e\u0447\u0438\u0442\u0430\u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u0443\u043c\u044b, \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u043b\u044c\u0433\u043e\u0439:<\/p>\n<figure class=\"full-width\"><figcaption>\u041a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e.<\/figcaption><\/figure>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0436\u0435 \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430.&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u043c\u0430\u043b\u0438\u043d \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0438 \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e), \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0442\u0443\u0442 \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c UUID. \u041f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0444\u0430\u0439\u043b device_uuid. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"python\">import uuid  def getDeviceId():     try:         deviceUUIDFile  = open(\"device_uuid\", \"r\")         deviceUUID = deviceUUIDFile.read()         print(\"Device UUID : \" + deviceUUID)         return deviceUUID     except FileNotFoundError:         print(\"Configuring new UUID for this device...\")         deviceUUIDFile = open(\"device_uuid\", \"w\")         deviceUUID = str(uuid.uuid4())         print(\"Device UUID : \" + deviceUUID)         deviceUUIDFile.write(deviceUUID)         return deviceUUID<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a MQTT \u0431\u0440\u043e\u043a\u0435\u0440\u0443:<\/p>\n<pre><code class=\"python\">import paho.mqtt.client as mqtt  mqttClient = mqtt.Client(\"P1\") mqttClient.loop_start() # \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0435\u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432  mqttClient.connect(BROKER_ADDRESS)<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 while-true \u0446\u0438\u043a\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c json \u0432\u0438\u0434\u0430:&nbsp;<\/p>\n<pre><code class=\"json\">{   \"device_id\": \"123e4567-e89b-12d3-a456-426614174000\",   \"id\": \"133d4167-18ds-11d1-b446-826314134110\",   \"place\": \"office_room\",   \"filename\": \"133d4167-18ds-11d1-b446-826314134110_alarm.mp4\",   \"type\": \"detected_motion\",   \"occurred_at\": \"01.01.2021 20:19:56\u00bb }<\/code><\/pre>\n<p>\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 MQTT \u0431\u0440\u043e\u043a\u0435\u0440:<\/p>\n<pre><code class=\"python\">MP4_VIDEO_EXT = '.mp4'  alarmUUID = str(uuid.uuid4())         filename = '{}_alarm'.format(alarmUUID)         message = json.dumps({                                 'device_id': deviceUUID,                                 'id': alarmUUID,                                 'place': 'office_room',                                 'filename': filename + MP4_VIDEO_EXT,                                 'type': 'detected_motion',                                 'occurred_at': st                                 }, sort_keys=True)         mqttClient.publish(\"raspberry\/main\", message)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e. \u0421\u0440\u0430\u0437\u0443 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043c\u0435\u0440\u044b.<\/p>\n<pre><code class=\"python\">import picamera  VIDEO_TIME_SEC = 15 FILE_DIR = 'snapshots\/' MP4_VIDEO_EXT = '.mp4' H264_VIDEO_EXT = '.h264' camera = picamera.PiCamera() camera.resolution = 640,480  def record(filename):     h264_file = filename + H264_VIDEO_EXT     print(\"Recording : \" + h264_file)     camera.start_recording(h264_file)     camera.wait_recording(VIDEO_TIME_SEC)     camera.stop_recording()     print(\"Recorded\")          # \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u043e\u0434\u043d\u043e\u043c mp4     mp4_file = filename + MP4_VIDEO_EXT     command = \"MP4Box -add \" + h264_file + \" \" + mp4_file     print(\"Converting from .h264 to mp4\")          call([command], shell=True)     print(\u00abConverted\")<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0438\u0434\u0435\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 MinIO. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 MinIO, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430. \u041e \u0441\u0430\u043c\u043e\u043c MinIO \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<pre><code class=\"python\">from minio import Minio from minio.error import S3Error  MINIO_HOST = \u00ab0.0.0.0:443\u00bb BUCKET_NAME = \u2018raspberrycamera\u2019 client = Minio(         MINIO_HOST,         access_key=\"minio\",         secret_key=\"minio123\",         secure=False     ) found = client.bucket_exists(BUCKET_NAME) if not found:     client.make_bucket(BUCKET_NAME) else:     print(\"Bucket {} already exists\u00bb.format(BUCKET_NAME))  def sendToMinio(filename):     try:         print(\"Sending to minio\")         client.fput_object(             BUCKET_NAME, filename, FILE_DIR + filename         )         print(\"Video has been sent\")     except Exception as e:         print(e)         print(\"Couldn't send to Minio\u00bb) <\/code><\/pre>\n<h2>\u0421\u0435\u0440\u0432\u0438\u0441 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0447\u0430\u0441\u0442\u043a\u0443 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2013 \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u043e\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0444\u0438\u043a\u0430 \u043e\u0442 Rasbperry \u0438 \u00ab\u0443\u043a\u043b\u0430\u0434\u043a\u0430\u00bb \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u043c\u0443 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0443\u043b\u043e\u0436\u0438\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 Docker \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e docker-compose:<\/p>\n<pre><code class=\"python\">version: '3.1' services:   app:     restart: on-failure     build:       context: .       dockerfile: Dockerfile     environment:       POSTGRES_URL: \"jdbc:postgresql:\/\/database:5432\/alarms\"       POSTGRES_USER: \"postgres\"       POSTGRES_PASSWORD: \"changeme\"        MQTT_BROKER_HOST: \"mosquitto\"       MQTT_BROKER_PORT: \"1883\"       MQTT_BROKER_TOPICS: \"raspberry\/main\"        MINIO_HOST: \"https:\/\/minio\"       MINIO_PORT: \"443\"       MINIO_ACCESS_KEY: \"minio\"       MINIO_SECRET_KEY: \"minio123\"       MINIO_BUCKET: \"raspberrycamera\"     ports:       - \"8080:8080\"     depends_on:       - database     links:       - database   database:     container_name: database     image: postgres     ports:       - \"5432:5432\"     environment:       - POSTGRES_PASSWORD=changeme       - POSTGRES_USER=postgres   <\/code><\/pre>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-318281","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318281"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318281\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}