Using the Teensy 3.0 with the Arduino Ethernet shield
Do you have a Teensy 3.0 and want to hook it up to the internet? Don’t really feel like breadboarding your own Ethernet interface? Then why don’t you use one of your Arduino Ethernet shields lying around the place to provide the Teensy with Ethernet capabilities? Here we show how to do just that.
So I ordered and received my Teensy 3.0 the other day. However, since I’m a Internet kinda of guy, a microcontroller is only useful to me when I can connect it to a network. The Teensy store sells some adapters to connect a WIZ812MJ Ethernet Module to your Teensy, but they’re meant for older Teensy 2.0 models. Also, I didn’t have one of those WIZ812MJ modules lying around.
Luckily our labs are stacked with Arduino boards, and we did have some spare Arduino Ethernet Rev3 shields. Both the WIZ812MJ Ethernet Module and the Arduino Ethernet shield use the Wiznet W5100 embedded TCP/IP chip, so it’s perfectely possible to use the Arduino Ethernet shield to bring the wonderous world of the Internet to the Teensy 3.0! As an extra, the Arduino Ethernet shield provides a micro-SD slot which you can also use with the Teensy. Both the Wiznet chip and the SD slot work on the same SPI bus, limiting the amount of wires you have to run between the Teensy and the Ethernet shield.
However, there’s always a catch. You need to be sure you have a Rev. 3 Ethernet shield, which is the current model sold by Arduino and their distributors. An older version of the Ethernet shield might damage or destroy your precious Teensy board. Read on to find out why.
SPI is a medium-speed, four-wire digital interface bus. It actually only uses three wires for the bus itself (two data lines and one clock line), and one extra wire to select the device, connected to the bus, the microcontroller wants to talk to. This is the so called Slave Select wire. In our case, we will need two SS wires, one for the Ethernet chip and one for the micro SD-card.
Arduino name | Teensy name | Teensy pin |
---|---|---|
MISO | DIN | 12 |
MOSI | DOUT | 11 |
SCLK | LED | 13 |
SS | CS | 10-9 |
The SPI bus on the Arduino Ethernet shield is broken out on the ICSP header on the backside of the board. The SS lines are on the regular digital pin headers.
The Teensy 3.0 uses a different naming scheme for the SPI bus.
Now before we go connecting the Arduino Ethernet shield to our Teensy 3.0, a note on why we need the Rev. 3 model of the Ethernet shield. The Teensy 3.0 works with 3.3V levels, while most of the Arduinos use the 5V level. The inputs of the Teensy, or rather the Freescale MK20 microcontroller on the Teensy board, however are NOT 3.3V tolerant. Connecting 5V to them will damage the microcontroller.
The Rev. 3 of the Arduino Ethernet shield features a IOREF pin. This pin is used to sense the voltage level the Arduino operates with and level shift the output of the shield to a compatible voltage. So the Rev. 3 version of the shield can be safely coupled to the Teensy without you having to worry about magic smoke leaving the Teensy microcontroller.
Some remarks about the power supply. The Wiznet W5100 chip works on 3.3V, but it’s quite a power hungry fellow. It consumes up to 150mA, which is around the maximum current the MK20 microcontroller on the Teensy can provide. The Arduino Ethernet shield luckily has a linear regulator converting power from the 5V pin to 3.3V. To avoid damaging the Teensy microcontroller, you should connect the 5V pin of the Arduino Ethernet shield to the Vin pin of the Teensy, provided you use the USB connection to power the Teensy. This way, the Arduino Ethernet shield will use the 5V provided by USB to power the W5100 chip, avoiding putting too much stress on the Teensy microcontroller.
Thanks for your sharing,I appreciate this.keep up the good work.
Are these pins right? I’m looking at the Teensy 3.0 pins and they look like this:
DOUT = 10
DIN = 11
SCK = 12
CS = 8/9/13/14
I’ve added a schematic to illustrate the connections required
Thanks! This unstuck my project. I have one question – the schematic shows the 3.v line going to the pin above the one labeled IORef on the shield, is that right?
You’re absolutely right, the 3V line should go to the IOREF pin. I’ll fix it in the schematic. But it will work regardless, because the IOREF pin on the Arduino Ethernet shield Rev.3 isn’t connected to anything. The Wiznet chip is a 3.3V chip, so the shield uses level shifters anyway.
I don’t get it. You said in your article that you need the v3 version of the Ethernet shield because of the IOREF pin and in this comment you say that it’s not connected to anything?
I addition (since I have a other shield lying around). I can’t blow anything on the Teensy if I power my shield with 3.3V instead of 5V?
I lose the Serial output as soon as I call Ethenet.begin() ? My code continues to run, but Serial.print() statements don’t show up over usb serial?
This looks more like a coding problem to me. Hard to say without seeing your code of course. I suggest you make a thread at the Teensy forum (http://forum.pjrc.com) describing your problem.
[…] I’ve begun work on the perf-board model I’ll be using for some real world testing until I either pay for some Custom PCBs or learn how to etch at home. So far I have the power circuit and all the connections for the SD card and ethernet; thanks to the Arduino Ethernet board I’m using with the Teensy. […]
I have an issue where if the power is cycled it won’t reconnect to the network. Any thoughts?