Connect MDEK1001 Listener to Raspberry Pi USB port

I’ve created a Windows c# console app to read the data from the listener and write the data to a MySQL data server (MariaDB) on Raspberry Pi 3 B+ with Raspbian Stretch. The listener is connected to PC with USB.

It works 100% on my PC.

I now want to run the app on the Raspberry Pi with Mono and read the data from Raspberry Pi USB. The app starting to run and open a serial port, but it don’t get data from the opened serial port. It seems that it didn’t recognized the USB port.

What must I do to connect the listener to Raspberry Pi? I didn’t find a solution on Google.

1 Like

Hi Izak,

The raspberry pi should detect the dwm1001-dev device over USB.

Do you see any device such as /dev/ttyUSBxx or /dev/ttyACMxx ?

Yves

No I don’t see it.

I see ttyAMA0: USB ACM Device if I do the dmesg | grep tty command.

Does this device disappear if you unplug the dwm1001? If yes it means it is the dwm1001 interface, and you can use minicom to connect to this port.

I don’t have a raspberry pi handy so cannot test right now.

Yves

Yes it disappear when I unplug it

How do I use minicom to connect?

I used screen to connect devices on serial.
You can easly install with
sudo apt-get install screen
screen /dev/ttyS0 115200
you can change /dev/anyDeviceYouWant

Thank you gumush for replying.

I’m not sure how to use screen in my code and try to use “screen /dev/ttyS0” as port name but it give me IO errors.

If I connect the listener to the USB port, the Raspberry pi 3 B+ sees the port as “/dev/ttyACM0”. My code open the port - wait for 3 seconds and write the “lep” command to the port.

Thereafter nothing seems to happen because the port receives no data. Any suggestions?

I’m using a raspberry Pi 3 B+

I’ve now connected the listener directly on the Raspberry Pi 3 B+ header and not with USB anymore.

I’ve enable SPI on RPi configuration

I’ve tried it with serial console disabled and enabled.

I run my C# code with Mono. The software opens the /dev/ttyS0 port.

My problem is that it didn’t open the dwm> cursor when I give it the following code:
mySerialPort.Write("\r");
Thread.Sleep(100);
mySerialPort.Write("\r");

I’ve tried it with different delays from 50milliseconds to 3 seconds and without delays. I try it with combinations of /r, /r/r, /n, /r/n, etc.

In my windows console it work 100% with /r/r, but not on RPi.

Do I miss something? I see on the forum somebody else also ask a similar question, but nobody reply to him and I can’t get any answers in google.

Please help

I’ve plugged the listener onto my Rpi 3 headers. With screen /dev/ttyS0 115200 I’m able to receive the coordinates from the tags.(I don’t use the USB anymore)

At least I know my connection between the listener and Rpi is correct and my setup of the serial port on the Rpi is correct.

What C# code must I use to receive the coordinates from the listener? How do I use screen in my C# application?

1 Like

I would like to know is there any other way to store the data from the android application to SQL database ??
Should we use raspberry pi to do that??

hi Izak, can you share your code with us ?

This is my python code for switching a tag into what I call “logging mode”, over the USB connection. It seems to work pretty much all the time…

# this function has to handle 3 possibilities:
#  1: the beacon is already in logging mode, and is producing POS output lines
#  2: the beacon is in active mode (dwm> prompt), but not logging anything
#  3: the beacon is in normal mode
def put_beacon_in_logging_mode(self, port_name):
start = time.time()
have_signal = False
result = ''
while not have_signal:
	result = self.port.read(1000)
	have_signal = 'dwm>' in result or 'POS' in result
	# we "get signal" by sending pairs of CR over the serial port
	if not have_signal:
		if round(time.time() - start) >= 5:
			print 're-connecting'
			self.port.close()
			time.sleep(2)
			self.connect_to_serial_port(port_name)
			time.sleep(1)
			start = time.time()
		self.port.write(b'\r')
		time.sleep(0.1)
		self.port.write(b'\r')
		print '..'
		time.sleep(0.9)
print 'Got signal'
time.sleep(0.5)
# if we've already received a 'POS' in the latest results,
# we're already in logging mode
if 'POS' not in result:
	self.port.write(b'lec\r')
	time.sleep(2)
triggered = False
while not triggered:
	line = self.port.readline()
	if len(line) > 0:
		line = line.strip()
	if line.startswith('DIST'):
		triggered = True
		print 'Beacon already in logging mode'
	if line.endswith('dwm>') and not triggered:
		self.port.write(b'lec\r')
		triggered = True
		print 'Beacon switched to logging mode'
2 Likes

this code have errors on python IDE
i think it needs :
import time
import serial

i am right ?

The code is not complete, its just an extraction of a small piece that shows the steps I use to ensure the tag ends up in the right mode.

  • Jon