element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Power Line Communications Arduino Ethernet Shield problems
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 0 replies
  • Subscribers 400 subscribers
  • Views 245 views
  • Users 0 members are here
Related

Power Line Communications Arduino Ethernet Shield problems

cszym001
cszym001 over 13 years ago

I am trying to configure arduino to talk over a power line communications modem to a computer but I cannot control it.  When I try to ping the ip address of the ethernet shield it comes back "destination host unreachable"  but when I connect it directly to my computer it is fine.  I thought the PLC modem was just a pass through do I need gateway info?  How can I communicate with the arduino over the powerline modems?  I can connect and ping a IP camera no problem.  here is my code I am using:

 

#include <Ethernet.h>

#include <SPI.h>

#include <Servo.h>

//send a sequence to the arduino via your web browser like so: http://192.168.1.167/?23456789

//The way the code is currently setup is that the pins will go high one at a time, in sequence, for 25ms then move on to the next in line. So this example would blink pin 2,3,4,5,6,7,8 then 9.

// pin 9 controlls a servo

Servo myservo; // create servo object to control a servo

// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

boolean reading = false;

 

////////////////////////////////////////////////////////////////////////

//CONFIGURE

////////////////////////////////////////////////////////////////////////

byte ip[] = { 169,78, 32, 18 }; //ip address to assign the arduino

byte gateway[] = {169, 78, 32, 10 }; //ip address of the gatewa or router

 

//Rarly need to change this

byte subnet[] = { 255, 255, 0, 0 };

 

// if need to change the MAC address (Very Rare)

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

 

Server server = Server(80); //port 80

////////////////////////////////////////////////////////////////////////

 

void setup(){

//Pins 10,11,12 & 13 are used by the ethernet shield

 

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

myservo.attach(9); // attaches the servo on pin 9 to the servo object

 

Ethernet.begin(mac, ip, gateway, subnet);

server.begin();

}

 

void loop(){

 

// listen for incoming clients, and process qequest.

checkForClient();

 

}

 

void checkForClient(){

 

Client client = server.available();

 

if (client) {

 

// an http request ends with a blank line

boolean currentLineIsBlank = true;

boolean sentHeader = false;

 

while (client.connected()) {

if (client.available()) {

 

if(!sentHeader){

// send a standard http response header

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println();

sentHeader = true;

}

 

char c = client.read();

 

if(reading && c == ' ') reading = false;

if(c == '?') reading = true; //found the ?, begin reading the info

 

if(reading){

Serial.print(c);

 

switch (c) {

case '2':

//add code here to trigger on 2

triggerPin(2, client);

break;

case '3':

//add code here to trigger on 3

triggerPin(3, client);

break;

case '4':

//add code here to trigger on 4

triggerPin(4, client);

break;

case '5':

//add code here to trigger on 5

triggerPin(5, client);

break;

case '6':

//add code here to trigger on 6

triggerPin(6, client);

break;

case '7':

//add code here to trigger on 7

triggerPin(7, client);

break;

case '8':

//add code here to trigger on 8

triggerPin(8, client);

break;

case '9':

//add code here to trigger on 9

triggerPin(9, client);

break;

}

 

}

 

if (c == '\n' && currentLineIsBlank) break;

 

if (c == '\n') {

currentLineIsBlank = true;

}else if (c != '\r') {

currentLineIsBlank = false;

}

 

}

}

 

delay(1); // give the web browser time to receive the data

client.stop(); // close the connection:

 

}

 

}

 

void triggerPin(int pin, Client client){

//blink a pin - Client needed just for HTML output purposes.

 

switch (pin){

case 8:

{client.print("Opening Door");

client.print("<br>");

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

break;}

case 9:{

client.print("Closing Door");

client.print("<br>");

for(pos = 180; pos> 0; pos -= 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15);

}

break;}

 

default:

{

client.print("Turning on pin ");

client.println(pin);

client.print("<br>");

digitalWrite(pin, HIGH);

delay(25);

digitalWrite(pin, LOW);

delay(25); break;}

}

}

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube