uint32_t temp_values_handler() { uint32_t err_code = NRF_SUCCESS; int32_t temp_buffer; err_code = bme280_read_temperature(&temp_buffer); if (err_code != NRF_SUCCESS) { // temp_printf("temp: bme280_read_temperature() failed.\r\n"); return err_code; } char val[20]; char time_val[20]; add_zeroes((int)temp_buffer, val); add_zeroes((int)getTimeStamp(), time_val); char buf[20]; sprintf(buf, "\n%d,%s,%s", DEVICE_ID,time_val,val); log2sd(buf, "READINGS.txt"); // temp_printf("li\n"); // temp_printf("Temperature: %d\n", (int)temp_buffer); err_code = ble_ambient_sensor_update(m_temp.m_amb, (uint8_t *) &temp_buffer, AMB_TEMP_MAX_PACKET_VALUE, BLE_AMBIENT_TEMP); check_ble_service_err_code(err_code); return NRF_SUCCESS; }
static int read_temperature(void *dev, phydat_t *res) { bme280_t *d = (bme280_t *)dev; res->val[0] = bme280_read_temperature(d); res->unit = UNIT_TEMP_C; res->scale = -2; return 1; }
uint32_t temp_values_handler() { uint32_t err_code = NRF_SUCCESS; int32_t temp_buffer; err_code = bme280_read_temperature(&temp_buffer); if (err_code != NRF_SUCCESS) { temp_printf("temp: bme280_read_temperature() failed.\r\n"); return err_code; } char buf[12]; sprintf(buf, "%d,%d,%d,%d,\n", DEVICE_ID,SENSOR_TEMP_ID,(int)temp_buffer,000); log2sd(buf, "TEMP.txt"); lerCartao(); temp_printf("Temperature: %d\n", (int)temp_buffer); err_code = ble_ambient_sensor_update(m_temp.m_amb, (uint8_t *) &temp_buffer, AMB_TEMP_MAX_PACKET_VALUE, BLE_AMBIENT_TEMP); check_ble_service_err_code(err_code); return NRF_SUCCESS; }