taylor(taejin an)
Published

W5100S-EVB-Pico with the Node-RED

The W5100S-EVB-Pico has the same role as the Raspberry Pi Pico platform and includes W5100S, so the Ethernet function is basically included.

BeginnerProtip908
W5100S-EVB-Pico with the Node-RED

Things used in this project

Hardware components

W5100S-EVB-Pico
WIZnet W5100S-EVB-Pico
×1

Software apps and online services

Arduino IDE
Arduino IDE
Node-RED
Node-RED

Story

Read more

Code

W5100S-EVB-CoreTemp.ino

C/C++
Modify IPAddress(#11) and port(#98) to yours.
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

// Enter the IP address of the server you're connecting to:
IPAddress server(192, 168, 0, 69);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 23 is default for telnet;
// if you're using Processing's ChatServer, use port 10002):
EthernetClient client;

bool led_status = false;
int led_delay = 0;
int get_delay = 0;
#define LED_ON HIGH
#define LED_OFF LOW
#define LED_DELAY 100000
#define GET_DELAY 200000

void blink() {
  if(led_delay > LED_DELAY) {
    if(led_status) {
      led_status = false;
      digitalWrite(LED_BUILTIN, LED_OFF);    // turn the LED off by making the voltage LOW
    }
    else {
      led_status = true;
      digitalWrite(LED_BUILTIN, LED_ON);   // turn the LED on (HIGH is the voltage level)
    }
    led_delay = 0;
  }
  else {
    led_delay ++;
  }
}

void get_core_temperature() {
  if(get_delay > GET_DELAY) {
    float core_temp = analogReadTemp();
    Serial.printf("Core temperature: %2.1fC\n", core_temp);
    
    if (client.connected()) {
      String core_temp_str = String(core_temp, 2);
      client.print(core_temp_str);
    }
    
    get_delay = 0;
  }
  else {
    get_delay ++;
  }
}
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet
  Ethernet.init(17);  // WIZnet W5100S-EVB-Pico

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
    blink();
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());

  if (client.connect(server, 9456)) {
    Serial.println("connected");
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
  blink();
  get_core_temperature();
}

W5100S-EVB-CoreTemp.json

JSON
[
    {
        "id": "e7cae84a2c3f73bf",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "4f48e7ad3b019333",
        "type": "tcp in",
        "z": "e7cae84a2c3f73bf",
        "name": "",
        "server": "server",
        "host": "",
        "port": "9456",
        "datamode": "stream",
        "datatype": "buffer",
        "newline": "",
        "topic": "",
        "base64": false,
        "x": 170,
        "y": 180,
        "wires": [
            [
                "ba6345527c734a24",
                "aa999e85b6c7e72c",
                "c41ea4ede2e5e5d7"
            ]
        ]
    },
    {
        "id": "ba6345527c734a24",
        "type": "ui_gauge",
        "z": "e7cae84a2c3f73bf",
        "name": "",
        "group": "2b2c73d8e1e0b8a2",
        "order": 0,
        "width": "6",
        "height": "6",
        "gtype": "gage",
        "title": "gauge",
        "label": "units",
        "format": "{{value}}",
        "min": "-20",
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 360,
        "y": 200,
        "wires": []
    },
    {
        "id": "aa999e85b6c7e72c",
        "type": "ui_chart",
        "z": "e7cae84a2c3f73bf",
        "name": "",
        "group": "2b2c73d8e1e0b8a2",
        "order": 1,
        "width": "6",
        "height": "6",
        "label": "chart",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 360,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "c41ea4ede2e5e5d7",
        "type": "debug",
        "z": "e7cae84a2c3f73bf",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 390,
        "y": 140,
        "wires": []
    },
    {
        "id": "2b2c73d8e1e0b8a2",
        "type": "ui_group",
        "name": "",
        "tab": "4e3ec7bc780f9d95",
        "order": 1,
        "disp": true,
        "width": "24",
        "collapse": false,
        "className": ""
    },
    {
        "id": "4e3ec7bc780f9d95",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

WIZnet-ArduinoEthernet

Ethernet Library for Arduino WIZnet modified Please use a branch W5100S-EVB-Pico.

arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 boards

Credits

taylor(taejin an)

taylor(taejin an)

8 projects • 8 followers

Comments