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

issue in sending the float value in ble_nus_send

Hi...

i have done the program to read the temperature sensor, i want to get the temperature in float value . i can able to read the temperature in float but i can't able to pass the float value in ble_nus_send . nRF52832 used segger 15.2v

here i am attaching my code , please tell me how to resolve this 

static void sensor_event_handler(void* p_context)


{
  uint16_t length1;
  uint16_t threshold;  
 
    char str[80];
     ret_code_t err_code;
 
     

        nrf_delay_ms(5000);

       while (m_xfer_done == false);
{
         m_xfer_done = false;
                
		uint8_t reg[2] = {0x00U};
        err_code = nrf_drv_twi_tx(&m_twi,LM75B_ADDR, reg, sizeof(reg), true);
		APP_ERROR_CHECK(err_code);
		while (m_xfer_done == false);
		nrf_delay_ms(5);
		
	        m_xfer_done = false;
		ret_code_t err_code1 = nrf_drv_twi_rx(&m_twi,LM75B_ADDR, &m_sample, sizeof(m_sample));
		APP_ERROR_CHECK(err_code1);
              
                
                NRF_LOG_INFO("hello :%d", m_sample);

                    uint16_t tempVal = (m_sample[0] <<  8) | m_sample[1];
        float tempC = tempVal * (0.0390625)/10;
       
 
    threshold=50;


  if(tempC < threshold )
            {
           
             length1 = sprintf(str,"%s%d.%01d", tempC);
 ble_nus_data_send(&m_nus,str,sizeof(tempC), m_conn_handle);
NRF_LOG_INFO("temp:%s%d.%01d", NRF_LOG_FLOAT(tempC));
          

              
             

                            
  }
       }
       }
  

Thanks in advance 

Parents Reply Children
Related