This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 UART communication with the external sensor

Hello, guys!

We are currently developing our firmware with nRF9160-DK and nRF Connect SDK v1.3.0. Among the other things, we need to communicate with the ultrasonic sensor DYP-A02 through UART interface. Each time we give a trigger pulse to the sensor, it should send us 4 Bytes of data over the UART RX line. Those bytes are received on UART TX line of nRF9160.

Here are the characteristics of the UART link:

we used UART_0 of nRF9160 to communicate with the sensor and, consequently, included the following lines in nrf9160_pca10090ns.overlay file:

&uart0 {
	status = "okay";
	current-speed = <9600>;
	tx-pin = <10>;
	rx-pin = <11>;
	rts-pin = <0xFFFFFFFF>;
	cts-pin = <0xFFFFFFFF>;
};

In the code, we initialize UART_0 and enable interrupts on UART with the following:

	_uart = device_get_binding("UART_0");
	uart_irq_callback_set(_uart, uart_cb);
	uart_irq_rx_enable(_uart);

With that done, we are able to receive some data on the UART_0 RX line. However, the trouble is that the received data does not match with expected data. We monitored with the logic analyzer what the sensor is spitting on UART TX line when we give it a trigger pulse. Those data are as expected:

We have 0xFF header + 2 data Bytes + Checksum Byte, as described in sensor datasheet. However, on the nRF9160 side, we are receiving 0x3F instead of 0xFF (for example).

We supply the sensor with 3.3V and I set VDDIO of nRF9160-DK to be 3V. Could that be an issue or we are missing something else?

Is there any fresh UART example that shows what exactly should be included in prj.conf/Kconfig files for proper UART communication? There are a lot of threads on the topic but many of them are now obsolete.

Thanks in advance for your time and efforts.

Sincerely,

Bojan.

Parents Reply Children
No Data
Related