D21G IND.IO not connecting to Ethernet Module
I've been attempting to get a sketch working that involves UDP send/receive from the Eth module connected to a D21G IND.IO. I believe I've followed just about every piece of documentation avaialble (as well as experimenting with numerous other permutations of code) and had no success. I'm in need of some review/commentary of my attempts and perhaps some guidance:
The D21G works well on its own - the sketch for simple actuator control works fine.
The Eth Expansion module also boots up fine and I can see normal 'hi, look at me' packets coming out from an ipV6 address.
The network it is on has DHCP but i'm targeting a static address. (I've tried DHCP and it does not work either)
The code is based heavily on a test sketch I did on a Leonardo Eth which worked fine and conencted to the network without issue.
I'm suspecting is something to do with configuring the SPI bus but I can't find a specific example for the D21G and my attempts to kludge something together from other available samples/documents has not proven sucessful.
The root symptom is that the module jsut will not seem to get a dynamic IP or accept a manual IP and thus can't communicate.
The most recent version filtered for relevant code:
Includes:
#define W5500_ETHERNET_SHIELD
#include <Indio.h>
#include <Wire.h>
#include <SPI.h>
#include <Ethernet2.h>
#include <EthernetUdp2.h>
#include <UC1701.h> // Industruino LCD
static UC1701 lcd;
Setting net variables (I've tried both versions with IP objects or byte arrays):
//Arduino Net Interface
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x01 };
//byte ip[] = { 10, 102, 123, 123 };
//byte subnet[] = { 255, 255, 0, 0 };
//byte gateway[] = { 10, 102, 255, 254 };
//byte dnServer[] = { 8, 8, 8, 8 }; //Changed for security purposes
IPAddress ip(10, 102, 123, 123);
IPAddress subnet(255, 255, 0, 0);
IPAddress gateway(10, 102, 255, 254);
IPAddress dnServer(8, 8, 8, 8); //Changed for security purposes
unsigned int localPort = 10001;
// Create UDP Instances
EthernetUDP udpSock;
The setup code (I've also tried the IND.IO versions of these - no apparent difference):
pinMode(10, OUTPUT); //Eth SS
digitalWrite(10, LOW); //Eth SS On
pinMode(4, OUTPUT); //SD SS
digitalWrite(4, HIGH); //SD SS Off
Starting the Ethernet, UDP and Serial (Final Println always returns 0.0.0.0)
delay(5000);
// Start the Ethernet and UDP
Ethernet.begin(mac, ip); //, dnServer, gateway, subnet);
udpSock.begin(localPort);
delay(5000);
// Start Serial Port
SerialUSB.begin(9600);
SerialUSB.print("My IP is: ");
SerialUSB.println(Ethernet.localIP());
The loop code isn't relevant as we never get that far (and it works fine on the Leonardo Eth). It seems I just can't get the module itself to initialize.
Hoping someone can see what I'm missing here?
Hi Mike, sorry to hear about the issue you're having. Can you please try with the standard 'WebClient' example in the Ethernet2 library. Only replace all "Serial" with "SerialUSB" and then it should work on the D21G; i have just tested it here, and got a connection and reply in the Serial Monitor. Please let us know how that goes.
It is important to use the Industruino version of the Ethernet2 library; it has one important change: the SPI speed is set to 4MHz in the Ethernet2 library, /src/utility/w5500.cpp , line #25, as seen here: https://github.com/Industruino/Ethernet2/blob/master/src/utility/w5500.cpp
cc'd from my email response for the benefit of others: Hi Tom, Thanks for the direct response – it’s taken me a few days to find more time to spend on this. I’ve taken a couple more stabs with no success. Most recently I’ve – in sequence: - Wiped all traces of Arduino from this computer. - Reinstalled Just the IDE 1.8.5 - Installed just the 3 libraries (indio, ethernet2, UC1701) from zips downloaded directly from industruino github (all flagged as updated for D21G) - Uploaded the sample WebClient sketch (only changing Serial with SerialUSB) o Doesn’t work, nothing out via serial and nothing at all on wireshark with a direct connection) - Uploaded the sample UDPSendReceiveString sketch (only changing Serial with SerialUSB) o Doesn’t work, nothing out via serial and nothing at all on wireshark with a direct connection) - Uploaded my sketch o Serial works, LCD works incl backlight, IP comes up as 0.0.0.0 and nothing on wireshark from the device (plenty of traffic from my laptop when the port wakes up – link is active) During the uploads I tried multiple sequences of uploading and cycling 12V power and USB power as I do recall reading somewhere that the ethernet module needs a reset after upload? Anyways… Thoughts…? Thanks,
I am having a similar issue on the D21G Ind/IO. I am using a static IP and the Industruino responds to pings correctly on the static IP. When I try to telnet to it I am unable to connect to it.
When I try out the sample webclient app in Ethernet2 I get the following
Failed to configure Ethernet using DHCP
connecting...
connection failed
disconnecting.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 10/18/17, 10:11 PM |
Seen: 4134 times |
Last updated: 4/24/18, 5:16 PM |
Hi Mike, please check if you are using the Industruino version of the Ethernet2 library. There is one important difference with the original: change the SPI speed to 4MHz in the Ethernet2 library, /src/utility/w5500.cpp , line #25, as seen here: https://github.com/Industruino/Ethernet2/blob/master/src/utility/w5500.cpp