The REYAX RYLR998 (Amazon, 1 per package so buy two) is a long-range radio transmitter and receiver that can send and receive short packets of bytes supposedly up to about 12 miles. Product information and specification data sheet can be found online.
Paired with a IZOKEE CP2102 Module USB to TTL adapter (Amazon, 2 per package), it makes talking to the RYLR998 as simple as conversing over a serial port.
Connections
Wire the two units together as shown. The CP2022 USB TO TTL is the red circuit board, shown on top. The RYLR998 LoRa is the blue circuit board, shown on the bottom.
-
Connect the 3.3V (3V3) power source of the CP2102 to the VDD of the RYLR998; be sure to only use the 3-volt power supply.
-
Connect both grounds, GND to GND.
-
Connect the TXD of the CP2102 to the RXD of the RYLR998.
-
Connect the RXD of the CP2102 to the TXD of the RYLR998.
-
DO NOT connect anything to the +5V of the CP2102!
-
There is no need to connect anything to the RST of the RYLR998. Internally the pin is held high via a 100 ohm resistor. If you do need to reset the device, connect it to a digital GPIO and ground it for a minimum of 100ms. However, it's unneeded in this configuration.
Finding The Serial Port
On a Mac, list the devices from the Terminal: ls /dev/cu*
. Then, connect the USB and a red power led should turn on.
List the devices again: ls /dev/cu*
.
A new device should have appeared. In my case, it was /dev/cu.usbserial-0001
.
Communicating with the Device
You'll want to make a serial connection at 115200 baud, no parity, eight bits, 1 stop bit (N,8,1).
The device uses "AT Commands" to control it, however there's a bit of a trick to it. You'll want to reference the official AT Command Guide for a list of commands.
-
All commands must start with a literal
AT
(capitalization matters). Virtually all commands also require a plus sign, too). -
All commands must end with a carriage return and line feed, a.k.a CR LF, a.k.a 0x0D 0x0A.
If either of these conditions are not met, it will return an error code.
- +ERR=1 means you didn't use the CR LF control characters at the end.
- +ERR=2 means you didn't start with
AT+
. - +ERR=4 means you sent a bad command.
Set the AT Command Guide for more error codes.
Here's the Unspoken Trick
Historically, the convention of AT commands were used with dial-up serial port modems.
AT
used to stand for "attention" and told the modem a command was coming for it.
You'd wait a moment, type AT followed by a command and press enter. The line you typed would
then be interpreted.
That is not how this works. If you type an A
you're more than likely to immediately be met
with an +ERR=1 error.
What isn't documented is that the device wants the entire command sent all at once, if there is so much as a single millisecond between characters, for some reason it thinks the command is not formatted correctly.
In short, it doesn't wait for the CR LF at the end. You must account for this.
Connecting Via Interactive Terminal
The best way I've seen to get around the issue is to use an application called CoolTerm made by Roger Meier.
Go to Connection / Options... and from Serial Port:
- set the Port to
usbserial-0001 (Silicon Labs)
or whatever you discovered the serial port to be for you, - then set the Baudrate to
115200
, - Data Bits to
8
, - Parity to
None
, - and Stop Bits to
1
.
Uncheck CTS, DTR, XON, and 'Software Supported Flow Control'; it is ok to leave 'Block Keystrokes while flow is halted' and DTR On and RTS On.
Then under Terminal options group, set the Terminal Mode to Line Mode
and change the Enter Key Emulation to CR+LF
.
Under Transmit Options turn off all checkboxes; do not use a transmit character delay, do not use a line delay, do not use a packet delay, do not wait for remote echo.
To talk with the device go to Connection / Connect, and in the "Type a command here. Terminate by pressing ENTER" box enter your AT commands there.
When done go to Connection / Disconnect.
Example commands
AT
responds with +OK.AT+UID?
responds with +UID=(and some hex value).AT+FACTORY
responds with +FACTORY.AT+RESET
responds with +RESET and then +READY.
Using a Python Program
First, install pyserial:
1
pip install pyserial
Here is a Python 3 program that will accept input from you, but also report if a message is received or the device reports back a status.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42import serial
import threading
SERIAL_PORT = '/dev/cu.usbserial-0001' # Change this if you need to
# Function to read incoming messages asynchronously
def read_from_port(ser):
while True:
if ser.in_waiting > 0: # Check if there's data waiting
incoming_data = ser.readline().decode('utf-8').strip()
print(f"\nReceived: {incoming_data}") # Print received data
continue
def main():
# Configure your serial port (adjust as necessary)
ser = serial.Serial(
port=SERIAL_PORT,
baudrate=115200,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
timeout=1
)
# Start a background thread to listen for incoming data
listener_thread = threading.Thread(target=read_from_port, args=(ser,))
listener_thread.daemon = True # Daemon thread to stop with main program
listener_thread.start()
try:
while True:
# Main loop to send commands
command = input("Enter command to send: ")
ser.write((command + '\r\n').encode('utf-8')) # Send command
except KeyboardInterrupt:
print("\nExiting program.")
finally:
ser.close()
if __name__ == "__main__":
main()
Radio Settings
The AT Command Guide explains that for two devices to communicate several things have match:
-
Use
AT+BAND=
to have the sender and receivers listen on the same frequency. 915000000 (unit is Hz) -
Use
AT+NETWORKID=
to have the sender and receivers be on the same network. 3-15 or 18. -
Use
AT+ADDRESS=
to set the unit's address. 0-65535. Listening to 0 does not pick up everything. -
Use
AT+CPIN=
to set the password. 0 (none), 00000001-FFFFFFFF.
Send
Use AT+SEND=
<Address 0-65535><Payload Length><Data> to send. e.g. AT+SEND=0,5,HELLO
Sending to 0 sends to all devices; in other words, they listen for their ADDRESS and zero.
Receive
Messages will appear as +RCV=
<Sender's Address>,<Size>,<Data>,<Signal Strength>,<Signal to Noise Ratio>.
Limitations
Transmission is not fast, nor can it handle much in terms of length. Reception is not guaranteed. Often line-of-sight is required. Don't rely on the password for encryption.
This radio is useful for sending and receiving short messages. It is not compatible with Meshtastic, but for which is extremely easy to write your own software.