Library For Arduino To Convert Varuables To Bytes And Back - GitHub
Maybe your like

What's about ?
Have you ever wanted to transmit int,short,long,double or any other numeric type over I2C,SPI,serial or other protocol or bus, but you converted variable to string to be able to transmit it char by char. This library enables you to convert any numeric value to bytes or other way around and you can also print array of bytes.
What you need to consider, when you are using this library
When you are using this library, you need to consider variable byte size, because if you are using different platforms, then there may be some errors, because int on platform 1 has 4 bytes and int on platform 2 may has 2 bytes.
Examples
Convert numeric variable for eg. int,short,float,double to array of bytes.
int somevar = 5; size_t blk_size = 0; uint8_t *block = ByteConvert::varToArray<int>(blk_size,somevar); // Use array delete block; // Don't forget to free memory, when you don't need array any moreConvert array of bytes to numeric variable.
uint8_t *block; // Predefined byte array with size of int int somevar = ByteConvert::arrayToVar<int>(block); // Use block & somevar delete block; // Don't forget to free memory, when you don't need array any more // Use somevarConvert array of bytes to string of hex characters
size_t blk_size; // Predefined size of byte array uint8_t *block; // Predefined byte array with size of int String somevar = ByteConvert::arrayToString(blk_size,block); // Use block & somevar delete block; // Don't forget to free memory, when you don't need array any more // Use somevarConvert string of hex characters to array of bytes
String somevar = ""; // Predefined string size_t blk_size = 0; uint8_t *block = ByteConvert::stringToArray(blk_size,somevar); // Use block delete block; // Don't forget to free memory, when you don't need array any moreTag » Arduino Convert 4 Bytes To Int
-
How To Convert 4 Bytes Into A Long? - Arduino Forum
-
Combining 4 Bytes Into One Long Int - Arduino Forum
-
Converting An Int Into A 4 Byte Char Array - Arduino Forum
-
Help With Converting 4 Bytes To A Long - Arduino Forum
-
Convert Large Number (int) To 4 Bytes - Arduino Forum
-
4 Byte For Int - Programming Questions - Arduino Forum
-
Convert 4 Bytes To Long On Arduino Error - Stack Overflow
-
Conversion Octet En Entier Arduino | Delft Stack
-
Converting 4 Bytes To Integer - MIT App Inventor Help
-
Working With Bytes | The Things Network
-
Convert 32 Bit Long To 4 Bytes And Back Again - CAN Bus
-
Converting String Of Bytes To Integer - General Usage - Julia Discourse
-
Convert Float To 4 Bytes And Then Back Again - Mbed
-
Converting Integer To Byte : R/arduino - Reddit