Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is most likely no translated for the post!




Ethernet ENC28J60 p...
 
Share:
Notifications
Clear all

Ethernet ENC28J60 problem


(@aashish)
New Member
Joined: 5 years ago
Posts: 0
Topic starter  

I need to interface ethernet with my arduino and got an ENC28J60 module
from ebay
[ http://www.ebay.in/itm/ENC28J60-ETHERNET-LAN-NETWORK-MODULE-FOR-ARDUINO-AVR-and-others-/301760059363?hash=item46424d17e3:g:f3QAAOSwNNxWE50r]

I followed the tutorial :
[//www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/]
connected the module to my arduino UNO as,

ENC28J60    ETHER_28J60   Ethercard   UIPEthernet   My eBay Module
module      <---------------arduino pin map (lib wise)------------------------>
Pin name   
 SS                    10               8 (!)        10                  10
 MOSI (SI)            11                11        11                  11
 MISO (SO)    12                12        12                  12
 SCK                    13                13        13                  13

 VCC                  <---------------------V3.3------------------->
 GND                  <---------------------GND------------------->

I don't have an ethernet connection, i use USB dongle to connect net to my pc------so i shared my USB dongle connection to LAN

connected
RJ45 cable b/w pc and ENC28J60 module, turned on USB dongle net and No
status LEDs blink on ENC28J60 module's ethernet port ---------- OK

now I got UIPEthernet library, and uploaded the following example to my Arduino uno

<code style="max-height: none; height: 200px;" class="bbc_code">#include <UIPEthernet.h> // Used for Ethernet

// * ETHERNET SETTING *
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };                                     
IPAddress ip(192, 168, 1, 179);                       
EthernetServer server(80);

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

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.print("IP Address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();

  if (client)
  { 
    Serial.println("-> New Connection");

    // an http request ends with a blank line
    boolean currentLineIsBlank = true;

    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();

        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == 'n' && currentLineIsBlank)
        {
          client.println("<html><title>Hello World!</title><body><h3>Hello World!</h3></body>");
          break;
        }

        if (c == 'n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != 'r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }

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

    // close the connection:
    client.stop();
    Serial.println("   Disconnectedn");
  }
}

even now No status LEDs on ethernet port of ENC28J60 module glows, only red power indicator glows

it
seems that my pc is not 'giving' internet traffic to ENC28J60 module as
No status LEDs on ethernet port of ENC28J60 module glows,

also on my pc LAN icron shows unpluged ??

Do
i need a switch or router or ethernet connection only to use ENC28J60
module, i cannot share my pc net ??, or something else I am doing
wrong???

Please help me, I am scared.......is my ENC28J60 module faulty??

Please help

Thanks in advance



ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1832
 

When directly connecting to a PC you will need:

1) A so call crossed ethernet cable - some of the wires are switched around (see: link).

2) You need to assign a fixed IP address to the Arduino (DHCP will not work), and set network mask and gateway. The gateway is your PC.

I can however not recommend working this way, as a lot of complications will arise, which make trouble shooting unnecessarily complicated. I really recommend working with a normal ethernet cable and a router. Even if the router is just a cheap one.


ReplyQuote
(@aashish)
New Member
Joined: 5 years ago
Posts: 0
Topic starter  

thanks a lot, means my ENC28J60 module is not faulty ------ Isn't it?

asking this is offbeat but can u please share how can i arrange such a router which accepts my usb 3g dongle and outputs ethernet??
thanks

ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1832
 

First question: which OS/Browser are you using to post here?
Somehow it adds weird <span> tags. I'm just being curious if this is something I should try to catch in this editor ... 
I have seen that with a few one other user and I'm wondering where these <span>'s come from ...

Anyway, back to topic with for your router question;

There are a few routers out there that actually accept a USB 3G Dongle. I have a Netgear here that claims it does - but I have not tested this, and this particular router might be a bit expensive for a simple test.

My DSL modem actually allows a 3G dongle as well - it's an ZTE Experia H368N as far as I can tell. Again: untested.

Normally you'd do something like this:

Arduino+Ethernet -> Router+3G dongle

If your router does not support a 3G dongle, then you basically have 3 options:

- Get another router than allows you to plug in a 3G dongle
- Use a different kind of Internet (DSL, Cable) with a regular router
- Get a router that already has 3G build in


ReplyQuote
(@aashish)
New Member
Joined: 5 years ago
Posts: 0
Topic starter  

Hi sorry for comming after very long time,
I finally managed to run the Hello Word! using EtherCard and UIPEthernet library with my college net
but now I want to add some data to my server, I take a php hosting from 0fees and now I can send the data to my server using : http://ashutest123.0fees.us/dataupload1.php?data=somedata and check the uploaded list of data in the table as http://ashutest123.0fees.us/showdata.php --------- u can take a view yourself.
Now I take the code from your "data push" example as,..

<code removed and replaced in following post>

but it does not upload any data to my database, it reports "connected" on the serial monitor but no upload is there,
please help me, where I am wrong.
Thanks in advance

ReplyQuote


(@aashish)
New Member
Joined: 5 years ago
Posts: 0
Topic starter  

Ohh the source code not seem to show good in the reply, please see the attachment


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1832
 

The best way to post code, is first pasting the code, select the code and then click the "code" button above:

#include <UIPEthernet.h> // Used for Ethernet
// * ETHERNET SETTING *
// Arduino Uno pins: 10 = CS, 11 = MOSI, 12 = MISO, 13 = SCK
// Ethernet MAC address - must be unique on your network - MAC Reads T4A001 in hex (unique in your network)
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };                                      
// For the rest we use DHCP (IP address and such)
EthernetClient client;
char server[] = "ashutest123.0fees.us"; // IP Adres (or name) of server to dump data to
int interval = 5000; // Wait between dumps
void setup() {
  Serial.begin(9600);
  Ethernet.begin(mac);
  Serial.println("Tweaking4All.com - Temperature Drone - v2.0");
  Serial.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-n");
  Serial.print("IP Address : ");
  Serial.println(Ethernet.localIP());
  Serial.print("Subnet Mask : ");
  Serial.println(Ethernet.subnetMask());
  Serial.print("Default Gateway IP: ");
  Serial.println(Ethernet.gatewayIP());
  Serial.print("DNS Server IP : ");
  Serial.println(Ethernet.dnsServerIP());
}
void loop() {
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("-> Connected");
    // Make a HTTP request:
    client.print( "GET /dataupload1.php?");
    client.print("data=");
    client.print( "thanksGOD" );
    client.println( " HTTP/1.1");
    client.print( "Host: " );
    client.println(server)
    client.println( "Connection: close" );
    client.println();
    client.println();
    client.stop();
  }
  else {
    // you didn't get a connection to the server:
    Serial.println("--> connection failed/n");
  }
  delay(interval);
}


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1832
 

First thing I'd like to say: I did write an article how to push data with this Ethernet shield. It might be helpful for you or other who are reading this. Seems you might have read this article already ... 

So submitting data and showing data works on the webserver end.

I have however observed that resolving a name doesn't always seem to work, so instead of "ashutest123.0fees.us" use the IP address of the server. However, that might introduce a new problem ...

You seem to be having a shared server, so using the IP address (185.27.134.147) will not work.
I would recommend asking your host for a dedicated IP address if possible and use that instead for the server. or ask you provider how to reach your website with an IP address. This could be something like http://185.27.134.147/blablayouraccount/dataupload1.php etc.


ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: