For a robust communication, consider adding something like byte escaping or reserving a bit bor handshaking Note 2: this should work, but you will have a lot of problems in "real life" because you don't have a way to detect the start and stop points in the transmission. Try and, if it doesn't work, we'll look at it again Note 1: I haven't tested this, so there could be errors. Uint8_t *recv_bytes = (uint8_t*)transmit If (Serial.available() >= 3 * sizeof(float)) Receiver’s Code: float received //create an float array Serial.write((uint8_t*)transmit, 3 * sizeof(float)) Sender's code: float transmit= //Values to be sent If you want to pass them "as they are", you can first cast the values' array to a byte array, then send it "raw" when receiving you just have to receive all the bytes and. This is because Serial.Write accepts integer values, so your floats are converted to int (i.e. You are not seeing the first two digits you are seeing the integer part of it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |