Fan-tastic Misuse Of Raspberry Pi GPIO

[River] is a big fan of home automation. After moving into a new house, he wanted to assimilate two wirelessly controlled fan lights into his home automation system. The problem was this: although the fans were wireless, their frequency and protocol were incompatible with the home automation system.

Step one was to determine the frequency the fan’s remote used. Although public FCC records will reveal the frequency of operation, [River] thought it would be faster to use an inexpensive USB RTL-SDR with the Spektrum program to sweep the range of likely frequencies, and quickly found the fans speak 304.2 MHz.

Next was to reverse-engineer the protocol. Universal Radio Hacker is a tool designed to make deciphering unknown wireless protocols relatively painless using an RTL-SDR. [River] digitized a button press with it and immediately recognized it as simple on-off keying (OOK). With that knowledge, he digitized the radio commands from all seven buttons and was quickly able to reverse-engineer the entire protocol.

[River] wanted to use a Raspberry Pi to bring the fans into his home automation system, but the Raspberry Pi doesn’t have a 304.2 MHz radio. What it does have is user-programmable GPIO and the rpitx package, which converts a GPIO pin into a basic radio transmitter. Of course, the Pi’s GPIO pin’s aren’t long enough to efficiently transmit at 304.2 MHz, so [River] added a proper antenna, as well as a low-pass filter to clean up the transmitted signal. The rpitx package supports OOK out of the box, so [River] was quickly able get the Pi controlling his fan in no time!

If you’d like to do some more low-cost home automation, check out this approach to using a Raspberry Pi to control some bargain-bin smart plugs.

36 thoughts on “Fan-tastic Misuse Of Raspberry Pi GPIO

    1. It’s a little misnomer to say it’s bit-banging. Instead, the RasPi lets you route one of its internal PLLs to one specific GPIO pin, and carefully timed small changes to the frequency … and PWM duty cycle I think … of that PLL lets you emit your choice of spectrum.

      It’s still pretty magic, it’s just magic at audio frequencies instead of RF frequencies.

      1. No need to shut up. HaD comments are all armchair enginerds that love to rip into people for “mistakes”. Your solution may not be elegant, but it’s functional, and more importantly you seemed to have fun with the project.

        It’s been a hot minute since I saw a real hack on HaD that livs up to the sites roots. Bravo!

      2. It’s not the length of wires but rather the *type* of wires that is the issue here. Coax is what is needed here as unshield loose wires become a loop antenna.

        The feedbak/criticism is the warning for the brainless zombies that copy/paste what they see.

      3. > but the Raspberry Pi doesn’t have a 304.2 MHz radio.

        BTW that’s the wrong antenna for 304Mhz.

        Have we become so quick to be first post for youtube to not try to do things properly here?
        Criticizing others for pointing out the errors is not a good way to learn.

  1. I hate to be that guy, but like tekkieneet said, if were trying to help others learn, your technically not supposed to do that per FCC guidelines. Transmitting a dirty and loud signal can cause problems with other peoples stuff, think medical equipment or car key fobs. Licensing is “required” to transmit, but the information learned is well worth it. And it’s cheap, the knowledge and power you’re armed with after far out weighs the cost of a couple of bucks. Toss them in your hacking toolkit.

    1. Speaking from a place of little knowledge, I was under the impression that most of those FCC regulations weren’t legally applicable to broadcasts under a certain effective power. Is that the case, or it more an issue of enforcement impracticality?

      1. Better put, the FCC has limits on output power. Part 15 covers this. Even though it’s an intentional radiator, you may be under the power limit for unintentional radiator. Of course, if you’re not selling a product…

  2. hrm, this kind of sounds like that OTA TV service that was a thing in the early 2ks that got shut down. they had dime sized TV antennas for every customer connected up to personal DVRs that would stream local TV to you. I wonder how hard it would be to RX a PI into a DTV capture card using the GPIO pins. its WAY beyond what I know how to do but this looks interesting none the less.

  3. I have a similar home automation system, but not tried integrating wireless yet. I am moving to the use of RP Picos for the hardware interfacing. I wonder whether the Pico’s PIO would be up to generating the RF?

      1. … but the frequency at which the PIO state machine runs can be very closely defined. There’s an example program using, I think, 20000 and 20002 to generate a 2Hz pulsing light.

      2. … in any case, my plan is to continue using the RPi as the main controller and attach multiple Picos, via i2c, as hardware interfaces (I’m currently using cards from AB Electronics for the I/O).

  4. Thank s ever so much for the post. I have been wanting to take control of my PENTAIR wireless pool controls but did not know where to start. You information about sniffing and decoding the signals and then the Rpi hack are a great help!

  5. I could use this for my primitive remote controlled fan. Does the Pi Zero W have enough resources to do this? (I currently am running PiHole on it, and would like to add the fan control software to it.)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.