(This is part 2 of 2. Part 1 covered using a cheap USB TV Tuner (RTL-SDR) to receive and decode the signals.)
The basic idea: can we use a digital GPIO pin as a radio transmitter?
If so, I can control my ceiling fan/light combo units with nothing but a Raspberry Pi, which would be great because I'm already using a Raspberry Pi running Home Assistant to automate things in the house. (I used an SDR receiver to figure out the radio protocol in the Part 1 video.)
This project was both fun and straightforward to do, because there's a software package called rpitx that handles the hard stuff. Basically, if you push bits out fast enough using GPCLK0 then you get - ta-da! - radio waves.
The total time from finding rpitx to being able to control my ceiling fan was probably just half an hour - it could've been faster if I didn't mess up the "sendook" command a few times.
I spent a bunch of time in the video talking about harmonics and slapping on a low-pass filter from eBay. This was, in keeping in the spirit of the videos, more of an educational diversion. Since the signal is not super strong to begin with, if I keep the RPi near the center of my house, the harmonics should be hardly noticeable outside the house anyways.
(There were a couple comments that pointed out that the long wire I used in the video to connect to the low-pass filter will emit the harmonics anyways. I'll be making the wires shorter before actually putting it into use someday...)
Also, I regret not showing the actual manufacturer-provided remote control in the video. Would've been nice to see what is being replaced.
Some people wanted to know if this is doable with an Arduino. The Arduino simply can't toggle its digital out fast enough to transmit at this frequency, so the best option is probably to get a dedicated radio transmitter like a CC1101 module that the Arduino can control. I don't have any experience with the CC1101 but several comments on my videos said they were useful.
If you missed it, Part 1 - Hacking My Ceiling Fan's Wireless Remote with a USB TV Tuner has the fun parts of decoding the radio signals and, IMHO, was rather more fun and interesting, if not as impressive.
As of March 2021, the rpitx Github README says that Pi B+ compatibility is "Partial" and Pi 4 compatibility is in "beta". To be honest, I don't know what that means and haven't tried it with anything other than a Pi 3b. YMMV.
Low-pass filters are advertised with the frequency range that they start filtering out signals at - it is not a sharp cut-off where signals at e.g. 399 MHz go through 100% but 400MHz signals are gone.
With a low-pass filter advertised as 400-470 MHz, the signal starts dropping off around or before 400 MHz and should mostly be gone by 470 MHz. We would say that this filter has a "pass band" of under 400 MHz, a "transition band" of 400-470 MHz, and a "stop band" of 470 MHz and higher.
There are, of course, other types of filters: high-pass filters and band-pass filters.
The antenna shown in the video is a cheap antenna advertised as for 315 MHz. The antenna, filter, and connector on the other end of the filter are all SMA connectors. Note that SMA is not compatible with RP-SMA connectors that a lot of consumer wireless gear has. Wikipedia explains the difference.
Electromaker on YouTube: https://youtu.be/TDF12MVMOfM?t=1161