Previous post showed how I stripped down a Pure Chronos CD/Radio and showed how the various buttons on the chassis were transmitted to the motherboard as a pseudo IR signal. Now its time to decode the signal on the Raspberry PI.
This article seems to be reasonably up to date:
https://www.digikey.co.uk/en/maker/blogs/2021/how-to-send-and-receive-ir-signals-with-a-raspberry-pi
Here is the circuit they use:
First step is to edit /boot/config.txt to specify the IO pins I am reading IR signal on GPIO pin 19.
dtoverlay=gpio-ir,gpio_pin=19 # for receiving data
##dtoverlay=gpio-ir-tx,gpio_pin=26 # for sending commands
Reboot:
sudo reboot now
Install some helper libraries:
sudo apt update
sudo apt install ir-keytable
Test:
This command will read IR reciever and print parsed commands.
sudo ir-keytable -c -p all -t
Investigate if this fails when you send some signals. After fixing incorrect wiring, I get something like this:
pi@raspberrypiMP3:~ $ sudo ir-keytable -c -p all -t Old keytable cleared Protocols changed to unknown other lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp cec imon rc-mm Loaded BPF protocol xbox-dvd Testing events. Please, press CTRL-C to abort. 246.860112: lirc protocol(nec): scancode = 0x8099 246.860168: event type EV_MSC(0x04): scancode = 0x8099 246.860168: event type EV_SYN(0x00). 246.920145: lirc protocol(nec): scancode = 0x8099 repeat 246.920207: event type EV_MSC(0x04): scancode = 0x8099
Yea, I can now read the various button presses from the Chronos chassis and read them with the RP. I could go further ans install the main lirc library, but enough for now. Time to reassemble the hardware and try to hack the music player software. Not sure if I will require LIRC as I dont need to translate the keycodes, but it may be helpful to get the data into the player software.
Install lirc for the main library:
sudo apt install lirc
Edit the configuration file so set the sensor up as a device:
sudo nano /etc/lirc/lirc_options.conf
... and add...
driver = default
device = /dev/lirc0
Reboot and test:
sudo systemctl stop lircd.service
sudo mode2 -d /dev/lirc0
… and so it goes on…