-2

is it possible to connect Arduino Ethernet Shield direct to PC and send a String variable? How can I read it later on the PC?

Will this code work?

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

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; // Shield MAC

byte pc[] = "192.168.0.13"; // pc IP
EthernetClient client;

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

  Serial.println("connecting...");

  delay(5000);
  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("Sample String");
    client.println();
  } else {
    Serial.println("connection failed");
  }

}

void loop()
{

}

1 Answers1

1

No, you seem to be off on a tangent. There at least two problems:

  1. The Ethernet library is designed to run on an Arduino board. If you set the IP address to the same as the PC IP address, the network will get confused and nothing will work reliably.
  2. Are you asking how one can publish data from an Arduino board and read the results on a PC? This is easier. Just set up the web server example on the Arduino, and access it from a browser on your PC.
kiwiron
  • 744
  • 3
  • 9