avaldebe / PMserial

Arduino library for PM sensors with serial interface
MIT License
53 stars 21 forks source link

Question about the pm values datatype. #25

Closed LGnahore closed 2 years ago

LGnahore commented 2 years ago

Hello, i have been working with this library recently and have noticed that the datatype of the pm values is uint16_t. Is there any simple way that i can get those values as floats or doubles or does it require big adjustments?

(If it is relevant, I am using an ESP8266 and a PMS7003.)

avaldebe commented 2 years ago

you probably want to cast integer to a float, as in this example

int x;
int y;
float z;

x = 1;
y = x / 2;          // y now contains 0, ints can't hold fractions
z = (float)x / 2.