Pi based Server

AndyMOTE

Control all your infra-red devices from one Mobile App
This article describes how to construct and configure a Raspberry Pi based AndyMOTE Server consisting of:
  • RaspberryPi (Model 3B+ recommended)
  • 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)
*Requires USB Power

AndyMOTE Server

The AndyMOTE Server connects to the AndyMOTE App through a local network as shown in the diagram. The Server also connects to an LIRC subsystem which provides the infra-red signals that control the devices in your system.

An Infrared Remote Control Extender (eg: Neoteck IR Repeater) allows you to hide away your server in a cabinet or behind your media system and control your devices without direct line of sight.

Before You Start

You will need a Monitor, a Keyboard and cables capable of connecting these items to your Raspberry Pi unless you intend to connect using ssh (see below)

Download and install Raspian Stretch-Lite or Raspian Buster-Lite to your SD Card. Note that this article will not work with Raspian-Jessie.

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.

If you wish to connect using ssh, create an empty file /boot/ssh (this enables SHH on the server). You can also configure ethernet static addressing, at this stage, if desired, as described below.

Next, 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=gpio-ir,gpio_pin=18
dtoverlay=gpio-ir-tx,gpio_pin=17

The following settings might be better for you if using a tv to display:

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16
hdmi_drive=2
hdmi_pixel_encoding=1
hdmi_ignore_edid=0xa5000080
config_hdmi_boost=7
disable_overscan=1
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17

For guidance on hdmi settings please visit here.








Pi3 based Server

Assembly

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. Ensure that the LEDs on the ENER314-IR are not obstructed (Modify case if necessary)

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.

Overclocking

If you are using a Raspberry Pi 1 you should overclock to Turbo setting.

In a terminal on the Raspberry Pi, issue the command

$ sudo raspi-config

Select the option Overclock, a message informing you about the dangers of overclock appears

Choose the Turbo option (1000MHz). A message informing you of the change appears

Choose Finish, a message will ask you if you want to restart,

Restart and wait for the unit to boot up.

Set-up WiFi Network

It is recommended that your connection to your Andymote Server uses Ethernet rather than WiFi if possible.

If you do not require WiFi you can skip this step.

You can do this using raspi-config; or manually as follows:

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"
}

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

Set-up Static Wifi IP Address

If you do not require WiFi you can skip this step.

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.

Set-up Static Ethernet IP Address

(Not applicable to Raspberry Pi Zero or Raspbery Pi Model A)

It's recommended that your server has a fixed IP Address and that your Andymote System uses Ethernet rather than WiFi if possible.

You may be able to achieve a static ip address by configuring your DHCP server appropriately or, to set the eth0 interface to a static address on the Raspberry Pi, edit the file /etc/dhcpcd.conf and include the lines .

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.110/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
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.110 to the actual static address you require for your application.

Reboot when done.

Install LIRC

Update & upgrade your installation & install LIRC using the commands.

$ sudo apt update
$ sudo apt -y upgrade
$ sudo apt -y install lirc

If you are installing on Raspian Buster

The installation of lirc (above) will fail. Don't panic. Do this.

$ sudo cp /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf

Update the following lines in /etc/lirc/lirc_options.conf:

driver = default
device = /dev/lirc0

Finish installation of LIRC (It should not error this time):

$ sudo apt -y install lirc

Create file /etc/lirc/lircd.conf and make it look like this:

# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.

include "lircd.conf.d/*.conf"

LIRC Configuration


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

Testing the IR Receiver

Enter the following sequence of commands to stop the LIRC Daemon and test the receiver.

$ sudo systemctl stop lircd
$ sudo mode2 --device /dev/lirc1

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

Add Remotes

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

When you have finished adding your .conf files rename the devinput.lircd.conf file thus:

$ sudo mv devinput.lircd.conf devinput.lircd.conf.dist

Method 1

You can create your own config files, using the original remote control, quite simply using the following commands:

$ sudo systemctl stop lircd
$ sudo irrecord -n ~/FILENAME.conf
-- OR --
$ sudo irrecord -f -n ~/FILENAME.conf

Replace FILENAME with some discriptive 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

Method 2

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.

Install AndyMOTE Server

There are two versions of AndyMOTE Server available; Legacy server (no longer supported) and QT Server. Click the appropriate link for installation instructions.

Install Mosquitto MQTT Server (Optional)

MQTT allows AndyMOTE to publish it's current activity state to other systems (for example Home Assistant).

To install Mosquitto do the following:

$ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
$ sudo apt-get update
$ sudo apt-get -y install mosquitto
$ sudo apt-get -y install mosquitto-clients

For more info read the AndyMOTE manual.