Skip to content

Arduino Nano web server with w5500

Arduino Nano web server with w5500

Components

Hardware components

x 1


WIZnet parts

Project description

Arduino Nano web server with w5500
  1. ?https://docs.arduino.cc/tutorials/ethernet-shield-rev2/WebServer
  2. ? Web Server
  3. ARDUINO NANO
  4. A5 SCL Yellow
  5. A4 SDA Green
  6. D10 CS SPI
  7. D11 MOSI SPI
  8. D12 MISO SPI
  9. D13 SCK SPI
  10. ARCELI W5500 SPI
  11. LAN Ethernet Module reseau TCP IP STM32 Interface 3.3V 5V
  12. https://www.amazon.fr/gp/product/B09DYFLMJG/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
  13. GND ? ? ? ? ? ? ? ? ? ? ? ? ? GND
  14. GND ? ? ? ? ? ? ? ? ? ? ? ? ? VCC --> +3V3 arduino nano
  15. MOSI --> D11 arduino nano ? ? VCC --> +3V3 arduino nano
  16. SCK --> ?D13 arduino nano ? ? NC
  17. CS ?--> ?D10 arduino nano ? ? RST
  18. INT ? ? ? ? ? ? ? ? ? ? ? ? ? MISO --> D12 arduino nano
  19. ?*/
  20. #include <SPI.h>
  21. #include <Ethernet.h>
  22. byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE}; //MAC Address
  23. IPAddress ip(192, 168, 6,69);//IP address
  24. EthernetServer server(80);//PORT 80 http
  25. // Initialize the Ethernet server library
  26. void setup() {
  27. ? Ethernet.init(10); ?// CS D10(Arduino Nano) -->CS W5500
  28. ? Serial.begin(9600); //Serial Debug
  29. ? while (!Serial) { } //Wait USB Serial ttyUSB
  30. ? Serial.println("Ethernet WebServer");
  31. ? Ethernet.begin(mac, ip); //Start Server web
  32. ? // Check for Ethernet hardware present
  33. ? if (Ethernet.hardwareStatus() == EthernetNoHardware) {
  34. ? ? Serial.println("Ethernet ARCELI W5500 ?not found.");
  35. ? ? while (true) {
  36. ? ? ? delay(1); // Bucle No hardware Error
  37. ? ? }
  38. ? }else { Serial.println("Ethernet Hardware W5500 OK ");};
  39. ? if (Ethernet.linkStatus() == LinkOFF) {
  40. ? ? Serial.println("Ethernet cable is not connected.");
  41. ? }
  42. ? // start the server
  43. ? server.begin();
  44. ? Serial.print("server IP ");
  45. ? Serial.println(Ethernet.localIP());
  46. }
  47. void loop() {
  48. ? // listen for incoming clients
  49. ? EthernetClient client = server.available();
  50. ? if (client) {
  51. ? ? Serial.println("new client");
  52. ? ? // an http request ends with a blank line
  53. ? ? boolean currentLineIsBlank = true;
  54. ? ? while (client.connected()) {
  55. ? ? ? if (client.available()) {
  56. ? ? ? ? char c = client.read();
  57. ? ? ? ? Serial.write(c);
  58. ? ? ? ? // if you've gotten to the end of the line (received a newline
  59. ? ? ? ? // character) and the line is blank, the http request has ended,
  60. ? ? ? ? // so you can send a reply
  61. ? ? ? ? if (c == 'n' && currentLineIsBlank) {
  62. ? ? ? ? ? // send a standard http response header
  63. ? ? ? ? ? client.println("HTTP/1.1 200 OK");
  64. ? ? ? ? ? client.println("Content-Type: text/html");
  65. ? ? ? ? ? client.println("Connection: close"); ?// the connection will be closed after completion of the response
  66. ? ? ? ? ? client.println("Refresh: 5"); ?// refresh the page ?every 5 sec
  67. ? ? ? ? ? client.println();
  68. ? ? ? ? ? client.println("<!DOCTYPE HTML>");
  69. ? ? ? ? ? client.println("<html>");
  70. ? ? ? ? ?client.print("ICARO SERVER on ARDUINO NANO WITH w5500 ");
  71. ? ? ? ? ?client.println("<br />");
  72. ? ? ? ? ?client.println("</html>");
  73. ? ? ? ? ?break;
  74. ? ? ? ? }
  75. ? ? ? ? if (c == 'n') {
  76. ? ? ? ? ? // you're starting a new line
  77. ? ? ? ? ? currentLineIsBlank = true;
  78. ? ? ? ? } else if (c != 'r') {
  79. ? ? ? ? ? // you've gotten a character on the current line
  80. ? ? ? ? ? currentLineIsBlank = false;
  81. ? ? ? ? }
  82. ? ? ? }
  83. ? ? }
  84. ? ? // give the web browser time to receive the data
  85. ? ? delay(1);
  86. ? ? // close the connection:
  87. ? ? client.stop();
  88. ? ? Serial.println("client disconnected");
  89. ? }
  90. }
RAW Paste Data

Comments

Similar projects you might like

Comments