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

read battery status using nfc with nrf52832

Hi,

I am not yet familiar with NFC.Is it possible to read battery data  from the NFC tag of the nRF52 to another device (for example a smartphone). I want to write simple application that reads battery status when the NFC tag is read by an NFC polling device, I want to write application using sdk 12.3.0 and sd132.

Parents Reply Children
  • uint8_t  percentage_batt_lvl;
    
    void get_battery_status()
    {
    	saadc_init();
    	nrf_drv_saadc_sample();
    	nrf_delay_us(200);
    	nrf_drv_saadc_uninit();
      
    }
    void sperNum(uint8_t sepNum, uint8_t num[])
    {
       
       num[0] = sepNum%10+48;
       num[1] = (sepNum/10)%10+48;
       num[2] = (sepNum/100)+48;
       
       
    }
    static void en_record_add(nfc_ndef_msg_desc_t * p_ndef_msg_desc)
    {
    /** @snippet [NFC text usage_1] */
    uint32_t err_code;
    
    static const uint8_t en_code[] = {'e', 'n'};
    
    uint8_t p[3];
    
    sperNum(percentage_batt_lvl,p);
    
    NFC_NDEF_TEXT_RECORD_DESC_DEF(en_text_rec,
    UTF_8,
    en_code,
    sizeof(en_code),
    p,
    sizeof(p));
    /** @snippet [NFC text usage_1] */
    
    err_code = nfc_ndef_msg_record_add(p_ndef_msg_desc,
    &NFC_NDEF_TEXT_RECORD_DESC(en_text_rec));
    APP_ERROR_CHECK(err_code);
    
    }

    I have called get_battery_status function in main context  in for loop.

  • Ok. Do you get the callback from the saadc? Does it have any values, or is it 0?

    And en_text_rec, is it 0, or does it contain a value?

    Have you tried debugging (turn off optimization in your project) to see where it fails?

  • The problem is now solved. Actually problem is with my pca10040 board.I have tried with another pca10040 board and got required output.

Related