/TV-auto-on-off

Using Xethru X4M300 to detect human presence, and turn on/off TV through HDMI CEC by Raspberry Pi.

Primary LanguagePython

Introduction

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.

Demonstration

Two demonstrations showing how this system work.

  1. Backend running https://youtu.be/6rI6X9ovETM

  2. Automatically turn on TV (turn-off does not test since TV problem ) https://youtu.be/_CS3PpktUMc

Hardware connection

TVauto

connection

Development Environment

  • Raspberry Pi3
  • Raspbian: v4.9
  • Python: v2.7
  • labcec: v4.0.2
  • X4M300 ModuleConnector: rpi-1.1.8

Deployment

  1. 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
  1. 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
  1. 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).

  1. 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.

References

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