Sending data over WiFi between two Arduino MKR 1010 WiFi

Hi there!

Trying to figure out a way to make one Arduino 1010 send data through a WiFi router that two Arduino 1010 is connected to?

They are both connected to the WiFi router, but how do I program a Arduino to send data over WiFi?? And how do I recieve it with the other??

If you want them to talk directly to each other without a server between, you can run an HTTP client and server on both Arduinos and have each Arduino client make HTTP requests of the other Arduino server.

Thee_Captain: If you want them to talk directly to each other without a server between, you can run an HTTP client and server on both Arduinos and have each Arduino client make HTTP requests of the other Arduino server.

why HTTP? plain socket is good enough

https://arduino.stackexchange.com/questions/60819/esp8266-tcp-ip-communication/60821#60821

The only thing is I do not want internet connection.

So if I have a WiFi router, not connected to internet, and starts a wifi server on it and connects both arduinos as clients, is it just to do write and read on that server then?

#include <SPI.h>
#include <WiFiNINA.h>

char ssid = “SECRET_SSID”; // your network SSID (name)
char pass = “SECRET_PASS”; // your network password
int status = WL_IDLE_STATUS;

WiFiServer server(80);
WiFiClient client;

void setup()
{
Serial.begin(9600);
Serial.println(“Attempting to connect to WPA network…”);
Serial.print("SSID: ");
Serial.println(ssid);

status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED)
{
Serial.println(“Couldn’t get a wifi connection”);
while(true);
}
else
{
server.begin();
Serial.print(“Connected to wifi. My address:”);
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);

if (client.connect(myAddress, 80))
{
Serial.println(“connected”);
// Make a request:
client.write(“hello there”); //Will this message be avaliable for another module to retrieve?
}
}
}
void loop(){}

mjohansson95:
#include <SPI.h>
#include <WiFiNINA.h>

char ssid = “SECRET_SSID”; // your network SSID (name)
char pass = “SECRET_PASS”; // your network password
int status = WL_IDLE_STATUS;

WiFiServer server(80);
WiFiClient client;

void setup()
{
Serial.begin(9600);
Serial.println(“Attempting to connect to WPA network…”);
Serial.print("SSID: ");
Serial.println(ssid);

status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED)
{
Serial.println(“Couldn’t get a wifi connection”);
while(true);
}
else
{
server.begin();
Serial.print(“Connected to wifi. My address:”);
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);

if (client.connect(myAddress, 80))
{
Serial.println(“connected”);
// Make a request:
client.write(“hello there”); //Will this message be avaliable for another module to retrieve?
}
}
}
void loop(){}

yes. but this is a client. remove the server object and server begin.

and port 80 is for http protocol.
use port 23 or 2323 for plain text communication (telnet)

Thank you so much!

So I can connect the client directly to the router IP adress? Where do I read more about which ports are for what?

Thank you again! :)

https://en.m.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Is it possible to communicate between 2 WIFI1010 devices without any external router?

Or can we use WIFI1010 module as a router to establish a communication between few WIFI1010 devices.

If its possible, please provide an example.

Thanks.

Ykciv: Is it possible to communicate between 2 WIFI1010 devices without any external router?

Or can we use WIFI1010 module as a router to establish a communication between few WIFI1010 devices.

If its possible, please provide an example.

Thanks.

start one of them as AP