![Arduino serial write float](https://kumkoniak.com/39.jpg)
![arduino serial write float arduino serial write float](https://roboticsbackend.com/wp-content/uploads/2020/12/arduino_push_button_no_pull_up_down-768x367.png)
You'll just have to use some kind of "serial read", and use the numbers as you want, keeping in mind each number has a byte size. If on the receiving circuit you want to read the exact same array you have on your code here, then your sketch is fine. To avoid blocking calls to Serial.write (), you can first check the amount of free space in the transmit.
![arduino serial write float arduino serial write float](https://hacksterio.s3.amazonaws.com/uploads/attachments/1133864/circuit_YglDOZmyHS.jpg)
If the transmit buffer is full then Serial.write () will block until there is enough space in the buffer. So instead of getting 4 bytes and trying to fill them as a float you get a float and read it as 4 bytes: byte b (byte )&floatVal Then you can access b 0 to b 3 quite happily. If there is enough empty space in the transmit buffer, Serial.write () will return before any characters are transmitted over serial. You are seeing weird stuff when you write an byte greater than 127, because ASCII only includes definitions for 128 characters (0 to 127). Instead you need to work the other way around - cast a type that has smaller alignment requirements over the type that has larger requirements. Copy the above code and open with Arduino IDE Click Upload button on Arduino IDE to upload code to Arduino See the result on Serial Monitor.
![arduino serial write float arduino serial write float](https://hacksterio.s3.amazonaws.com/uploads/attachments/1142606/serial_temperature_sensor_Hn3qdSGbxb.png)
You are writing binary data, but you are trying to see them as ASCII, that's why you see for example } instead of 125, because the one byte 125 represents } in ASCII.
![Arduino serial write float](https://kumkoniak.com/39.jpg)