RF Ceiling Fan Remote Hack

Hi Folks,

So seems like a number of people in the NEEO (and various other home automation worlds) have had issues with ceiling fan control. So here are the steps i went through in order to highjack the RF remote.

Note if your remote is 433MHz there is a strong chance you can just buy an RF bridge (like the SONOFF RF Bridge), and by sending an http request to the bridge it will send the required RF signal.

If however like me you have a 303MHz (cheap crap) remote, then you’ll need to dust off the soldering iron.

<First up, I am documenting the process I went through - you may have a different fan, or you may have different components - so please check everything before proceeding. I take no responsibility for any damage to ANYTHING if you decide to replicate these steps>

NOTE - I use Wink for Z-wave, and i bring everything together with Home Assistant ( http://Hass.io ). However you can add the z-wave in-wall switch to NEEO. I’m assuming you already have the fan power configured (On/Off) - if not you will need to do that first.

What you will need (a soldering iron & solder obviously)

1 x ESP8266 12 Chip http://a.co/2gBBJq9 [For speed control]

1 x 5V to 3.3V DC voltage regulator http://a.co/ahhJsZl

1 x Pack of breadboard & wires http://a.co/64jNdyN

1 x USB FTL http://a.co/6aCINO5

1 x USB 5 pin connector http://a.co/0lYfNLK (and microUSB cable)

1 x Z-wave in wall microswitch http://a.co/e4f972y [For power - if you dont already have something in place - full wall z-wave switch for example]

Step 1:

Wire up the ESP8266 Chip so you can flash it with the Tasmota firmware. You can write your own firmware, but I do not have the patience :wink: (see Wiring Diagram below)


I used breadboard to wire and test, then flash the chip

NOTE - the black dotted line. YOU HAVE TO CONNECT THIS WHEN YOU POWER UP THE CHIP TO PUT IT IN FLASH MODE, and then you can remove it. If you’re fancy you can put a switch here to jump GPIO 0 to GND.

The best tutorial to flash the firmware is here:

be sure to edit user_config.h with your wifi settings (the rest is less important as you can edit from the web interface it puts on the device). After, check it powers and you can connect to the IP address (go into your wifi router and look for the device named sonoff-xxxx, then type that IP address in your browser).

Step 2:

Prepare the fan remote to be highjacked :slight_smile:

On most remotes the PCB is so cheap they leave optional pin headers for more expensive models. Trace the button you want to highjack and you’ll see pressing the button connects that pin to ground. So we are basically going to do the same thing on command.


The Tasmota firmware only has the function for 4 relays - we are only going to use 3 (slow, medium and fast). The power to the fan is controlled via the in wall z-wave microcontroller - i’m not posting instructions on that - but you should connect it to whatever Z-wave controller you plan to use like NEEO (or HomeAssistant).

I also took this opportunity to remove the battery cables, and resolder wires that can connect it to the breadboard.

Step 3:

Connect the ESP8266, the fan remote, voltage regulator and USB power (still on breadboard for testing)

NOTE Seeing as i had used Tx/Rx for flashing, I kept those wires and used the GPIO pins for the fan control. I just added an extra connection to the ESP8266 GPIO14 for the final fan button.

Note - the USB provides 5V - the fan remote is pretty resilient and runs at actually 3.3 to 9V. However the ESP8266 should be 3.3V.

Step 4:

Customizing the Tasmota firmware on the device.

Plugging in the USB power should now bring up the chip’s web interface. Go back into your router and find its IP address (i also took this opportunity to set a static IP as you will be sending commands to a specific address later and dont want it changing).

you will be greeted with this page (your IP address will be different)


Click Configuration

Then Module configuration

which will give you the options to set how the ESP8266 is connected. In our case you need to select the following from the drop down box.

above image is from the web (credit sigmdel.ca) - NOT SWITCH:

GPIO1 (Serial Out) = Relay2i

GPIO3 (Serial In) = Relay3i

GPIO14 = Relay4i

This will allow an MQTT command or http request to be sent and trigger the power on or off of the ‘relays’.

Tasmota Purists will probably find a better way to customize the firmware so when a switch is triggered it will do so briefly and then power off. However we will configure the behaviour upstream in home assistant.

You will now see this after the ESP8266 reboots:

0%20(3)

For some reason IE misaligns the buttons, so use Chrome here.

Clicking on the Toggle 2 turns the Fan LED on, and then clicking it again will turn it OFF. As long as the fan LED is on, the RF signal is being transmitted, so you want to turn it off again before sending a different command. You should now test this with your fan.

Step 5:

Shrink all the wiring down and connect point to point without breadboard, drill a hole in the base of the remote for the USB power - I used a dremel. There is a battery compartment so you dont need to do this.

move to fan location, and using a 5V USB plug (not sure about you, but i have loads of these lying around) connect to the USB power

Step 6:

Integrate with home automation system. If you know how to use MQTT then you can just skip this step.

The ESP8266 with Tasmota firmware can take http requests:

http:///cm?cmnd=Power2%20On
http:///cm?cmnd=Power2%20off

Test these out in a browser replacing Power2 with Power3 or Power4 for the different fan buttons.

For this to function best I wrote 3 items PER button.

The Rest_command:

rest_command:
  fan_slow_on:
    url: 'http://<your IP Address>/cm?cmnd=Power2%20On'
  fan_slow_off:
    url: 'http://<your IP Address>/cm?cmnd=Power2%20Off'

The Switch:

switch:
  - platform: template
    switches:
      fan_slow:
        value_template: "{{ is_state('switch.fan_slow', 'on') }}"
        turn_on:
          service: script.turn_on
          entity_id: script.fan_slow_script
        turn_off:
          service: rest_command.fan_slow_off

The Script:

script:
  # Turns on the fan, pause, the fan remote RF signal, pause, then turns off RF signal
  fan_slow:
    sequence:
      - service: switch.turn_on
      - entity_id: switch.bedroom_fan
      - delay: 00:00:05
      - service: rest_command.fan_slow_on
      - delay: 00:00:04
      - service: switch.turn_off
      - entity_id: switch.fan_slow

This sets the http request you want to send (rest_command). then when you turn on the fan_slow switch, it actually runs the script which involves ensuring the fan is actually on, then sends the RF signal, then sends the http request to turn off the RF signal).

I then created another 3 items (rest_command, switch and script) for fan_medium, and fan_fast (ENSURING i replace the http request with the correct Power2, Power3 or Power4)

Again i’m sure there are leaner, better ways to write this. However it works :slight_smile:

Oh and the last thing was to add the entity to the cloud: in my config so i can use it with alexa. I added each speed as a switch, and then created a custom routine:

“Alexa, turn the ceiling fan to medium”

which then turned on switch.fan_medium

6 Likes

thanks for this write up.

I have a very similar remote that I was wondering how I could integrate it with HA. I’ll definitely have to look into trying this out.

I’ve been struggling with some 433mhz remotes too but that’s a COMPLETELY different story!

Funny - I was just working on this today using a pi zero. Have a bit of work to do on the web interface but feel pretty good about the json calls. Nice work.

Thanks for this tutorial I plan to do this with my harbor breeze remote as well. seems the link for the esp8266 chip is now to a nodemcu so i dont have to buy the other parts listed. Let me know if there are any other changes.

I have since moved to a sonoff ifan02 - a direct replacement for a ceiling fan RF module (in the US at least). I now use MQTT over WiFi to control it

Did you find the resulting speeds using the iFan02 satisfactory?

In the Tasmota iFan02 support thread many people thought the speeds were too slow compared to the standard US fan speeds.

Or did you have to use replacement caps to get them better?

Speed of response? I mean it’s marginally slower than RF, but… in my opinion it works more reliably - and - you don’t need all the mess in with the above :wink:

No I mean the actual rotational speed of the fan blades…

Oh. It’s plenty fast at high speed - I would say comparatively fast

Ok. Thanks.

That’s the only thing keeping me from swapping out my current RF controller with the Sonoff. Having read about those issues on the Tasmota forum I was a little concerned about the WAF. She definitely is picky about her ceiling fan. :laughing: Maybe I’ll have to give it a shot and see how it goes.

Right now I just use the iFan02 along with its remote as a kind of relay to resend the RF signal from a Broadlink. If I click the light button on the iFan remote then HA picks up the MQTT message from that and sends an signal via RF to turn the other controller light on.

It’s kind of hacky but it works OK. And i have the benefit of keeping track of the psuedo-“actual” state.

Check out this post for a slightly different approach