How to convert float variable to byte & back again?

how to convert float to byte variable? I hope that many can help me in this case. thank you

A float will not fit in a byte so you cannot do what you ask.

Why do you think that you need to do it ?

im sorry i dont know that , i just try to send data to lora gateway, im beginner ,i learn to send data to lora gateway,can you help me to send data to lora gateway?i use dragino module

(deleted)

spycatcher2k: GOOGLE 'C++ struct' - Allows you to access the bytes that make up the float!

Did you mean union rather than struct ?

(deleted)

Would it be possible to get the address of the float using a pointer and put all the bytes at the addresses from that one address into bytes?

Well, OP hasn't bothered to post any code, so we'll have to guess. I'd say it's probably not necessary to "convert" to bytes in the first place.

With most RF Comm libraries (like RadioHead) you just need to supply a pointer to your data and the number of bytes to transfer. The library does the rest.

On the RX side, you just do a memcpy() from the RX buffer to a data element of the same type as in the TX code. The type of data is irrelevant. It could be a byte, int, c-string, float, array, struct, etc. I usually use a struct with this technique as it can handle mixed data types.

OP should start with examples from the library.

ekolukito: im sorry i dont know that , i just try to send data to lora gateway, im beginner ,i learn to send data to lora gateway,can you help me to send data to lora gateway?i use dragino module

Please provide a link to where you are learning from.

Have you got a program that you are having a problem with ?