Using DWM1001 API on Raspberry Pi and PySerial

I am trying to use the DWM1001-DEV with a Raspberry using Python. The Decawave DWM1001 is connected to the Raspberry over Micro USB.
I try to open a serial port connection with PySerial and then test if the connection works by reading some random value.

Blockquote

import serial

ser = serial.Serial(‘/dev/ttyACM0’,115200)
print(ser.name)
ser.write(b’\r\r’)
ser.write(b’lep\r’)
ser.close

Blockquote

I try to use the UART Shell mode by writing \r\r and then get some data using the lep command. However nothing happens. How would I go about communicating with the DWM1001?
I would appreciate any pointers on how to write a Python program for communicating with the DWM1001.

Edit: I have now added the line
response = ser.readline()
print(response)

However, nothing happens when running the script and I have to stop it manually.

Thank you!

Please modify the python program to below and try. I am assuming you have setup the UWB Network properly!
Identify your serial port using “lsusb” or “dmesg” command in the raspberry pi terminal and update the below program accordingly!

import time
import serial
try:
    ser = serial.Serial()
    ser.port = '/dev/ttyUSB0'
    ser.baudrate = 115200
    ser.bytesize = serial.EIGHTBITS 
    ser.parity =serial.PARITY_NONE 
    ser.stopbits = serial.STOPBITS_ONE 
    ser.timeout = 1
    ser.open()
    ser.write(b'\r\r')
    time.sleep(1)
    ser.write(b'lep\r')
    ser.close()
except Exception as e:
    print(e)
    pass
print(ser)

ser.open()

while True:
    try:
        data=str(ser.readline())
        print(data)
        time.sleep(0.01)
    except Exception as e:
        print(e)
        pass
    except KeyboardInterrupt:
        ser.close()

Hope this helps

Regards

1 Like

Hi
\r is a carriage return, it is correct to send character 13 or new line. you could send it with \n