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

reading signal strength in firmware nrf91

Hi, 

I am trying to read signal strength inside my code. At the moment I know I can do this with AT commands:

AT+CESQ
+CESQ: 99,99,255,255,255,46
OK

RSRP = -140 + 46 = -94 dBm signal strength

And I also saw there is something implemented in the asset tracker application. My question is: Is there a function to read such parameter or how to do it if there is no such thing?

Thank you.

Voja

Parents Reply Children
  • Hi, 

    I am trying to do this, but there is no result:

    void get_signal_strength(void){
    
            const char signal_strength_command[] = "AT+CESQ";
            char cmd_rcv_buf[50];
            enum at_cmd_state *err;
            at_cmd_write(signal_strength_command, cmd_rcv_buf, strlen(cmd_rcv_buf), err);
            printk("state: %d   ", err);
            printk("answ: %s \n", cmd_rcv_buf);
    }


    Of course, I am connected to the NB-IoT network before calling this function. 
    Serial output is:
    state: 0   answ:  
    


    Do you know what might be the problem?



    Best regards,
    Voja

  • Try something like this:

    void get_signal_strength(void)
    {
    	const char signal_strength_command[] = "AT+CESQ";
    	char cmd_rcv_buf[50];
    	enum at_cmd_state state;
    	int ret = at_cmd_write(signal_strength_command, cmd_rcv_buf, sizeof(cmd_rcv_buf), &state);
    	if (state == AT_CMD_OK) {
    		printk("answ: %s", cmd_rcv_buf);
    	}	
    	printk("state: %d, ret %d\n", state, ret);
    }

  • Hi Hakan, 

    Thanks for the help, also one more thing needs to be changed. sizeof will return 0 because there is nothing in the buffer. 

    here is the function that worked for me:

    void get_signal_strength(void){
    
            const char signal_strength_command[] = "AT+CESQ";
            char cmd_rcv_buf[50];
            enum at_cmd_state state;
            at_cmd_write(signal_strength_command, cmd_rcv_buf, 50, &state);
            if (state == AT_CMD_OK) {
                printk("answ: %s", cmd_rcv_buf);
    	}	
            printk("state: %d, ret %d\n", state);
            
    }

Related