Sending data from arduino server to two two IP address

Hello,

I want to send data from arduino as server to two IP addresses simultaneously.

Please suggest

send to IP 1.
send to IP 2.

A server doesn't initiate a communication. A client does.

PS: There are other solutions, but your information is not sufficent to answer. Provide more information - ask a question.

Sir, in my project, i am reading data from a sensor on arduino and this data needs to be sent from arduino to two independent systems. Thus how shld i proceed with this.
Pls help as i am a beginner

i'm using the following.
a bit convoluted because there are multiple clients (and IPs) indexed by twr. if an attempt to send (i.e. print) fails, an attempt is made to connect and immediately re-send

// ---------------------------------------------------------
// common routine for sending strings to wifi
void
nodeSend (
    TwrSym       twr,
    const char*  msg )
{
    if (1)
        printf ("  %s: twr %d %s, %s\n",
                __func__, (int)twr, twrs [twr].sym, msg);

    if (! client [twr].print (msg))  {
        printf ("   %s: ... re-connecting - %s %d\n",
                    __func__, twrs [twr].ip, port);
        client [twr].connect (twrs [twr].ip, port);
        delay (500);
        if (! client [twr].print (msg))
            printf ("    %s: %s failed to connect\n", __func__, twrs [twr].sym);
        else
            printf ("    %s: %s connected\n", __func__, twrs [twr].sym);
    }
}

your specification is a bit vauge
what server software will the "!servers" be running
e.g. they could run FTP servers - when the Arduino has data it could run an FTP client which transmits a file
or you could write your own TCP/UDP server/client software

My project is as:

Arduino acting as client (ip: 10.5.11.100)
Arduino need to send command/querry over ethernet to twos ystems acting as servers (ip: 10.5.11 101 and 10.5.11.102).

Servers can take querry as:
http://10.5.11.101/SWPORT? and returns integar in response.

How to send above querry to two servers simultaneously from arduino as client.

Can you pls help me with the code.

Much be delighted.

post your code (in highlighted area after clicking </> icon)

I request you to help me with the code

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

EthernetClient client;

int HTTP_PORT = 80;
String HTTP_METHOD = "GET ";
char HOST_NAME[] = "http://10.5.11.100";

void setup() {
Serial.begin(9600);

if (Ethernet.begin(mac, 80) == 0)
{
Serial.println("Failed to obtaining an IP address using DHCP");
while(true);
}

if(client.connect(HOST_NAME, HTTP_PORT))
{
Serial.println("Connected to server");

client.println(HTTP_METHOD + "/MN?" + " HTTP/1.1"); //http://10.5.11.100/MN? returns model name of the device when connected from a pc. Trying to get the same by sending HTTP request from arduino acting as client.

client.println("Host: " + String(HOST_NAME));
client.println("Connection: close");
client.println();

while(client.connected()) 
{
  if(client.available())
  {
    String c = client.read();
    Serial.print(c);
  }
}
client.stop();
Serial.println();
Serial.println("disconnected");

}
else
{
Serial.println("connection failed");
}
}

void loop() {}

Pls suggest if my code is correct for sending an http request from arduino acting as client to a server at 10.5 11 100.

Server replies model name when requewt is made from browser as http://10.5.11 100/MN?.

Trying to get the same using arduino

does the host name argument to connect() need to be "http://10.5.11.100/MN"?

No host name is http://10.5.11.221.
MN? is querry to get model name

a server will often have different responses when a sub-folder is appended to the hostname

@ertarun86

welcome to the arduino-forum.

please describe what kind of data do you want to transmit.
Post some lines of example-data

post a description of what the data represents
post a description of

which device will initiate sending the data

will the Arduino send sensor-data once every X seconds?
will the Arduino send data only after having received a request to do so?

I estimate using a client/server-connection is overcomplicated for this application

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.