Hello Arduino community
I'm trying to send values of type int32_t, measured by an ADC on a microcontroller, with server.write() through an ethernet connection. The connection works totally fine and transmitting char arrays, for example "Hello", works perfectly. I have trouble sending and/or recieving or maybe converting numbers. The values of type int32_t contain 4 numbers.
Until now my attempt to send looks like this (the variable num is normally set by the ADC):
int32_t num = 1328; server.write((char*) &num, 4);
On the recieving computer the code looks like:
char buffer; r = recv(socket, buffer, 64, 0); buffer[r] = '\0'; //terminating the string with a null //printing out the array of course gives me symbols and letters
But how can I correctly convert the garbage I get back to a useful value, like 1328, which i can save in a int variable? Can I do some kind of cast?