Read values and store them as variables over ethernet

Dear all,

I'd like to ask for help in sending data from one arduino to another over ethernet (both using w5100).

I have 12 float variables that I need to send to another arduino over the local network.

I can generate an HTML (as showed in Webserver example) showing the 12 variables in 12 new lines or in one single line next to each other.

However I do not know how should I read them with the other arduino.

I guess I can read the whole info with:

if (client.available()) {
char c = client.read();

or string c, but than I'll have a string/String with lets say:

"24.2 33.3 24.2 22.2 22.5 55.5 55.1 23.3 21.1 32.2 12.2 23.2"

and I need to separate and assign them somehow to 12 variables.

Could anyone help me in this?
Is there any other (more straight-forward) method to send data over ethernet?

Sorry for this, but I'm quite novice and could not figure it out myself.

Thank you,

Gergo

I think the EthernetClient is part of the Stream class. You could use parseFloat() to get those float numbers.

A more direct approach is to use UDP. But UDP data packets are transmitted without any handshake or check that they actually arrive. When for example the temperature is transmitted every 5 minuts, it is often no problem that once in a while a packet gets lost.
The Ethernet reference page contains a list of the function, also for UDP, and links to examples.

I partially agree with Peter_n on the UDP part. I use it for fast data transfers if I need more than one transfer every couple seconds.

But I think it is as reliable as TCP on a localnet. The UDP.endPacket() function returns a value indicating if the next device en route to the destination device took the packet, and on the same localnet, the next device en route to the destination device is the destination device. :wink:

Thank you for the both of you.

I'll try these during the forthcoming nights.

Gergő