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

how to send the float to string over ble_nus

hi, 

 I am working on temperature sensor i merged the uart and twi sensor , using nrf52832 + Max30205 (temperature sensor) . i am getting  the temperature in float which is printing in debug terminal , how to send the float over ble_nus _send . for that i need to convert into string right . i have done i have converted into string but i am no t receiving any data in nrf toolbox 

       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);
             
     uint16_t tempVal = (m_sample[0] <<  8) | m_sample[1];
          float tempC = tempVal * (0.0390625)/10;
           
      
    threshold= 28;

 if(tempC> threshold )
            {
             length1 = sprintf(str,"%.2f", tempC);
             ble_nus_data_send(&m_nus,str,sizeof(tempC), m_conn_handle);
              NRF_LOG_INFO("Temperature: " "%s%d.%01d", NRF_LOG_FLOAT(tempC));
                     
       
             
                            
  }
     
       
       }
       }
       

Parents Reply Children
Related