Restricting number of decimal places sent?


#1

Is there a way to restrict the number of decimal places that cayenne.virtualWrite sends?
I am seeing it send three every time i send a float, and I would prefer only one to make the graphs nicer - to much “jitter” otherwise


#2

Can you show the output of serial monitor and the code you are using


#3

Cayenne.virtualWrite(0,readadc(0)*0.0207);

Sends a value x.xxx

Just want to restrict this to sending x.x


#4

do you want it to be shown as x.x on dashboard or you want to truncate on device?
if on dashboard then in seting you can adjust the number of decimal places to 1.
on device then you can truncate using something like:

float x = 1.6634;
char y[5];
void setup() {
  Serial.begin(9600);
  dtostrf(x, 5, 1, y);
  Serial.println(y);
}
void loop(){
}

#5

I’m truncating the display in dash board already but the graph still shows the 3 decimal places and its all jitter – which I’d like to remove by truncating on the device

I’ll see if that code fits tomorrow and let you know – super tight on code space


#6

@tim2 about the storage space issue, can you try connecting using manual connection code https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Connections/ManualConnection/ManualConnection.ino

it saves around 10% of space.


#7

I’ll experiment with that – just complicates device deployment with manual configuration required

Tim