Teensy 3.6 with Ethernet

Status
Not open for further replies.

SimonWakley

Active member
I'm planning on making a board to break out the pins from the Teensy 3.6 for various hardware projects I have pending. I would like to add Ethernet to that board and there seem to be 3 routes to take. I can use the WIZ820io board, I could use a Wiznet WIZ812MJ or maybe take the components from the OSH Park Ethernet PHY for Teensy 3.5 & 3.6 and use that.

I do have some experience with the Wiz812 series, but I do only need SPI so the 820io module seems to be more compact and I assume is basically the same as using the 812 in SPI mode.

I don't want to have to do a lot of development on this side of things, so I would be interested in which has the most stable code and operation.

If there is logic already built into the Teensy 3.6, using that would seem most efficient and elegant, but as I said, I don't want to have to spend a lot of time getting it working, I would rather use something that is more fully tested and has existing libraries etc.

Thanks
 
as far as i know, there is logic built in the teensy 3.6's mcu. but i wonder if those pins are all broken out.
 
Easiest route is probably the WIZ820io. It's smaller and much faster than the WIZ812 and directly supports by the Ethernet library that comes with Teensyduino.
 
Thanks to everyone for their rapid responses. I am getting the Wiz I0 board and will bread board it out. Great to get such fast and learned answers.
 
So I have the Breadboard, the Wiz I/O and I have modified, uploaded and run Blink on the Teensy 3.6. Is there a guide for a newbie on how to configure this. I did look at the Ethernet sketches, but I don't see how to tell what pins or even which SPI the SPI is using. I also want to have an external Serial Port for debugging. Is there a beginner's guide to this. The pins have multiple uses and I need to work out how to assign the right pins to the right function, since Tx1 is in 3 different places :) If someone could point to the correct documentation, I would be grateful! Thanks
 
Hi,
So I did find the documentation and it was not exactly hidden :) More like in plain sight. So now I would like to know more about the Chip Select line and the Reset line. In the docs, it uses 9 for the Reset and 10 for the Chip Select. These are also Tx2 and RX2. I would like to use them for one of several serial ports, so is there a way to use a different line for Chip Select. Reset - I can just just wire it high and the device seems to work. Should I have that connected I was toggling it in setup() but is it used explicitly in the ethernet library, I could not see it there? Can I assign the Chip Select line to pin 15 as that is also listed as CS0. but there appears to be no alt for Tx2 and Rx2.
I did try defining PIN_SPI_SS as 15 but that did not seem to take. (#define SS_PIN_DEFAULT 10)
Thanks

Code I have currently working is here:
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888; // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; // buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

#define Debug Serial3 // Using Tx3 and Rx3 for debug via a FTDI 3.3v TTL serial cable

#define LED 13 // Also being used for CLOCK
#define WIZNET_RESET 6

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

pinMode(LED, OUTPUT);


// This is to disable the Wiz until ready togo
pinMode(WIZNET_RESET, OUTPUT);
digitalWrite(WIZNET_RESET, LOW);
digitalWrite(WIZNET_RESET, HIGH);

// Wiznet Chip Select Line
pinMode(10, OUTPUT);

Debug.println("Set Up Wiz");
// start the Ethernet and UDP:
Ethernet.begin(mac, ip);
Udp.begin(localPort);

Debug.println("Wiz Set Up Done");

}

int counter = 0;

void loop()
{

// if there's data available, read a packet
int packetSize = Udp.parsePacket();

if (counter)
digitalWrite(LED, HIGH);
else
digitalWrite(LED, LOW);

if (packetSize)
{
Debug.print("Received packet of size ");
Debug.println(packetSize);
Debug.print("From ");
IPAddress remote = Udp.remoteIP();

for (int i=0; i < 4; i++) {
Debug.print(remote, DEC);
if (i < 3) {
Debug.print(".");
}
}

Debug.print(", port ");
Debug.println(Udp.remotePort());

Debug.print(", port ");
Debug.println(Udp.remotePort());

// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
Debug.println("Contents:");
Debug.println(packetBuffer);

// send a reply to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
counter = 0;
}

delay(10);

counter++;

// Just so we know it it still alive, but just not getting anything
if (counter > 100)
{
Debug.println("Deaf");
counter = 0;
}
}
 
Ok, this part isn't documented. At least not yet, but it really should be. It's also new, so make sure you've got the latest Teensyduino 1.34.

With the latest version, you can use Ethernet.init(pin) **before** Ethernet.begin(...)

All older versions are hard-coded to pin 10, so this only works with the latest version. If you get a compile error than init() isn't defined, then you must install a newer version.
 
Status
Not open for further replies.
Back
Top