Raspberry Pi Broadlink RM Pro

Posted on Sun 24 June 2018 in RaspberryPi

This one got me excited. Sending commands from the Raspberry Pi to the Broadlink RM Pro.

I don’t know why I hadn't tried before, I'd always stuck to circuitry. I think in this case it was down to necessity.

I was building a remote controller, had successfully built an IR transmitter/receiver circuit but wasn't satisfied, it was too weak and untidy to be of any proper use. I immediately turned to my Broadlink RM Pro.

After some Googlemashing, I came up with the below.

Start Here:

Broadlink Guide

I was able to get from start to finish without too many errors. I did fall flat installing at one point but a quick apt-get update solved the problem.

I'll CP the code :

#!/bin/bash

sudo su

cd /home/pi

mkdir rm3

cd rm3

apt-get update

apt-get -y install python-dev

apt -y install python-pip

apt-get -y install git

git clone https://github.com/mjg59/python-broadlink.git

cd python-broadlink/

python -m pip install pycrypto

python -m pip install netaddr

wget https://bootstrap.pypa.io/get-pip.py

python setup.py install

Once finished CD into your /rm3/python-broadlink/cli folder and

sudo ./broadlink_discovery

This will start searching for your Broadlink device.

I found during the initial set up, you needed to be on the same WiFi network, once the initial discovery had taken place, disconnecting the Pi from WiFi, leaving on LAN was fine.

My output looked like this:

########################################### RM2.

# broadlink_cli --type 0x272a --host 192.168.10.111 --mac 3516d10d43b4

Device file data (to be used with --device @filename in broadlink_cli) :

0x272a 192.168.10.111 3516d10d43b4

temperature = 27.7

###########################################

RM2

# broadlink_cli --type 0x279d --host 192.168.10.15 --mac c9e94234ea34

Device file data (to be used with --device @filename in broadlink_cli) :

0x279d 192.168.10.15 c9e94234ea34

temperature = 0.0

I had two connected to the same WiFi network at the time. This identification came in handy for a project-in-work.

Once you've discovered, you'll need to learn and test a few codes:

sudo ./broadlink_cli --type 0x2712 --host **replace IP** --mac **replace MAC** --learnfile **name of.key**

You will see the orange learning light on the RM Device.

Once learnt, the code will save it's self in the same folder, you can execute using:

sudo ./broadlink_cli --type 0x2712 --host **replace IP** --mac **replace MAC --send **name of.key**

sudo ./broadlink_cli --type 0x2712 --host **replace IP** --mac **replace MAC --send **name of.key**

Another thing to note, possibly incorrect or irrelevant, same IP different MAC. A typo when testing. Only e9c9 was connected.

Having tested, you do need a MAC address, or possibly just a twelve digit hexadecimal string.

Scripts

I host a webpage with buttons on it. The buttons link to php scripts which call the python scripts.

buttona.py

import os
os.system ("cd /rm3/python-broadlink/cli && sudo ./broadlink_cli --type 0x2712 --host 192.168.10.110 --mac 3516d10d43b4 --send @key.a")

buttona.php

<?php
system("sudo python /var/www/pihome/public_html/buttona.py"); header("Location: http://ipaddress:port/page.php");
?>