ESP8266 Alexa IR Blaster

I have hacked a Broadlink RM3 Mini to replace its BL3332-P controller with a ESP8266 in the form of a Wemos D1 Mini.

The RM3


BL3332 Removed

BL3332 Pinout

RM3 Wiring

D1 Mini Wiring

Hot glued

Ready to assemble


The IR configuration file is just a JSON format file like below.

	"devname": "ESP_Alexa",
	"devices": [
			"name": "Television",
			"decode_type": 7,
			"repeat": 3,
			"bits": 32,
			"on": "E0E09966",
			"off": "E0E019E6"
			"name": "Mute",
			"decode_type": 7,
			"repeat": 1,
			"bits": 32,
			"on": "E0E0F00F",
			"off": "E0E0F00F"
			"name": "Freeview",
			"decode_type": 3,
			"repeat": 5,
			"bits": 32,
			"on": "DF0800FF",
			"off": "DF0800FF"
			"name": "Satellite",
			"decode_type": 3,
			"repeat": 3,
			"bits": 32,
			"on": "5F0830CF",
			"off": "5F0800FF"
			"name": "Abox",
			"decode_type": 3,
			"repeat": 3,
			"bits": 32,
			"on": "00FB38C7",
			"off": "00FB38C7"

That contains the 'devname' for MQTT and then an array of devices that are for the excellent Espalexa library.
The array has a 'name' that will be the name you call in Alexa and the rest of the fields are used by the IR blaster to define the IR codes to send to turn the device on/off.

Attached below is the sketch and example ‘mqttSettings.h’ that need adjusting to match your MQTT broker.

Use ESP Alexa lib to control hacked Broadlink RM3 Mini IR Blaster

Configuration of Alexa device names and IR codes is via irconfig.json file stored in SPIFFS and you can also control devices using MQTT

On first run the ESP8266 will create an access point (ESP_AlexaWM) where you enter the WiFi credentials and MQTT broker details.

After the WiFi has connected the ESP8266 tries to load a irconfig.json file from SPIFFS that contains the device name (used for MQTT) and also an array of Alexa device names and IR on/off control codes.

If no config.json file exists or it fails to load correctly then a MQTT topic that is compounded from ESPALEXA basename + “/BLANK” + (ESP.getChipId(), HEX) is created and connected to the broker. This allows a MQTT channel back to a blank device so a irconfig.json file can be uploaded.

If the irconfig file loads correctly then after reboot (also doable over MQTT) the MQTT topic will be ESPALEXA + “/” + devname

MQTT control topics are… ESPALEXA + “/” + devname + “/” + name + “/Set” with a payload of the value (0-255) to set for the Alexa name device.

ESPALEXA + “/” + devname + “/” + name + “/Get” will return the Alexa name device state in payload. This will be invalid for the first call and may not reflect the true state of the device if it did not receive the last IR transmission.

ESPALEXA + “/” + devname + “/Pull” will return the irconfig.json file from SPIFFS.

ESPALEXA + “/” + devname + “/Push” with the payload of a irconfig.json file will create/overwrite the config.json file in SPIFFS.

ESPALEXA + “/” + devname + “/Reset” will start a 5 second countdown to the ESP8266 resetting.

The last two topics are mostly used for testing and user should probably remove from finished project

ESPALEXA + “/” + devname + “/WipeSPIFFS” will format the SPIFFS filesystem and reboot the ESP8266.

ESPALEXA + “/” + devname + “/Mem” will return the free heap space. Used for testing for memory leaks.

If the IR receiver detects IR transmissions then it will try to decode the IR format and send results to MQTT. This allows you to get the thing running and then interogate the on/off IR codes for the devices to be edited into a irconfig.json that can then be uploaded over MQTT.

ESP_Alexa_RM3.ino (26 KB)

mqttSettings.h (292 Bytes)

Attached is a very basic Node-Red flow that demos how you can interact with the ESP_Alexa_RM3 to read/send irconfig.json files. Operate IR devices and request (expected) device state over MQTT.

I have not included detailed flows but as an example of the way you can compound command is to listen for a device on/off command and also send on/off commands for the TV.

Things for the future is to add ability to send (unknown to ESP_Alexa_RM3) IR codes direct from MQTT so I could do something like...
"Alexa switch on Satellite" and Node-Red would detect this and also send IR codes to turn on the TV and switch its input to the Satellite box.

You do not need to use the Broadlink RM3 Mini for this. The below image has two alternatives.
The one on the left is home made and has good IR range but is to directional. The one on the right is an off the shelf shield for the D1 that has 4x IR LEDS but the range is very poor.

A word of caution for people who decide to go the Broadlink route is the newer RM4 mini is to small to comfortably fit the D1 mini.

ESP_Alexa Node-Red.txt (38.9 KB)