I’m attempting to peer two RAK3172 modules together with two RPi’s. Currently testing with a simple send script on one pi and a receive script on the other. I’ll paste in the two scripts at the end of this topic but I also tried the single-line
is one problem.
AT+PSEND expects ASCII characters representing hexadecimal values.
If you want to send “Hello” the command would be AT+PSEND=48656C6C6F
Even though the whole string in encoded to bytes? I tried the hex value you gave but not getting anything, is the way I have the PRECV setup correct? I’m new to UART on RPi’s too but I’m not getting any response when I try to read the 3272’s reply during AT command setup either
Your UART settings seem to be ok.
Are you sure RX/TX are connected correct
RX RPi <=> TX RAK3172
TX RPi <=> RX RAK3172
Also keep in mind that the RAK3172 will only listen and respond to AT commands on the UART2 interface.
I am not a RPi or Python expert, but is this sequence actually waiting for a response and if yes, how long?
If there is a UART command that waits until a certain character is received, you should use that instead and wait for an LF or CR that marks the end of an response.
And the best idea to check if you connected the correct UART and have the pins assigned correct is to use an UART/USB adapter and a computer to test the communication.
I double checked my RX/TX pins and they were correct and using UART2. I had used a usb Uart adapter and was able to receive the commands sent to my computer with a similar python script but I will connect it again to make sure it’s still sending them correctly.
The uart.read command should read until the specified timeout at the top of the script (1 second) but I likely need to look into a better way or approach of reading the console
Update: Connected to my computer again and the left side is what my computer is receiving, then when I send “replytest” a few times here and there it always received it and printed in the Pi’s ssh console on the right. However, I realized i was missing the newline character for my receive command when I first connect, so that could be my issue but not sure why i wouldn’t get output for other commands, maybe it needs ATE command?
Update is that the script doesn’t work as-is, but when I use the RAK serial tool to manually configure the receive side and then send PRECV command, i did get an event with the other pi running the send script, but I think the event happened during the setup of the pi’s AT commands and not after the PSEND. I don’t believe I got any data along with it either, I was trying to send the hex values you gave me for “hello”, event details below but I also noticed that I didn’t get a response from 3272 when using 115200 baud which I thought was the new default, only got response at 9600. Will change both bauds to 9600 and keep testing to see if anything else works
Your setup and AT commands are correct, I can only guess your Python script for receiving is not working as expected.
One thing in your receive loop, you are sending repeatedly AT+PRECV=65535 to the RAK3172 and that is wrong. Receive should be enabled once, until you received a packet (the complete packet as I marked in the screenshot) and only after that AT+PRECV=65535 can be send again. I don’t think that your while loop will work as you think it should.
counter = 0
while True:
print(counter, " Waiting for data...")
UART.write(b"AT+PRECV=65535")
rcv = UART.read()
print(rcv.decode())
UART.reset_output_buffer()
counter += 1
I realized that issue with my recv command earlier when I had the module connected via uart adapter to my computer, because it showed AT_BUSY, but is there a way to configure the timeout for the recv? I noticed it would eventually time out after awhile and I wanted the loop to always be ready to receive (send receive command after timeout)
And I figured the data I received would be the hex values I was sending, when converting what i did receive to ASCII it results in this:
First, can you send an at+ver=? command to the RAK3172, I think you are using an old firmware version. I would suggest you update it to our latest RUI3 firmware.
Tutorials to switch from old firmware (V1.0.4) to RUI3 => RAK3172 Module Quick Start Guide | RAKwireless Documentation Center
As I said, I don’t know Python, not sure what the rcv.decode() is doing with the received data. Did you try to just print to the console what you received?
I believe I’m on v1.0.2, I’ll look into updating. And should’ve realized that value was the timeout, I read that the 65535 value was no timeout so that’s why I was using it.
I was using rcv.decode() because I assumed the module would reply with bytes but that could be my issue, I’ll try printing directly or decoding from hex
Update: I removed the .decode() and I’m getting OK messages from AT commands, needs formatting but I can work on that. Additionally, my received events are also being displayed, but is the data in Hex? I will have to look into how to parse it within my code since it gives me mode and signal characteristics in addition to data, at least they’re colon delimited which should help
I also updated to 1.0.4 and using 115200 baud with no issues
Being new to RAKwireless products, have been trying to understand how to issue AT commands to RAK11310 (RAK19001 baseboard) so as to be able to get information from such basic commands as at+ver=?.
In the examples there is Examples/RAK WisBlock examples/11300/Communications/WiFi/AT_Command_Test. From the code, this simple program appears to accept an AT command from the Serial Monitor, issue that command, and display the results.
I can confirm the command is received and issued but no response is displayed.
What am I missing? Many thanks for the community’s guidance.