Skip to main content

Getting started with Arduino

Arduino board definition​

To program the NULA Ethernet W55RP20, use the RP2040 Arduino core by Earle Philhower:

RP2040 Arduino core

Arduino core for Raspberry Pi RP2040 chips, by Earle Philhower.

ℹ️

New to Arduino? Follow our beginner's guide for installation and uploading your first sketch:

Getting started with Arduino

Step-by-step guide to installing Arduino and uploading your first program.


Installing the board package​

Install the Raspberry Pi RP2040 boards package directly from the Arduino Boards Manager:

  1. Open Arduino IDE
  2. Go to File → Preferences → Additional Boards Manager URLs and add:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
  1. Go to Tools → Board → Boards Manager
  2. In the search bar, type rp2040
  3. Find the entry Raspberry Pi Pico/RP2040/RP2350 by Earle Philhower and click Install

Once installed, select your board from the menu:

Tools → Board → Raspberry Pi RP2040 Boards → Soldered NULA Ethernet W55RP20


Example sketch​

This sketch connects to a "quote of the day" service over TCP and prints the response. Make sure an Ethernet cable is plugged into the RJ45 port before uploading.

#include <W55RP20lwIP.h>

const char* host = "djxmmx.net";
const uint16_t port = 17;

Wiznet55rp20lwIP eth(20 /* chip select */);

void setup() {
Serial.begin(115200);
delay(5000);
Serial.println("Starting Ethernet port");

if (!eth.begin()) {
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring.");
while (1) {
delay(1000);
}
}

while (!eth.connected()) {
Serial.print(".");
delay(500);
}

Serial.println("");
Serial.println("Ethernet connected");
Serial.println("IP address: ");
Serial.println(eth.localIP());
}

void loop() {
static bool wait = false;

Serial.print("connecting to ");
Serial.print(host);
Serial.print(':');
Serial.println(port);

WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
delay(5000);
return;
}

Serial.println("sending data to server");
if (client.connected()) {
client.println("hello from RP2040");
}

unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
delay(60000);
return;
}
}

Serial.println("receiving from remote server");
while (client.available()) {
char ch = static_cast<char>(client.read());
Serial.print(ch);
}

Serial.println();
Serial.println("closing connection");
client.stop();

if (wait) {
delay(300000); // run once every 5 minutes
}
wait = true;
}

Open the Serial Monitor at 115200 baud. The board will print its IP address, connect to the server, and print the response.


Function reference​

Wiznet55rp20lwIP eth()

Creates the Ethernet object. The argument is the GPIO pin connected to the W5500 chip select.

Returns value: None.

Function parameters:

TypeNameDescription
intcsChip select pin number. Use 20 for the NULA Ethernet W55RP20.

eth.begin()

Initializes the W55RP20 Ethernet hardware and waits for a DHCP lease. Must be called before any network operations.

Returns value: bool - true if initialization succeeded, false if the hardware was not detected.

eth.connected()

Checks whether the board has an active Ethernet link and a valid IP address.

Returns value: bool - true if the link is up and DHCP has assigned an IP.

eth.localIP()

Returns the IP address assigned to the board by DHCP.

Returns value: IPAddress - the board's current IP address.

client.connect()

Opens a TCP connection to the specified host and port.

Returns value: bool - true if the connection was established, false otherwise.

Function parameters:

TypeNameDescription
const char*hostHostname or IP address of the remote server.
uint16_tportTCP port number to connect to.

client.connected()

Checks whether the TCP connection to the remote server is still active.

Returns value: bool - true if the connection is open.

client.println()

Sends a string followed by a carriage return and newline over the TCP connection.

Returns value: None.

Function parameters:

TypeNameDescription
StringdataThe string to send.

client.available()

Returns the number of bytes received from the server that are ready to be read.

Returns value: int - number of bytes available.

client.read()

Reads one byte from the receive buffer.

Returns value: int - the next byte, or -1 if no data is available.

client.stop()

Closes the TCP connection and releases the socket.

Returns value: None.