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

Transmitting data over UART_2 to external sensors

Hi Dev Team,

I have been trying to send data across from my nRF9160DK board to an external sensor via RS-485. For this, I have a TTL_RS485 converter in between.

To start off with, I just want to send a string and receive it on an external debugger to check my UART communication. I am using UART_2 and I am attaching my nrf9160dk_nrf9160ns.overlay file here. The wiring has been done based on uart_2 configuration. 

/* Needed to get NRF_PWMn defined. */


/ {
	model = "Nordic nRF9160 DK NRF9160";
	compatible = "nordic,nrf9160-dk-nrf9160";

	chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
	};
};


&pwm1 {
	status = "okay";
};

&pwm2 {
	status = "okay";
};

&pwm3 {
	status = "okay";
};


&uart1 {
	current-speed = <9600>;
	status = "okay";
	tx-pin = <12>;
	rx-pin = <13>;
	rts-pin = <14>;
	cts-pin = <15>;
};



&uart2 {
	status = "okay";
	current-speed = <9600>;
	tx-pin = <10>;
	rx-pin = <11>;
	rts-pin = <16>;
	cts-pin = <17>;
};

The same is in the SPM folder as nrf9160dk_nrf9160.overlay file. 

The basic UART example in the master branch provides the structure to receive data from UART. Is there any particular example to send the data from the UART ?.

I tried following this thread : https://devzone.nordicsemi.com/f/nordic-q-a/44788/nrf9160-dk-send-receive-data-from-uart1/179149#179149  , but I get an error while trying to implement that code. The error I get is in Line 24 where k_fifo_get is defined. Is there any way to fix this issue ?

Is there any other example that shows how to transmit the strings externally through a UART (UART_2 in my case).

Regards,

Adeel.

  • Hi Carl,

    Thanks for the lead. I think you are right, but for now I was just trying to transmit a string just to see if the communication works. So, I did not connect RE/DE right now. Can I just control the RE/DE through controlling the GPIO's and setting a 1/0 like this:

    gpio_pin_configure(gpio, 12, GPIO_OUTPUT);

    gpio_pin_set(gpio, 12, 1);

    printk("GPIO 12 Value is: %d\n", gpio_pin_get(gpio, 12));

    Is this the correct way to setup the GPIO pins ? If so, I will try to set it up for my RE/DE and configure it for my transmission. 

    Also, my SPM still gives me the error posted above. Do you think this can also be an issue here regarding external communication (or) is that independent of this ?

    Regards,

    Adeel.

  • Hi, Adeel!

    I see that you are getting help from Simon on the same matter in this ticket, so I'll close this one. 

    Please open another ticket if you encounter other issues.

    Best regards,
    Carl Richard

Related