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

It is possible to send data from nrf9160sip to ESP32 using UART communication?

Hi All

We have to send GPS data to Cloud but we do not have network so is this possible to send GPS data from nRF9160sip to ESP32 via UART communication

and after using MQTT send those data to cloud from ESP32.

so our quires are

[1] It is possible to send data from nRF9160sip to ESP32 ? if yes then can you guide us.

[2] It is possible to send data from ESP32 to Cloud via MQTT?

Thanks & Regards 

Shital

Parents
  • Hi! This should absolutely be possible!

    [1] It is possible to send data from nRF9160sip to ESP32 ?

     Yes. Take a look at this UART-sample for the nRF9160. Use this as the base for the UART-communication from the nRF9160 to the ESP32.

     

    [2] It is possible to send data from ESP32 to Cloud via MQTT?

     The ESP32 is not a Nordic product, so you will have to ask on another forum for any specifics. However, from my understanding, it should be possible to use the ESP32 to post to an MQTT broker. 

    As a general statement, it seems like you are only using the nRF91 DK for its GPS antenna. If this is the case, a simpler solution could be just using a GPS module with the ESP32 itself.

    Best regards,

    Heidi

  • Hi

    Thanks for your replay,

    I use this example of UART for Transmit data but in this example is only about Rx receive data i beat confuse about how transmit my GPS data to other device.

    Can you suggest me for any UART Transmit example code  from nf9160 to other peripheral?

    Thank you

    Shital

  • shital said:
    so how can we do it

     Exactly how I explained. Use the UART-sample as a base, add the overlay file defining your pins and then look at the uart.h-file to know which function you should use to transmit data.

  • Hi Heidi

    Thanks for your support its quit easy but for me its beat confused about to send data i atteched my code and overlay file, prj.config file and main.c 

    so can you suggest me where is i doing misatake or something missing

    Thanks in Advanced

    #include <zephyr.h>
    #include <misc/printk.h>
    #include <uart.h>
    #include <string.h>
    #include <stdlib.h>
    
    /* nRF9160 DK voltage = 3.0V 
     * non sucure
     * board name: nrf9160_pca10090ns
      nrf9160_pca10090ns.overlay /
    
    
    struct uart_data_t {
    	
    	u8_t    data[1024];
    	u16_t   len;
    };
    
    static u8_t uart_buf[1024];
    static K_FIFO_DEFINE(fifo_uart_tx_data);
    
    
    /********************************************/
    
    void uart_sendCOM(struct device x,  u8_t Cont)
    {
    	       
             u16_t len = strlen(Cont); 
             uart_fifo_fill(x, Cont,len );
             uart_irq_tx_enable(x);
             
        
    }
    void uart_cb(struct device *x)
    {
    	uart_irq_update(x);
    	int data_length = 0;
    
    	if (uart_irq_rx_ready(x)) {
                    data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
    		uart_buf[data_length] = 0;
    	}
    	printk("%s", uart_buf);
    
           	if (uart_irq_tx_ready(x)) {
                   
            	struct uart_data_t *buf =
    			k_fifo_get(&fifo_uart_tx_data, K_NO_WAIT);
    		u16_t written = 0;
    
    		/ Nothing in the FIFO, nothing to send /
    		if (!buf) {
    			uart_irq_tx_disable(x);
    			return;
    		}
    
    		while (buf->len > written) {
    			written += uart_fifo_fill(x,
    						  &buf->data[written],
    						  buf->len - written);
    		}
    
    		while (!uart_irq_tx_complete(x)) {
    			/* Wait for the last byte to get
    			 * shifted out of the module
    			 */
    		}
    
    		if (k_fifo_is_empty(&fifo_uart_tx_data)) {
    			uart_irq_tx_disable(x);
    		}
    
    		k_free(buf);
    	
    		
    	}
    
           
    }
    
    void main(void)
    {
    	
            struct device *uart0 = device_get_binding("UART_0");
           
            uart_irq_rx_enable(uart0);
            uart_irq_callback_set(uart0, uart_cb);
            uart_sendCOM(uart0, "Hello the world!");
            k_sleep(3000);
            
    }

    prj.config

    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_TEST_RANDOM_GENERATOR=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    #CONFIG_UART_2_NRF_UARTE=y
    CONFIG_SERIAL=y
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    #CONFIG_HAS_HW_NRF_UARTE3=y
    CONFIG_HAS_HW_NRF_UARTE1=y
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_UART_1=y
    CONFIG_AT_HOST_UART=2
    CONFIG_UART_0_NRF_UARTE=y
    CONFIG_UART_0=y
    CONFIG_AT_HOST_UART=0
    #CONFIG_UART_ASYNC_API=y
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES=y
    # MQTT
    CONFIG_MQTT_SOCKET_LIB=y
    CONFIG_MQTT_LIB_TLS=y
    CONFIG_MQTT_MAX_PACKET_LENGTH=2048
    CONFIG_NRF_CLOUD_HOST_NAME="aigjres9rg3vv-ats.iot.eu-west-1.amazonaws.com"
    CONFIG_NRF_CLOUD_SEC_TAG=3314
    
    # LTE link control
    CONFIG_POWER_OPTIMIZATION_ENABLE=y
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    
    # Modem info
    CONFIG_MODEM_INFO=y
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    
    # nRF Cloud
    CONFIG_NRF_CLOUD=y
    
    # Sensors
    CONFIG_GPS_USE_SIM=y
    CONFIG_ACCEL_USE_SIM=y
    
    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=y
    CONFIG_DK_LIBRARY_INVERT_LEDS=n
    
    # Console
    CONFIG_CONSOLE_SUBSYS=y
    CONFIG_CONSOLE_HANDLER=y
    CONFIG_CONSOLE_GETCHAR=y
    
    # Main thread
    CONFIG_MAIN_THREAD_PRIORITY=7
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_GPS_SIM_THREAD_STACK_SIZE=1024
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1500
    CONFIG_HW_STACK_PROTECTION=y
    
    

    overlay file

    &uart0 {
    	status = "ok";
    	current-speed = <115200>;
    	tx-pin = <00>;
    	rx-pin = <01>;
    };
     

  • Hi, can you tell me exactly why it isn't working?

    Are you able to build your example?

    What is your overlay file called?

    Why are you enabling the configs for UART1,2 and 3 when you are using UART 0?

    Which NCS tag are you on: v1.0.0, master, etc.?

  • Hi Heidi

    Yes we build example.

    Name of overlay file is nrf9160_pca10090ns.overlay

    ok i also try the prj.config file from given example but its not send any data.

    i am confused about to pin configuration and like what are of pins i used for send data to external module via uart. 

    which uart used send data to external module like uart0,uart1?

    and which pin used for?

  • Which NCS tag are you on? I am not able to build your project. Please zip the whole project directory and attach it.

Reply Children
No Data
Related