I am trying to send data from one arduino to another over ethernet using udp protocol. In arduino writing data over udp is like this

UDP.write(buffer, size);

where buffer is an array to send as a series of bytes and size is the size of the array.

Now, i am reading a sensor value from a0 pin of the arduino it will be stored either in int or float type variable. As mentioned earlier udp only sends byte type array. so all i want to do is convert the value stored in the variable to the byte type array. my variable will be.

int data;
byte data_array[Size];

and in loop


now i have convert this value in data_array;

Please provide the suggestion with proper explanation. Thank you

  • UDP.write((const byte*) &data, sizeof(data));
    – Juraj
    Mar 11 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.