문제

I am using an arduino v1.0.3 with xlively to upload sensor data but it only uploads 2 decimal positions. Is there a way to change this (would like 3 or 4 decimal positions) thanks

XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
.
.
.
datastreams[0].setFloat(pres);
도움이 되었습니까?

해결책

Firstly, I'd like to note that most Arduino boards use the 8-bit AVR microcontrollers, which do not have a floating-point unit (FPU). The compiler will add functions that perform floating point operation in software and this increases the code size and decreases performance. As far as I know ARM-based Arduino boards available today do not have an FPU either.

More specifically to your question, Xively library for Arduino is using print() method, which can optionally take a second argument if you require more decimal places. The easiest way would be to amend lines 165 to 168 in XivelyDatastream.cpp to do the following:

case DATASTREAM_FLOAT:
  count += aPrint.print(_value._valueFloat, 4);
  break;
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top