BME280 and pressure with 2 decimals

Hi everybody!

This is not my first time dealing with ESP8266+BME280+MQTT, but this is my first time using Cayenne. I have an issue with displaying pressure with 2 decimals, if I use:

P = bme.readPressure() / 100.0F;

Cayenne.virtualWrite(2, P, “bp”, “hpa”);

I get value of 1004, if I remove (100.0F) I get value of 100482, inside of Cayenne interface when I try to set 2 decimals, I get 100482.00, instead of moving decimal to the left it moves it to the right and adds 00.
Does anyone have any recommendations how to fix this? Thanks in advance.

you need to send the decimal point from the device itself. From cayenne when you change decimal it only add the 0 after the decimal point.

Before this I was using MQTT (Mosquitto) + InfluxDB + Grafana, and with this code I was getting value with 2 decimals without any modifications.
I’m trying to figure out why there seems to be an issue with Cayenne…

are you using float P ?

2 Likes

I didn’t…
That fixed it! Thanks so much Shramik for you help!

1 Like