Update system:
Bash
sudo apt update
sudo apt upgrade -y
Install pigpio and rpi-rf:
Bash
sudo apt install pigpio python3-pigpio -y
pip3 install rpi-rf
Enable and start the pigpiod service: This ensures the low-level daemon is running at boot.
Bash
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
Check its status with systemctl status pigpiod.
1. Save the Python Scripts
First, you need to save the code into .py files on your Raspberry Pi.
For the Receiver (rf-receiver-pi):
Open a terminal on your Raspberry Pi (you can use SSH or directly on the desktop).
Create a new file, for example, named rf_receive.py:
Bash
nano rf_receive.py
Copy the entire code from the rf-receiver-pi immersive artifact and paste it into the nano editor.
Save and exit nano by pressing Ctrl+O, then Enter, then Ctrl+X.
For the Transmitter (rf-transmitter-pi):
In the same terminal, create another new file, for example, named rf_transmit.py:
Bash
nano rf_transmit.py
Copy the entire code from the rf-transmitter-pi immersive artifact (which was provided in my previous response about sending code) and paste it into the nano editor.
Save and exit nano by pressing Ctrl+O, then Enter, then Ctrl+X.
2. Execute the Commands
Now, you can run the scripts from the terminal.
To run the Receiver script:
Bash
python3 rf_receive.py
To run the Transmitter script:
Bash
python3 rf_transmit.py
pi@piGIO:~ $ python3 /home/pi/rf_transmit.py 14683463 1 304
Initializing 433MHz RF transmitter on BCM GPIO 4...
Attempting to send Code: 14683463, Protocol: 1, Pulselength: 304, Manually repeating: 10 times
Code sent successfully.
pi@piGIO:~ $ python3 /home/pi/rf_transmit.py 14683471 1 304
Initializing 433MHz RF transmitter on BCM GPIO 4...
Attempting to send Code: 14683471, Protocol: 1, Pulselength: 304, Manually repeating: 10 times
Code sent successfully.
All working.