├── LICENSE ├── README.md ├── enclosure ├── ArduinoNetworkTester_rev01.step └── ArduinoNetworkTester_rev01.stl ├── images ├── completed_01.jpg ├── completed_02.jpg ├── parts.jpg ├── prototype.jpg └── render.jpg └── src └── ArduinoNetworkTester.ino /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 novamostra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArduinoNetworkTester 2 | Arduino Network Tester, extends the functionality of the well-known Network Cable tester by adding DHCP, DNS and Internet connectivity tests using an Arduino Pro Mini and a W5500 Ethernet Shield. 3 |

4 | 5 |

6 | 7 | ## How it works 8 | When turned on, the Power LED is ON and the Status LED is blinking, until you connect an RJ45 (Ethernet Cable) from an OSI Layer 3 device (e.g. router) to the W5500 ethernet port. After that, the device runs the tests one by one starting with DHCP where it requests an IP address. If it successfully receive one then the DHCP LED lights. Next it tries to resolve the url www.example.com to the appropriate IP, if it is successful then the DNS LED lights up. Finally it makes an HTTP request to the domain www.example.com and parse the result. If the returned HTTP Status Code equals 200 then the Internet Connectivity LED turns on. 9 | 10 | ## Bill of Materials 11 | 1) Double Side Thru-Hole Prototype PCB Board (at least 70*90mm) 12 | 2) Arduino Pro Mini 3.3v 8MHz 13 | 3) W5500 Ethernet Shield 14 | 4) 5 LEDs (SMD 0805) 15 | 5) 5 330 Ohm Resistors (SMD 0805) 16 | 6) Battery Charger (TC4056A) 17 | 7) 3.7V 100mah LIPO battery with XH 2.5mm connector 18 | 8) B2B-XH-A 2 Pins connector 19 | 9) On-Off switch (SS-12F15G) 20 | 10) 2.54 mm Pin headers 21 | 22 | ## Prototype PCB Board Design 23 | Arduino Network Tester consists of two double side thru-hole prototype PCB boards, the top with the LED Indicators and the bottom, with the rest circuit. 24 |

25 | 26 |

27 | Read more at novamostra.com 28 | -------------------------------------------------------------------------------- /enclosure/ArduinoNetworkTester_rev01.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/enclosure/ArduinoNetworkTester_rev01.stl -------------------------------------------------------------------------------- /images/completed_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/images/completed_01.jpg -------------------------------------------------------------------------------- /images/completed_02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/images/completed_02.jpg -------------------------------------------------------------------------------- /images/parts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/images/parts.jpg -------------------------------------------------------------------------------- /images/prototype.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/images/prototype.jpg -------------------------------------------------------------------------------- /images/render.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/novamostra/ArduinoNetworkTester/c96763424079d379d7a0beed55e19d7842e1e395/images/render.jpg -------------------------------------------------------------------------------- /src/ArduinoNetworkTester.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Network Tester 3 | 4 | Checks DHCP, DNS and Internet connectivity. 5 | 6 | Arduino Network Tester, extends the functionality of the well-known 7 | Network Cable tester by adding DHCP, DNS and Internet connectivity tests, 8 | using an Arduino Pro Mini 3.3V 8Mhz with optiboot_atmega328 bootloader 9 | and a W5500 Ethernet Module. For DNS and Internet Availability the domain 10 | example.com is used. 11 | 12 | With simple code changes it could be used to check the configuration of 13 | isolated local networks, using local Web Server/Router page instead of 14 | example.com and/or Static DHCP configuration (uncomment the appropriate 15 | line) in the case of a local network without DHCP Server. 16 | 17 | Additionally the ability to set custom mac address could be used to check 18 | MAC filtering configuration of the network. 19 | 20 | Read more about the implementation at: 21 | https://novamostra.com/2020/07/30/arduino-network-tester/ 22 | 23 | created 30 July 2020 24 | by Novamostra 25 | */ 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define PWR_LED 6 32 | #define DHCP_LED 5 33 | #define DNS_LED 4 34 | #define INT_LED 3 35 | #define STATUS_LED 2 36 | 37 | //Here you can set your own mac address 38 | byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; 39 | 40 | DNSClient dns_client; 41 | EthernetClient eth_client; 42 | 43 | char server_url[] = "www.example.com"; 44 | // www.example.com resolves to 93.184.216.34 45 | // if you change server_url you must also change server_ip 46 | byte server_ip[] = { 93, 184, 216, 34 }; 47 | 48 | //the resolved ip from the DNS query 49 | IPAddress server_ip_resolved; 50 | 51 | boolean dns_resolved = false; 52 | boolean http_responded = false; 53 | 54 | long last_blink = 0; 55 | 56 | void init_leds() { 57 | pinMode(PWR_LED, OUTPUT); 58 | pinMode(DHCP_LED, OUTPUT); 59 | pinMode(DNS_LED, OUTPUT); 60 | pinMode(INT_LED, OUTPUT); 61 | pinMode(STATUS_LED, OUTPUT); 62 | 63 | digitalWrite(PWR_LED, HIGH); 64 | digitalWrite(DHCP_LED, HIGH); 65 | digitalWrite(DNS_LED, HIGH); 66 | digitalWrite(INT_LED, HIGH); 67 | digitalWrite(STATUS_LED, HIGH); 68 | delay(500); 69 | digitalWrite(DHCP_LED, LOW); 70 | digitalWrite(DNS_LED, LOW); 71 | digitalWrite(INT_LED, LOW); 72 | digitalWrite(STATUS_LED, LOW); 73 | } 74 | 75 | void reset_leds() { 76 | digitalWrite(DHCP_LED, LOW); 77 | digitalWrite(DNS_LED, LOW); 78 | digitalWrite(INT_LED, LOW); 79 | digitalWrite(STATUS_LED, LOW); 80 | } 81 | 82 | void flash_led(int led, int blink_delay) { 83 | if (millis() - blink_delay > last_blink) { 84 | if (digitalRead(led) == HIGH) { 85 | digitalWrite(led, LOW); 86 | } else { 87 | digitalWrite(led, HIGH); 88 | } 89 | last_blink = millis(); 90 | } 91 | } 92 | 93 | void setup() { 94 | // Open serial communications and wait for port to open: 95 | init_leds(); 96 | 97 | //while no cable is connected wait 98 | while (Ethernet.linkStatus() != LinkON) { 99 | flash_led(STATUS_LED, 1000); 100 | } 101 | //A cable has been connected, stop flashing Status LED 102 | digitalWrite(STATUS_LED, LOW); 103 | // Obtain an IP using DHCP 104 | if (Ethernet.begin(mac) == 0) { 105 | // Static Configuration: comment the previous line, 106 | // uncomment the following line and set appropriate values: 107 | // if (Ethernet.begin(mac, ip, dns, gateway, subnet)==0) { 108 | while (true) { 109 | //Failed to configure Ethernet using DHCP 110 | flash_led(DHCP_LED, 1000); 111 | digitalWrite(STATUS_LED, HIGH); 112 | } 113 | } else { 114 | //DHCP Configuration completed 115 | digitalWrite(DHCP_LED, HIGH); 116 | // give the Ethernet shield a second to initialize: 117 | delay(1000); 118 | 119 | //Check DNS 120 | dns_client.begin(Ethernet.dnsServerIP()); 121 | if (dns_client.getHostByName(server_url, server_ip_resolved) == 1 && server_ip_resolved == server_ip) { 122 | //DNS is working 123 | digitalWrite(DNS_LED, HIGH); 124 | dns_resolved = true; 125 | } else { 126 | //DNS failed 127 | } 128 | 129 | //Check Internet Connectivity 130 | if (eth_client.connect(server_url, 80)) { 131 | http_responded = false; 132 | eth_client.println("GET http://" + String(server_url) + " HTTP/1.1"); 133 | eth_client.println("Host: " + String(server_url)); 134 | eth_client.println("Connection: close"); 135 | eth_client.println(); // end HTTP request header 136 | } else { 137 | //Unable to establish an http connection 138 | digitalWrite(STATUS_LED, HIGH); 139 | } 140 | } 141 | } 142 | 143 | void reset_WDT() { 144 | wdt_enable(WDTO_15MS); 145 | while (1) {}; 146 | } 147 | 148 | void loop() { 149 | //If cable unplugged reset 150 | if (Ethernet.linkStatus() != LinkON) { 151 | reset_WDT(); 152 | } 153 | 154 | // Handle HTTP Client response 155 | String response = ""; 156 | while (eth_client.available() && !http_responded) { 157 | char c = eth_client.read(); 158 | response = response + c; 159 | //Find the first carriage return, this line returns the status code of the HTTP server 160 | if (c == '\r') { 161 | http_responded = true; 162 | eth_client.stop(); 163 | //if page loaded then internet connectivity exists 164 | if (response.indexOf("200") > 0) { 165 | digitalWrite(INT_LED, HIGH); 166 | digitalWrite(STATUS_LED, HIGH); 167 | } else { 168 | //Failed to load the page, Internet connectivity does not exist 169 | digitalWrite(STATUS_LED, HIGH); 170 | } 171 | break; 172 | } 173 | } 174 | } 175 | --------------------------------------------------------------------------------