Go Down

Topic: EthernetUdp Sending Sensor Data (Read 303 times) previous topic - next topic

phinsil6

Hello!

I have a couple of sensors that I am trying to send out over a UDP socket to processing but I am having trouble concatenating a string together and sending it out.

For example, I am trying to read in Analogs 0-3, and concatenating as such:
Code: [Select]
String data = "*" + analogRead(0) + "/" + ... + analogRead(3)
But then another problem is that I need to send it over Udp via Udp.write() but that only seems to except character arrays.  So how do I accomplish this?

wildbill

The easiest way is to use the String method toCharArray to get your data into a form suited to UDP.write. Better would be to use sprintf to build your char array and get rid of the String object.

phinsil6

So with toCharArray I can build a string and then write it to the socket as such?
In what format will other side pick it up as? String?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy