skip navigational linksPJRC
Shopping Cart Download Website
Home Products Teensy Blog Forum
You are here: Teensy Teensyduino Libraries Ethernet

PJRC Store
Teensy 4.1, $28.60
Teensy 4.0, $22.80
Teensy LC, $11.65
Main Page
Getting Started
How-To Tips
Code Library

Ethernet Library

The Ethernet library lets you connect to the Internet or a local network. You can create applications like web servers, or access web pages, send email or a variety of other internet functions.

Download: Included with the Teensyduino Installer
Latest Developments on Github

Ethernet works with Teensy, and Teensy's "print" function includes block write optimizations that allow more efficient data transmission than standard Arduino.

Ethernet from Teensyduino supports W5100, W5200 and W5500 chips. The chip type is automatically detected.

Hardware Requirements

The simplest way to use Ethernet with Teensy 2.0 is the WIZ812 Adaptor Kit and WIZ812 Ethernet Module (made by Wiznet and sold by Saelig and other companies). For Teensy LC, 3.0 - 3.6, this WIZ820+SD Adaptor and the WIZ820io Module are recommended,

W5x00 must have chip select signal connected to Teensy pin 10.

Basic Usage


Configure which pin is used for the CS signal. Must be called before Ethernet.begin().

Ethernet.begin(mac, ip, gateway, subnet);

Initialize the Ethernet library and hardware. "mac" and "ip" are required. "gateway" and "subnet" are optional.

Allowing Other Computers to Connect (Acting as a Server)

Server myserver = Server(port)

Create a server that will listen for incoming connections on a specific port number.


Begin listening for incoming connections.

Client myclient = myserver.available();

Wait until somebody connects to the server port, then return a Client object that can be used for communicating.

Connecting to Other Computers (Acting as a Client)

Client myclient = Client(ip, port)

Create a client object that will connect to another computer at a specific IP number and port number.


Make the connection. Returns true if the other computer accepted the connection.

Communicating While Connected


Send data.


Check if any data has been received and is available to read.

Read one byte received. -1 is return if no data received.


Check if the other computer is still connected. Disconnecton is reported only after all data has been read.


Disconnect from the other computer.

Example Program

The Ethernet Library comes with examples, like this simple web server which can be accessed from any browser.

This example code can be loaded from the File > Examples > Ethernet > WebServer menu.

You must edit the IP number to a number which is appropriate for your local Ethernet network.

Some Ethernet examples will only run with the Arduino Serial Monitor open. To allow these examples to work without the serial monitor, find and delete this code:

   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

WIZ812MJ Module Connections

The WIZ812 Adaptor Kit is the easiest way to use the WIZ812 Ethernet module. But it can also be connected with only 6 wires.
You will need the WIZnet WIZ812MJ Ethernet module, which is available from several distributors at very affordable prices.

WIZ812MJ Ethernet Module

Only 4 signals (MISO, MOSI, SCLK, SS), plus 3.3 volt power and a reset are required to make the WIZ812MJ work with Teensy or Teensy++. The WIZ812MJ has many pins, but nearly all connect to ground or 3.3 volts, or aren't used at all.

Pin FunctionTeensy 1.0Teensy 2.0Teensy++ 1.0Teensy++ 2.0Teensy 3.0

This bottom side view of the WIZ812MJ can make connecting the wires much easier.

Here is the wiring used for the board used to test Ethernet on Teensy. The 4 signals lines are connected to both Teensy 2.0 and Teensy++ 2.0 pins, so either board may be plugged in. Normally you would only connect to the correct 4 pins to avoid losing use of the other 4 in your application.


For more detailed information about the Ethernet library, please refer to the official Ethernet page.