Arduino to Arduino by ethernet - HELP?

Hi,

I´m trying to do a project with two arduinos connected by ethernet, but the information about it is praticly 0.

Can anybody help me? Is it possible to connect by ethernet two arduinos? for example one arduino has a motion sensor and at the other end the other arduino has a LED, and when the motion sensor is triggered the LED turns on.

Well something like that... the only examples are by android or webpage but i was kind of trying to do it more direct... is it possible?

Cumps

I´m trying to do a project with two arduinos connected by ethernet,

. . .and I'm going for the forum record of the most cross-posts.

DO NOT CROSS-POST, IT WASTES TIME.

Cross post? sorry i wasn´t sure about the right categorie

Take a look here Send informations from Yun to Yun - #7 by Angelo9999 - Arduino Yún - Arduino Forum

The OP of that thread wants to use WiFi but the solution does not depend on what are you using.

They are in the same network so they can see each other. You can find the board in the network as http://arduino.local

You have to change "arduino" with the name of your board.

right now i have something like this but the connection is not bein established...

SERVER

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer Server;

void setup() {
Serial.begin(9600);
Bridge.begin();
Server.listenOnLocalhost();
Server.begin();

}

void loop() {
YunClient client = Server.accept();

if (client) {
Serial.println("Client Connected");

//Console.println(request);
//process(client);
client.stop();
}

delay(50);

IPAddress server(192,168,1,1); // adresse IP de la YUN1
if(client.connect(server,5555)){ // si on est connecté au serveur
Serial.println("connected");
}
client.stop();
delay(500);
}

CLIENT

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

IPAddress server(192,168,1,1); // numeric IP for Google (no DNS)
IPAddress ip(192, 168, 1, 2);

YunClient client;

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

void loop()
{

if (client.connect(server, 5555)) {
Serial.println("connected");
}
else {
Serial.println("connection failed");
}
client.stop();
delay(500);

I´m not sure where the problem is .... aparently is the code correct?

Before trying the sketch, check if the two boards are connected each other.

To test the connection, upload the YunSerialTerminal sketch on both of them, then run from serial terminal ifconfig to see the IP of your board.

Once you know the IP of one board, go write in the terminal of the other board

ping *IPofTheFirstBoard"

This is what the serial monitor shows:

[ 77.020000] eth1: link down
[ 79.020000] eth1: link up (100Mbps/Full duplex)
[ 119.020000] eth1: link down
[ 120.020000] eth1: link up (100Mbps/Full duplex)

Can you post the output of the ifconfig command and of the ping command

do i need to do the ifconfig command? i know the ip of both YUN by doing the arduino.local and then i can see their IP Adress

ifconfig command:

switching to jffs2

  • init -

Please press Enter to activate this console. [ 37.150000] Loading modules backported from Linux version master-2014-01-23-0-g62c147d
[ 37.150000] Backport generated by backports.git backports-20140124-0-g1256d3e
[ 37.190000] cfg80211: Calling CRDA to update world regulatory domain
[ 37.190000] cfg80211: World regulatory domain updated:
[ 37.200000] cfg80211: DFS Master region: unset
[ 37.200000] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[ 37.200000] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 37.210000] cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 37.210000] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[ 37.210000] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
[ 37.220000] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (300 mBi, 2000 mBm)
[ 37.220000] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)
[ 38.180000] ieee80211 phy0: Atheros AR9330 Rev:1 mem=0xb8100000, irq=2
[ 38.190000] cfg80211: Calling CRDA for country: US
[ 38.190000] cfg80211: Regulatory domain changed to country: US
[ 38.190000] cfg80211: DFS Master region: FCC
[ 38.190000] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[ 38.200000] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm)
[ 38.200000] cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (300 mBi, 1700 mBm)
[ 38.210000] cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz), (300 mBi, 2400 mBm)
[ 38.210000] cfg80211: (5490000 KHz - 5600000 KHz @ 80000 KHz), (300 mBi, 2400 mBm)
[ 38.210000] cfg80211: (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2400 mBm)
[ 38.220000] cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (300 mBi, 3000 mBm)
[ 38.220000] cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 4000 mBm)
[ 38.630000] NTFS driver 2.1.30 [Flags: R/O MODULE].
[ 38.680000] Error: Driver 'gpio-keys-polled' is already registered, aborting...
[ 38.800000] PPP generic driver version 2.4.2
[ 38.860000] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 38.980000] NET: Registered protocol family 24
[ 39.010000] nf_conntrack version 0.5.0 (954 buckets, 3816 max)
[ 39.450000] i2c /dev entries driver
[ 39.480000] Linux video capture interface: v2.00
[ 39.600000] fuse init (API version 7.18)

You posted the output of the boot process. To post the ifconfig output wait until the Yun finishes booting and then write in the serial monitor ifconfig and press enter.

i think i made it because know i can see in both of them if they are connected...

But its always transmitting that it is connected.... if i had a motion sensor on the client and i wanted to send the information to the server every time the sensor detect something and then on the YUN server it would turn of an LED how could i put the function on the code?

right know i´ve got something like this:

SERVER
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer server;

void setup() {
Serial.begin(9600);
Bridge.begin();
//Server.listenOnLocalhost();
server.begin();
}

void loop() {
YunClient client = server.accept();
if (client) {
Serial.println("Client Connected");
client.stop();
}
else {
Serial.println("connection failed");
}
client.stop();
delay(500);


CLIENT
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

IPAddress server(192,168,1,1);
YunClient client;

void setup() {
Serial.begin(9600);
delay(500);
Bridge.begin();
delay(500);
}
void loop()
{
if (client.connect(server, 5555))
{
Serial.println("connected");
delay(1000);
client.stop();
}
else {
Serial.println("connection failed");
(!client.connected());
{
Serial.println();
Serial.println("disconnecting.");
client.stop();

while (true);
}

delay(2000);
}
}

With the client:
after it connects to the server you can use client.write() to write data to the server.

With the server:
After it accepts the client and checks the connection, it can read data from client with client.read() or client.readString().
Here you can find an example for the server, the last step contains an example code.
http://scuola.arduino.cc/lesson/zzdeJ3m/YunServer_Sensor_values_to_HTML_page

thanks!! it´s working but the problem is that know i have a problem with the libraries because i´m using this:

#include <VirtualWire.h>
#include <Bridge.h>
#include <YunClient.h>

and this is the message error:

Bridge\Bridge.cpp.o: In function BridgeClass::crcCheck(unsigned int)': C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:50: multiple definition of crc16_update(unsigned int, unsigned char)'
VirtualWire\VirtualWire.cpp.o:C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:50: first defined here
Bridge\Bridge.cpp.o: In function String::operator+=(char const*)': C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:66: multiple definition of crc_xmodem_update(unsigned int, unsigned char)'
VirtualWire\VirtualWire.cpp.o:C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:66: first defined here
Bridge\Bridge.cpp.o: In function BridgeClass::transfer(unsigned char const*, unsigned int, unsigned char const*, unsigned int, unsigned char*, unsigned int)': C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:79: multiple definition of _crc_ccitt_update(unsigned int, unsigned char)'
VirtualWire\VirtualWire.cpp.o:C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:79: first defined here
Bridge\Bridge.cpp.o: In function BridgeClass::begin()': C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:90: multiple definition of _crc_ibutton_update(unsigned char, unsigned char)'
VirtualWire\VirtualWire.cpp.o:C:\Program Files (x86)\Arduino\libraries\VirtualWire/util/crc16.h:90: first defined here
collect2: error: ld returned 1 exit status

Both Bridge and VirtualWire are including the same file, so it can't compile.