Teensy 3.5/3.6 Ethernet

Status
Not open for further replies.
Hi,

On the spec for the 3.5 and 3.6 it says Ethernet 1 for both (https://www.pjrc.com/teensy/techspecs.html) bottom of this table. So looking around all I can find is that you still need to use the WIZ820I/850 along with the Adaptor board, is this correct or can I just add an RJ45 Socket to my 3.5 board and away I go?

I don't need the SD card Adaptor board is what I am thinking as the 3.5/6 has SD built in and is 3.3V so can power the WIZ from that but can't find any power details for the Wiz if indeed it's needed.

Thanks

Cliff.
 
Please use the search, which results in threads like these almost instantly. The native Ethernet support is still very experimental and besides some basic UDP stuff can't do much right now. If you want to join the development, the Teensy native ethernet board is available. Note that you still need magnetics and a PHY IC as well.

Seeing that complete Wiz850io boards currently sell for less than €/$10 including shipping, the Wiznet way is currently still the best for both price and performance.
 
Epyon,

Yes I see this thread but it's talking about POE and I don't need POE as I am getting power from the USB connection. Also I am trying to highlight that the sales spec on the website says that it has an Ethernet port and that is one of the reason I liked the board but in fact it doesn't so the page should be updated.

Thanks

Cliff.
 
The thread links to other threads, threads that you would also have found with the search function ;) .

The specs page is correct. The Ethernet portion clearly states: "A special shield is required to connect an Ethernet PHY chip and magnetics to actually communicate with other computers. "
 
Then why don't the 3.2 boards have a 1 in that table then as they can use the same board in fact the page what details the WIZ820i shows a 3.2 board in the images.

I do like the kickstarted board but it would need to allow me to act as a server before I can use it and as mentioned above I don't need the POE.

However having said this is there any reason why I can't just connect the WIZ board direct to the 3.5/6 and do away with the Adaptor board? the only part is the CAT811T which I understand is for the reset at startup but I can control that from a standard I/O pin I am thinking.

Cliff.
 
Because the 3.2 boards don't have the Ethernet MAC integrated. They rely on an external chip implementing it. The 3.5/6 only need the analog stuff like the magnetics and the PHY, which you will always need separately (but not necessarily discreet).

It could indeed be put somewhat clearer by changing the description to 'Onboard Ethernet MAC' or 'Native Ethernet'.
 
However having said this is there any reason why I can't just connect the WIZ board direct to the 3.5/6 and do away with the Adaptor board?

Sure you can. Just keep the wires a reasonably short length (a few inches is fine) because they are fairly fast SPI.

The CAT811T is really only necessary for the W5200 chip on the older WIZ820io. That chip has terrible behavior if you try to use the SPI pins before the giving the chip a reset pulse. Even with W5200 chip, you can get away without the reset chip if you add code to pulse the pin.

The adaptor board is designed to be easy and convenient for beginners. There are lots of cases where people tried using only the SD card while the Wiznet board was present, or they connected another SPI chip and ran a program meant only to talk to that other chip. People don't intuitively expect the unused WIZ820io to interfere with their other stuff, and indeed it will if not given a proper reset pulse. The CAT811T was added to the 2nd rev so examples for other SPI libraries would "just work" if you had the ethernet module connected but unused. You probably don't care about this, especially if you've read this message and fully understand the reset issue (or if using the newer W5500 chip). But hopefully you can see why having that chip on the adaptor makes for a much better end user experience when hobbyists connect stuff to their Teensy and run already-made examples from hundreds of Arduino libs for other SPI devices.

Regarding the built in ethernet mac on Teensy 3.5 & 3.6, in some glorious but distant future we'll have fully featured and stable software support. But that day is a long way off. Odds are strong we'll have a Teensy 4.0 model (with the same or very similar ethernet mac) before there's usable library support. I know that can feel disappointing, and it's probably only cold comfort to point to the work that's instead gone into USB Host support (and many other little things). But that's the reality of where we are right now.

The Wiznet chips do work pretty well. Of course, they are limited to 4 or 8 connections, they have tiny buffer memory which limits throughput over high latency links (anything not a LAN), and even over locally connected ethernet the speed is capped by the SPI speed & protocol overhead. The plus side is they handle the TCP/IP protocol, which allows for much simpler & smaller code, and of course that code has been around for a long time.

From a hobbyist or even small volume production cost point of view, the ethernet phy needed for the ethernet mac is about the same price as the wiznet module. When we do someday have good software support, it will offer dramatically higher performance. Mantiou benchmarked the hardware able to achieve pretty much the full 100 Mbit/sec wire speed from a PC to Teensy's memory with UDP packets. But for real networking, that performance will also come with a cost in code complexity and memory usage, as well as the phy hardware to go from RMII to the actual ethernet cable.
 
Last edited:
Ok So I have the parts built together and I am trying to get the DHCP to work so that I can get the device to obtain it's own IP address.

I have tried to use the following code.

Code:
//Example of a non blocking ethernet request and MAC address retrieval for Teensy 3.x and Wiznet W5100/5200 based shields
//This sketch sets up the Ethernet interface with the Teensys built in MAC address and requests a DHCP lease from the router.
//While the lease is being obtained you can already do other stuff.
//When a lease has been obtained, the sketch will launch a DNS resolve request (also non-blocking) and make a HTTP GET
//to the resolved IP address.
//See http://www.epyon.be/2016/05/22/non-blocking-ethernet-example-teensy/ for more information

//Make sure you include the NB ethernet library!
//Sketch>Include library>NBethernet
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <macaddress.h>

macAddress myMac; //object retrieves mac address of Teensy 3.x or Teensy LC
char server[] = "www.google.be"; //server we want to connect to
EthernetClient client;

boolean _ethernetInitialized = 0;
boolean _clientInitialized = 0;
boolean _inSession = 0;
boolean _waiting = 0;

elapsedMillis sinceCheckedEthernet;
elapsedMillis delayEthernetStart;
elapsedMillis sinceCheckedCon;

static uint16_t bytes_read; //you can use this to limit the max amount of bytes read

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // Oh Teensy y u so fast
  delay(4000);
  Serial.println("Starting");
  // Print MAC address embedded in the Teensy
  Serial.print("My mac is: ");
  Serial.println(myMac);
  // Start of non-blocking Ethernet. doEthernet in loop() will poll status.
  pinMode(9, OUTPUT);
  digitalWrite(9, LOW);    // begin reset the WIZ820io
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);  // de-select WIZ820io
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);   // de-select the SD Card
  digitalWrite(9, HIGH);   // end reset pulse

  Ethernet.begin(myMac);
}

void loop() {
  doEthernet();
  /*Here you can have other code doing all kinds of stuff without being blocked by the Ethernet library*/
}

void doEthernet() {
  if (delayEthernetStart >= 500) {    // initial power-up start delay to allow router to boot
    if (sinceCheckedEthernet >= 500) { // check every once in a while if we acquired a DHCP lease and if it is still valid
      Serial.println("Checking");
      checkEthernet();
      sinceCheckedEthernet = 0;
    }
  }
  if (_ethernetInitialized == 1 && !_inSession) {             //if Ethernet is initialized and we don't yet have an active connection
    if (_clientInitialized == 0 && sinceCheckedCon >= 5000) { //try to initiate a connection
      Serial.println("Initializing connection");
      if (!client.initConnection(server, 80)) {               //something went wrong, lets try again in 2000ms
        Serial.println("Initializing connection failed");
      }
      else {
        Serial.println("Connection initialized");             //Yay, we have initialized a connection!
        _clientInitialized = 1;
      }
      sinceCheckedCon = 0;
    }
    if (_clientInitialized && client.finishedConnecting()) {  //Continously check if the connection has been established
      if (client.finishedConnecting() == 1) {                 //If so, launch our request to the server
        Serial.println("Connected");
        client.println("GET /search?q=arduino HTTP/1.0");
        client.print("Host: ");
        client.println(server);
        client.println("Connection: close");
        client.println();
        _inSession = 1;                                       //We are now in session untill we have received the data
        _clientInitialized = 0;
        bytes_read = 0;
      }
      else {
        _clientInitialized = 0;
        Serial.println("We don't have a connection (yet)");
      }
    }
  }
  if (_inSession) {
    // we have a connection, and the GET has been sent.
    // lets consume the response
    if (client.available()) {             //You could add && bytes_read < <number> to limit the amount of bytes to be read
      char c = client.read();
      Serial.print(c);
      bytes_read++;
    }
    //If you have added a max number of bytes to be read, uncomment the following code to flush the rest of the received data
    /*else if (client.available()) {
        client.flush();
      }*/
    if (!client.connected()) {
      Serial.println();
      Serial.println("disconnecting.");
      client.stop();
      _inSession = 0;                   //We have succesfully received all data and now close the active session
    }
  }
}

void checkEthernet() {
  if (Ethernet.initialized()) {
    Serial.print("Ethernet is initialized...");
    if ( Ethernet.maintain() == 0) {        //Check if we have acquired a DHCP lease
      if (_ethernetInitialized == 0) {
        Serial.print("My IP is ");
        Serial.println(Ethernet.localIP());
        _ethernetInitialized = 1;
      }
    }
  }
}

But all I get is an IP address of 0.0.0.0 no matter what I try, anyone have any ideas? If I start the Ethernet connection with an assigned IP it works great but this code either stops the Teensy 3.5 from running and I get a solid amber light on the board or I get an IP of 0.0.0.0 and I need a real IP so that I can modify the code for my project.

Thanks

Cliff.
 
Please try first with the Ethernet library that ships with Teensyduino. It is also more optimised. The NBEthernet library doesn't play so well with the W5500 and some routers.
 
Status
Not open for further replies.
Back
Top