Introduction: AndyMOTE Server
I wanted a universal remote control for my mancave and figured that I should be able to do this with an app on my mobile phone (to provide the User Interface) and a Raspberry PI to provide the Infra Red 'Blaster'. After a little investigation I discovered the LIRC project which looked ideal for the 'Blaster'. I wrote my own Android App (AndyMOTE) and a small 'Server' Program to provide an interface between the two.
This instructable shows you how to build the server
The instructions given here should work with Raspian Jessie, they do not work with Raspian Buster and, at this point, I understand that Raspian has now been replaced with the Raspberry Pi OS, I have an updated set of instructions on my website (see link below) that work with Raspian Stretch-Lite or Raspian Buster-Lite https://andymote.abondservices.com/server.html
Step 1: Items List
- RaspberryPi Zero WH
- Energenie ENER314-IR Infra Red Controller
- Micro SD Card (Class 10) (16GB)
- Raspberry Pi Power Supply
- (Optional) Case (eg: Pibow Zero W)
- (Optional) Infrared Remote Control Extender* (1 Receiver; 4 Transmitters)
You will also need a Monitor, a Keyboard and cables capable of connecting these items to your Raspberry Pi
Step 2: Prepare Your Raspberry Pi
Download Raspian Lite from here then install it on your SD Card (Instructions here).
Once Raspian Lite is installed on your SD Card and before you move the card to your Raspberry Pi; mount the card on your PC. Create an empty file /boot/ssh (this enables SHH on the server) and make the following edits to file /boot/config.txt
# Set HDMI to Normal output
hdmi_drive=2
# Set HDMI to DMT Mode (sutable for Monitors)
hdmi_group=2
# Set Resolution to 800x600 @ 60hz
hdmi_mode=9
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17
(See here for guidance on video settings)
Step 3: Assemble the Server
First, insert your pre-prepared SD Card into the Raspberry Pi.
Put the Raspberry Pi into it's case. I had an issue that the ENER314-IR Infra Red Controller interfered with the Pibow case so did not use two of the pieces.
Next, plug the Energenie ENER314-IR Infra Red Controller into the Raspberry Pi (see picture).
Then, connect the Raspberry Pi to keyboard (using USB connector) and monitor (using HDMI connector... Adapters may be necessary).
Finally, power up and wait for the unit to boot.
Step 4: Setup Network
First, Open the wpa-supplicant configuration file using your favorite editor (eg nano).
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Goto the end of the file and add your network (eg).
network={
ssid="YOUR_SSID"
psk="YOUR_KEY"
priority="1"
id_str="YOUR_SSID_NAME"
}
Replace YOUR_SSID, YOUR_KEY and YOUR_SSID_NAME as appropriate for your network.
Save the file, restart the WPA supplicant and reboot.
$ wpa_cli -i wlan0 reconfigure
$ sudo reboot
Step 5: Setup Static IP Address
It's recommended that your server has a fixed IP Address.
You may be able to achieve this by configuring your DHCP server appropriately or, to set the wlan0 interface to a static address on the Raspberry Pi, edit the file /etc/dhcpcd.conf and include the lines .
# Example static IP configuration:
interface wlan0
static ip_address=192.168.1.116/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
Change 192.168.1.1 to the actual address of your router and 192.168.1.116 to the actual static address you require for your application.
* You may wish to run the raspi-config utility and make any configuration changes at this point.
Reboot when done.
Step 6: Install LIRC
Install LIRC using the command.
$ sudo apt-get install lirc
Edit the /etc/modules file; eg:
$ sudo nano /etc/modules
and add the lines:
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
Save the file and reboot.
$ sudo reboot
Step 7: Configure LIRC
Edit the /etc/lirc/hardware.conf file, eg:
$ sudo nano /etc/lirc/hardware.conf
and make it look like this:
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput --listen"
#
# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false
#
# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false
#
# Try to load appropriate kernel modules
LOAD_MODULES=true
#
# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
#
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
#
# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
Edit the /etc/lirc/lirc_options.conf file and modify lines as below:
driver = default
device = /dev/lirc0
Save the file and restart lircd.
$ sudo systemctl restart lircd
Step 8: Testing the Receiver
Enter the following sequence of commands to stop the LIRC Daemon and test the receiver.
$ sudo systemctl stop lircd
$ sudo mode2
The mode2 program will output the mark-space ratio of an IR Signal to the console. Point a remote control at your IR receiver and press some buttons. You should see something like this:
space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
when you are done press ctl-c and restart the LIRC Daemon using the following command.
$ sudo systemctl start lircd
Step 9: Add Remotes - Method 1
LIRC uses configuration files that contain data relating to each remote control that can be emulated by LIRC. You must generate or otherwise provide these configuration files in order for the LIRC subsystem to work as desired.
Important
You must provide an individual config file for each remote to be emulated.The config files must be stored in directory /etc/lirc/lircd.conf.d. Choice of Key Name is important for the best AndyMOTE experience, when selecting names for your keys, please follow the guidelines here. Config files can also be downloaded from here but beware that, if you use them, they must contain only one remote configuration. (Config files are simple text files and can be easily edited if necessary.
Method 1 requires the original remote control using the following commands:
$ sudo systemctl stop lircd
$ sudo irrecord -n ~/FILENAME.conf
-- OR --
$ sudo irrecord -f -n ~/FILENAME.conf
Replace FILENAME with some descriptive name for the remote control you are configuring. The latter command creates a 'raw' file and this is sometimes needed depending on the characteristics of remote control you are using. The -n switch allows you to you to use any keyname you like (rather than be limited to the LIRC Namespace list).
Remember to restart lircd and reboot when you are done.
$ sudo systemctl start lircd
$ sudo reboot
Step 10: Add Remotes - Method 2
Method 2 does not require the original remote
Global-cache maintain a cloud based database of over 200,000 IR Codes. Anyone can register and download up to 5 codesets per day. These codesets can be converted to LIRC conf files, in an AndyMOTE friendly way, using the gcConvert application described here.
Step 11: Install the AndyMOTE Server Program
Install Libraries liblirc and libboost as described below:
$ sudo apt-get update
$ sudo apt-get install liblirc-dev libboost-all-dev
Next, install git, goto your home directory & clone the andymoteserver repository
$ sudo apt install git
$ cd ~
$ git clone https://github.com/orangereaper/andymoteserver
then compile the source
$ cd andymoteserver
$ make
Move the resulting file to a convenient location; eg:
$ sudo mkdir -p /opt/andymoteserver
$ sudo mv dist/Debug/GNU-Linux/andymote /opt/andymoteserver/
Tidy up
$ cd ~
$ rm -Rf andymoteserver
Finally, to run AndyMOTE Server as a service, create the file /lib/systemd/system/andymote.service with content as shown below:
[Unit]
Description=run AndyMOTE Server as a service
[Service]
Type=simple
RemainAfterExit=false
Restart=always
RestartSec=30
ExecStop=/bin/true
ExecStart=/opt/andymoteserver/andymote
[Install]
WantedBy=multi-user.target
Enable and start the service
$ sudo systemctl enable andymote
$ sudo systemctl start andymote
Step 12: And Finally...
The above picture shows my server in its final position (left). The device on the right of the photo is the Infrared Remote Control Extender, this receives the IR signals from the server and re-transmits them via 4 IR transmitters (not shown); these are mounted on my media devices, (TV, Amplifier etc).
I hope you enjoy!
3 Comments
Question 2 years ago on Step 7
In step 8 after $ sudo mode2 I become a message:
Using driver devinput on device auto
Cannot initiate device auto
What is the problem?
Answer 2 years ago
The instructions given here should work with Raspian Jessie, they do not work with Raspian Buster and, at this point, I understand that Raspian has now been replaced with the Raspberry Pi OS, I have an updated set of instructions on my website (see link below) that work with Raspian Stretch-Lite or Raspian Buster-Lite
https://andymote.abondservices.com/server.html
4 years ago
Very nice job on your first Instructable :)