The television at home was bought quite early, a “Chuang*” brand that has ads when turned on. Moreover, it has been used for several years and is quite slow. What is unacceptable is that it does not allow the installation of third-party software. I decided to get a box with better performance. However, after looking around, most of them are out of budget.
By chance, I used Raspberry Pi 4 for work, and of course, using 3 is also possible. Theoretically, the firmware of the two devices is the same. So I decided to use this device to try to build an ATV that is relatively smooth to use.
This article mostly references the original translation: https://konstakang.com/devices/rpi4/
First, buy a Raspberry Pi 4B. Now, a low-config version is sufficient, the 2G version is around 270 yuan. Also, you need to buy an infrared receiver and a 100-ohm resistor (recommended for installation). Refer to the wiring diagrams online.
Image source: https://shumeipai.nxez.com/2016/01/17/infrared-remote-control-remote-raspberry-pi.html
The GPIO18 pin is used in the image, while the default defined pin for Raspberry Pi OS is GPIO17. If you want to debug the Raspberry Pi OS environment, you need to pay attention to this point; I suggest connecting a 100-ohm resistor in series with VCC and taking power from 5V, the testing effect is also good. If you do not have a 100-ohm resistor, you can take power from 3.3V for testing.
There are many models of remote control receivers, the recommended TSOP4838 or my recommended VS1838B are both fine, and even cheaper.
Burn the ATV image to the SD card; you can use the Raspberry Pi Imager.
https://konstakang.com/devices/rpi3/LineageOS17.1/
The following is basically a translation of the original FAQ; Q: How to enable developer mode (Root, terminal window prerequisites)? A: Settings -> About -> Click ‘Build number’ several times.
Q: Enable root permissions? A: Developer options -> Root permissions; not recommended to enable, you know.
Q: Enable terminal application? A: Developer options -> Local terminal.
Q: Advanced reboot? A: Developer options -> Advanced reboot.
Q: Only see the boot screen and cannot enter the home screen? A: It is estimated that the screen does not support adaptation, try modifying the resolution settings in /boot/resolution.txt under Windows. If you delete the /boot/resolution.txt file, the system will also try to adapt multiple times.
Q: Storage space and SD card size do not match? A: Boot into recovery, refer to enabling advanced reboot; reboot to TWRP, and flash our expansion package. The expansion package download address: https://www.androidfilehost.com/?fid=8889791610682901036
You need to copy it to a USB drive or SD storage yourself.
Q: No physical buttons? A: Plug in the keyboard F1 = Home, F2 = Back, F3 = Multi-tasking, F4 = Menu, F5 = Power, F11 = Volume down, F12 = Volume up.
Q: Make a physical power button yourself? A: Add a button between GPIO21 and GND. Enable the relevant option in settings (needs to restart to take effect). Surprisingly, this button also supports booting into Recovery (long press effective).
Q: Switch audio between HDMI and 3.5? A: Find the Raspi-related option in settings, you can switch. It also supports DAC (I have not tested).
Q: Enable infrared remote control? A: Find the Raspberry Pi related options in settings, and turn on the relevant settings. The original text specified a configuration file page: https://github.com/lineage-rpi/android_external_ir-keytable/tree/lineage-17.1/rc_keymaps which is actually not very useful, this article will explain a bit more: first create a rc_keymap in /boot/, note that there is no extension. The file format should be set to Unix (LF) + UTF-8. The default Windows format of Notepad++ will not work. This point is not emphasized in the official documentation and has troubled me for a long time.
Next, the first line
type: nec here is lowercase, many documents write it in uppercase, which will cause an error, but it will not display these errors when starting. Finally, there is key value acquisition and definition, for ATV, there are definitely some common key values like up, down, left, right, etc. Enable root permissions, local terminal application, and enable IR Remote (these three steps are required). Open the terminal and enter:
su
ir-keytable -p nec # This step is not necessary, convert the remote control protocol to nec, note that it is lowercase. If your remote cannot echo, you can try executing this step.
#Protocols changed to nec indicates success;
Ir-keytable -t # Key value detection, very useful, press ctrl+c to exit.
At this point, the system will give a prompt asking you to press the key on the remote. I suggest you only install the key sequence we provide. Basically meets the requirements of ATV. First, the up direction key, record the value after scancode= (which is the key value). Replace the key values below one by one, and finally save it to the /boot/rc_keymap file. If you use Windows, you can create a new file in the removable disk with notepad+, format requirements as mentioned above.
# table lg akb7291, type: nec
0x408 KEY_POWER
0x443 KEY_MENU
0x45b KEY_HOMEPAGE
0x440 KEY_UP
0x406 KEY_RIGHT
0x407 KEY_LEFT
0x428 KEY_BACK
0x441 KEY_DOWN
0x444 KEY_ENTER
0x4aa KEY_ENTER
0x403 KEY_VOLUMEDOWN
0x402 KEY_VOLUMEUP
Note: 1. First confirm that your remote control is an infrared remote, the method is to take a picture with your mobile phone camera, if there is light, it is infrared remote. If it is Bluetooth, you can directly pair it in settings – remote and accessories, the effect is also very good. Non-advertising insertion, sensitive constitution please avoid.
2. The remote control of Mijia uses its own protocol, there are decoding problems; usually invalid during key value acquisition.
3. The KEY_OK in the original text has not been successfully tested, it is effective after replacing KEY_ENTER. The article uses the AKB7291 remote control, if you are not sure, you can buy this directly.
This article is contributed by @最爱肉松: https://make.quwj.com/project/358
The links in the text can be clicked to read the original at the end
More wonderful content
Using Raspberry Pi to create a motorcycle dashboard
Using Raspberry Pi to create a smart pet feeder
Creating a smart planetary observer based on Raspberry Pi
Handmade metal wireframe X-wing clock
Arduino + 280 LEDs DIY music spectrum light
DIY Stanford Pupper 12 Degree Freedom Quadruped Robot Dog
Barrier: PC and Raspberry Pi keyboard and mouse sharing solution