Sending AT commands using powershell/another serial communication tool

Issue: Can’t communicate with RAK7201 button over usb using powershell or another serial communication tool

Details: I am writing a script to automate button setup. I would like to be able to send AT commands using powershell.

Here is the code I tried. The device did not restart.

$port= new-Object System.IO.Ports.SerialPort,COM3,15200
$port.DTREnable = $True
$port.ReadTimeout = 5000;
$port.WriteTimeout = 5000;

Additionally, I tried sending “at+set_config=device:restart\r\n” using the cool term serial communication tool with no success.

Are you sure that COM3 is correct?

“15200” is certainly not

Have you tried the rak serial port tool?

My code didn’t paste properly. The first line was supposed to be:
$port= new-Object System.IO.Ports.SerialPort COM3,15200,None,8,one

I checked that COM3 was correct by using the serial port tool and checked that the baudrate was 15200 (COM3 and baudrate = 15200 worked using the serial port tool). I also experimented with other baudrates.

I’ve been able to open and close the port, but when I write to the device, the device does not respond to the command. This is also the case when using the cool term serial tool.

The reason I’m not using the serial port tool is I’m writing a script for setup purposes that automatically sets the required heartbeat values and logs the devices devEUI.

15200 is simply not a valid baud rate

115200 may be what you mean.

Does it work in the rak serial port tool? If so, the issue would be the baud rate or other settings you are trying to use.

Yes you are right about the baudrate. When the dropdown for baudrate in the serial port tool minimizes, it cuts off part of the number. I however just changed the baudrate in my code to 115200 and it still doesn’t work (works in serial port tool).

Do you know where I can find documentation on the other settings I should be using?

Hello @cturpin2 ,
Have you press and hold key 1 before trying to initiate the communication?
In order to initiate a serial communikation with this device you have to hold button 1 untill it’s light goes into constant blue light.

Hi @Nikola ,

Yes I put the device in configuration mode (all four LEDs on) and the device responds to the serial port tool

I have been unable to get the device to respond to any other serial communication tool or my powershell code

Hello @cturpin2,
I did tested it with Powershell so this is what is working for reading :

First setup the new object which will represent the port:

$port= new-Object System.IO.Ports.SerialPort COM8,115200,None,8,one

Then make sure to open the port.
Using this simple function you can monitor the RX of the serial communication:

function read-com {
    $line = $port.ReadExisting()
        Write-Host -NoNewline $line
  catch [System.Exception]

do {
}while ($port.IsOpen)

This should help you. :smiley:

Best Regards