コロナ禍やそれ以降、テレワークを一定の頻度で行う中、自宅で仕事をするときは運動不足になりがちでした。
会社に出社した時と比べると、明らかに歩数や運動量が劇的に少なかったです。
それを解消しようと、例えば「同じ場所から長時間動いてない状態(また、少し離席することはあってもきちんと休憩していない状態)を検知して、何か運動を促すような音楽・動画を流したら良いのではないか」というのをずっと前から思っていました。
(ラジオ体操の動画とか流すと、子どもの頃に体にしみついた習慣により、自然と体を動かす気になったりするのではないか、と思ったり)
そう思いつつ、実現方法をあまり考えていませんでした。しかし、ふと PC やスマホからの動画のキャストを行える Google の Chromecast に API があったら、通信経由でのアクションをトリガーにした動画再生ができるのではないか、と思いました。
そして、調べてみたら「Google Cast API (Google Cast Web Sender API)」という API や、それを使いやすくするライブラリがあるようだったので、今回の仕組みを作ってみました。
過去に、IoT系の試作をするのに「M5Stack系のデバイスによる HTTPリクエスト/MQTT での通信処理」と、「それの受け側になるサーバー/仲介役になる MQTTブローカーの実装」などは何度も作ってみていたので、そのノウハウも活用しつつ試作しました。
動画は、自前でホスティングした動画でも、YouTube上で公開されている動画でも使えるので、自分好みの動画を使うことができます。
The COVID-19 situation and subsequent teleworking on a constant basis, I tended to get less exercise when working from home.
The number of steps I took and the amount of exercise I got were obviously dramatically less than when I came to work at the office.
In an attempt to solve this problem, I had long thought that it would be a good idea, for example, to play some kind of music or video that would detect the state of not moving from the same place for a long period of time (and not taking a proper break, even if you leave your seat for a short time) and encourage exercise.
I thought so, but had not really thought about how to realize it. However, it occurred to me that if Google's Chromecast, which allows users to cast videos from PCs and smartphones, had an API, it would be possible to play videos triggered by actions via communication.
I looked into it and found that there is an API called “Google Cast API (Google Cast Web Sender API)” and a library that makes it easy to use, so I created this mechanism.
In the past, I had tried many times to prototype an IoT system by creating “HTTP request/MQTT communication processing by M5Stack devices” and “implementation of a server to receive the requests/MQTT broker to act as an intermediary”, so I used that know-how to create this prototype.
You can use your own hosted videos or videos available on YouTube.
画像素材:●かわいいフリー素材集 いらすとや
https://www.irasutoya.com/
音素材:●BGM | 無料 BGM・効果音のフリー音源素材 | Springin’ Sound Stock
https://www.springin.org/sound-stock/category/bgm/
今回の作品に必要なデバイスは以下のとおりです。
必要なものは、「人がある場所に一定時間とどまっているかを判断できるセンサー = 距離センサー/人感センサー など + センサーを扱える通信機能付デバイス」と「通信経由での外部からのアクションに反応して動画再生を行えるデバイス」、そして「それらのデバイス間の通信の仲介役」です。
そして、上記を実現するために今回用いた技術などは以下のとおりです。
以下がデモ動画です。
本来は、例えばセンサーが反応する範囲に連続して 1時間滞在した場合(そして、数分の離席など短い時間の不在は、連続滞在中と見なすなどとする)、体を動かすように促すため動画再生を実行とします。
しかし、以下のデモ動画ではその部分は時間の都合で、「ある程度の限られた時間だけセンサーが反応する範囲にいたら動画を再生する」という挙動にしています。
●【デモ動画】フィットネスアシスタントガジェット - Fitness Assistant Gadget - YouTube https://www.youtube.com/watch?v=J48dPBleQqI
なお、上記のデモ動画内でのエクササイズ動画は、既存のものを勝手に用いるのはまずいかもしれないと思い、念のため以下の自作のダミー動画としています。
●おうちでできるエクササイズ!【デモ動画用】 - YouTube https://www.youtube.com/watch?v=WRay0ltUoUQ
The following devices are required for this work.
The system requires a “sensor that can determine whether a person stays in a certain location for a certain period of time (distance sensor, PIR motion sensor, etc.) + a device with a communication function that can handle the sensor,” a “device that can play video in response to actions from outside via communication,” and a “mediator for communication between these devices”.
The technologies used to realize the above mechanisms are as follows
The following is a demonstration video.
Originally, for example, if a user stays within the range where the sensor responds for an hour continuously (and a short absence, such as a few minutes, is considered as a continuous stay), the video is played to encourage the user to move his/her body.
However, in the following demo video, this part is time-consuming, so the behavior is “play a video if the user is within the range where the sensor responds for a certain limited time.
Demo Video: Fitness Assistant Gadget - Fitness Assistant Gadget - YouTube https://www.youtube.com/watch?v=J48dPBleQqI
The exercise video in the above demonstration video is a dummy video of my own making as follows, just in case it might be bad to use an existing one without permission.
Exercises you can do at home :For demonstration video - YouTube https://www.youtube.com/watch?v=WRay0ltUoUQ