I'm reading values from a sensor, coming in as serial data.
The values come in multiple Serial bytes as follows:
For example a sensor reading of 2.16 comes in as the following four bytes: '2', '.', '1', '6'
Fairly simple, and it's been easy to print those 4 bytes out individually just using mySoftSerial.read() for each incoming byte; and then Serial.print(...) the 4 bytes to the terminal.
However, I would like to STORE altogether the four separate incoming Serial bytes of the value "2.16"... specifically, I want to store into one float variable so I can do arithmetic with it.
What would be an effective way to accomplish that?
Seems like a common thing to do, but I haven't come across any simple method.
[sidenote: I tried the approach discussed in a past thread, of using a union that has a float and a byte array, but that didn't solve the problem here because it appears the incoming data also has to have been sent out from a byte array originating from a union, which is not the case here]