The purpose of this design is using Xethru X4M300 sensor to detect human presence state at one place and turn on/off TV according to this state through HDMI-CEC, the whole project is deployed on Raspberry Pi.
Two demonstrations showing how this system work.
-
Backend running https://youtu.be/6rI6X9ovETM
-
Automatically turn on TV (turn-off does not test since TV problem ) https://youtu.be/_CS3PpktUMc
- Raspberry Pi3
- Raspbian: v4.9
- Python: v2.7
- labcec: v4.0.2
- X4M300 ModuleConnector: rpi-1.1.8
- Install labcec on Raspbian, following instructions on this website, cec-client will also be installed. The python-libcec library may not be installed correctly, running following command can add python-libcec manully.
$ sudo apt-get install python-libcec
- Download X4M300 module connector from XeThru Community. Install python library pymoduleconnector by running the following command from the pymoduleconnector root directory:
$ python setup.py install
- Connecting equipment according to Hardware Connection. The serial interface connecting X4M300 can be identified by running:
$ dmesg | grep tty
The name of the serial interface looks like ttyACM0(in my situation).
- Download TVauto.py from this repository. Run
$ python TVauto.py -d /dev/ttyACM0
ttyACM0 should be replaced by your serial interface name. The default human presence detection range is 0.5-1.5M.
If evey step goes smoothly, it will cost one hour to deploy and test this application.
X4M300:https://www.xethru.com/x4m300-presence-sensor.html
HDMI-CEC:https://en.wikipedia.org/wiki/Consumer_Electronics_Control
labcec:https://github.com/Pulse-Eight/libcec
CEC commands: http://www.cec-o-matic.com/
Using cec-client and libcec on Respberry Pi: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=53481