Send and Recieve IR data with your SAO easily!
Driver for the IR-Transceiver-SAO.
For specific docs about the the IR-Transceiver-SAO, head over the IR-Transceiver-SAO project.
Interfacing with the SAO can be done by using IRRemoteSAO.
The SAO is set to I2C address 0x08 by default.
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO( i2c, 0x08 )debug_logs is an optional parameter that prints raw byte values sent and recieved over I2C.
Default value is False.
tvRemoteSAO = IRRemoteSAO( i2c, 0x08, debug_logs=True)seconds_delay is an optional parameter that configures the delay between I2C commands.
Default value is .5.
tvRemoteSAO = IRRemoteSAO( i2c, 0x08, seconds_delay=.5)A basic test to verify your SAO and I2C is working can be done with the ping command.
import machine
from IRRemote import IRRemoteSAO
device_i2c_address = 0x08
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO(i2c, device_i2c_address )
print(tvRemoteSAO.ping())Using examples/sanity_test.py is a good way to test the core functionality of your board.
Note: This requires two SAO boards.
The program will ask you to input:
- Your SAO Address
- Other boards SAO Address
- Your Message
- Other board's SAO Address
The script will verify that data is able to be sent and received.
When IR data is recieved by the SAO, the data is stored in a buffer.
By default, only one byte is sent.
This example will print out data in the buffer. One the data is send over I2C, it is removed from the buffer.
import machine
from IRRemote import IRRemoteSAO
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO( i2c, 0x08 )
size = tvRemoteSAO.get_ir_recieve_buffer_size()
if size > 1:
val = tvRemoteSAO.read_ir_byte()
print(val)The buffer can be enabled to store multiple values with enable_ir_recieve_buffer.
The SAO has a max recieve buffer of 128 bytes.
tvRemoteSAO.enable_ir_recieve_buffer(1)Writing data is simple. The following will transmit the number 1 to 10.
import machine
from IRRemote import IRRemoteSAO
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO( i2c, 0x08 )
for x in range(0, 10):
tvRemoteSAO.write_ir_data_byte(0, x)Setting your SAO to Address mode will ignore all receieved data bytes that do not contain the expected Address.
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO( i2c, 0x08 )
# Only received data with Address ID 9.
tvRemoteSAO.set_ir_address(9) Every IR Transmission has an Address as the first byte.
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
tvRemoteSAO = IRRemoteSAO( i2c, 0x08 )
# Send 42 to Address 9
tvRemoteSAO.write_ir_data_byte(9, 42)- Install Pico VS Code Extension
- Upload
src/IRRemote.pyto pico - Now you can run any of the sample programs on the pico