Go Down

Topic: Can not chat in two directions using Arduino Ethernet Shield, why? (Read 4548 times) previous topic - next topic

creativen

I have my own project to make my Notebook and Netbook could chat each other using Arduino Ethernet Shield.

I pile up my Arduino UNO and Arduino Ethernet Shield,
then I connect my Notebook to Arduino UNO using USB printer cable then I connect my Netbook to Arduino Ethernet Shield using RJ 45 cable.

Then I upload ChatServer sketch from my Notebook to Arduino UNO with this change:
Code: [Select]
...
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xFE, 0xAC }; //same with the sticker
IPAddress ip(192,168,1, 77); // ip address assigned to my Arduino Ethernet shield
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);
...


So my full sketch is:
Code: [Select]

/*
Chat  Server

A simple server that distributes any incoming messages to all
connected clients.  To use telnet to  your device's IP address and type.
You can see the client's input in the serial monitor as well.
Using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 10 August 2010
by Tom Igoe

*/

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xFE, 0xAC };
IPAddress ip(192,168,1, 77);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);

// telnet defaults to port 23
EthernetServer server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet

void setup() {
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);
  // start listening for clients
  server.begin();
  // open the serial port
  Serial.begin(9600);
}

void loop() {
  // wait for a new client:
  EthernetClient client = server.available();
 
  // when the client sends the first byte, say hello:
  if (client) {
    if (!gotAMessage) {
      Serial.println("We have a new client");
      client.println("Hello, client!");
      gotAMessage = true;
    }
   
    // read the bytes incoming from the client:
    char thisChar = client.read();
    // echo the bytes back to the client:
    server.write(thisChar);
    // echo the bytes to the server as well:
    Serial.print(thisChar);
  }
 
}


Then, in my netbook I open RUN (Windows XP) then type TELNET then type o 192.168.1.77 [23]
Then it responds well, so everything I type in my netbook, it will appear int my notebook using Serial Monitor for Arduino

But I can not send any character from my notebook to the netbook, anyone know why ?
Any solution so they can communicate in two direction?
Is my notebook server/client?
is my netbook server/client?
I confuse...

Vielen Dank...

dxw00d

The sketch you are running communicates via ethernet. Only one of your machines is connected to the ethernet port on the shield, so only one of your machines can telnet to the Arduino.

creativen

If I use router to connect to my Arduino then from the router to many machine (PC,Notebook,Netbook),
then can I communicate in two direction, I mean not only receive chat but also send a chat?


The sketch you are running communicates via ethernet. Only one of your machines is connected to the ethernet port on the shield, so only one of your machines can telnet to the Arduino.

Hmm maybe it is because we use telnet (telecommunication network) so it can only communicate using ethernet cable, is there any other way (maybe not using telnet) so there are more than one machine can communicate to the Arduino?


Nick Gammon


I have my own project to make my Notebook and Netbook could chat each other using Arduino Ethernet Shield.


Why use the Arduino for this? What does it achieve?

Quote
I pile up my Arduino UNO and Arduino Ethernet Shield, then I connect my Notebook to Arduino UNO using USB printer cable


The printer cable?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

creativen



I have my own project to make my Notebook and Netbook could chat each other using Arduino Ethernet Shield.


Why use the Arduino for this? What does it achieve?

Actually at first, I want to do a trial so I know how the Ethernet Shield work.
Then It is just fun I can use arduino for communication between PCs

For my project, I want to control my arduino using LAN cable, in my case I want to control the arduino from my netbook, any idea for this?

Quote

Quote
I pile up my Arduino UNO and Arduino Ethernet Shield, then I connect my Notebook to Arduino UNO using USB printer cable


The printer cable?

Yes, the usb printer cable like in this image


dxw00d

That's a USB Type A (the flat end) to Type B (the squarish end) cable. It is often used for printers, but that doesn't make it a printer cable. External hard disks often use that type of cable, as do scanners, and many other things.

creativen


If I use router to connect to my Arduino then from the router to many machine (PC,Notebook,Netbook),
then can I communicate in two direction, I mean not only receive chat but also send a chat?


The sketch you are running communicates via ethernet. Only one of your machines is connected to the ethernet port on the shield, so only one of your machines can telnet to the Arduino.

Hmm maybe it is because we use telnet (telecommunication network) so it can only communicate using ethernet cable, is there any other way (maybe not using telnet) so there are more than one machine can communicate to the Arduino?


Anyone could help me to answer this?

silasmoeckel

Well first off you have to understand that the Ethernet shield is very limited that chip only supports 4 simultaneous sockets (telnet connections).  That chip has 8x the ram of a 328 and does most of the heavy lifting.  You seem to be looking to implement this http://arduino.cc/en/Tutorial/ChatServer

Chagrin

His notebook is connected via USB to the Arduino.
His netbook is connected via telnet to the Arduino.

If I understand correctly, his question is why he can send a telnet message from his netbook to the Arduino and see it in the serial monitor on his notebook, but if he types a message into the serial monitor on his notebook why he cannot see it in his telnet session on his netbook.

The answer is simple: because the sketch is not designed to do that. The sketch never performs any Serial.read() and never does anything with the data you're typing into the serial monitor -- it's a debugging, read-only display.

If from your notebook you opened a telnet session to the server and typed your commands there then the sketch should behave in the way you're expecting.

creativen


His notebook is connected via USB to the Arduino.
His netbook is connected via telnet to the Arduino.

If I understand correctly, his question is why he can send a telnet message from his netbook to the Arduino and see it in the serial monitor on his notebook, but if he types a message into the serial monitor on his notebook why he cannot see it in his telnet session on his netbook.

You are right exactly! You clear all misunderstanding, I might have problem in my english.


The answer is simple: because the sketch is not designed to do that. The sketch never performs any Serial.read() and never does anything with the data you're typing into the serial monitor -- it's a debugging, read-only display.

is there a sketch to fulfill my needs? two way chat?


If from your notebook you opened a telnet session to the server and typed your commands there then the sketch should behave in the way you're expecting.

How I open a telnet session to the server from my notebook if I just connect it using USB cable not RJ 45 cable?

Vielen Dank.

dxw00d

Quote
How I open a telnet session to the server from my notebook if I just connect it using USB cable not RJ 45 cable?

You can't.

Quote
If I use router to connect to my Arduino then from the router to many machine (PC,Notebook,Netbook),
then can I communicate in two direction, I mean not only receive chat but also send a chat?

Did you try this?

creativen


Quote
If I use router to connect to my Arduino then from the router to many machine (PC,Notebook,Netbook),
then can I communicate in two direction, I mean not only receive chat but also send a chat?

Did you try this?

No I did not, I want to make sure if it is possible then I will buy the router, just for fun to use arduino to chat...
Logically it should work, shouldnt it?

dxw00d


creativen


Do you not already have a router, for broadband?


I dont have a router yet...
What do you mean to tell me?

Go Up