The main interface for the Ethernet uses code from the standard Arduino example WebServer and the SD card code used earlier in the tutorial.
The program implements the very bare bones of an HTML server. The code lists directories then files as an unordered HTML list.
Ensure the project is powered up and connected via an Ethernet cable to your home network. The yellow network activity light should blink now & then on one side of the connection, green on the other. If the lights are not on, check the Ethernet connection.
Open a web browser on a computer on your network and go to address http://192.168.1.177 or to the alternate address you coded in your sketch. If you changed the sketch to use DHCP to get a free address from your router, the address received will be print on the serial monitor.
The program should output the heading Files: then a list of files on the card. You did put a few test files on the card earlier, yes? If not, no worries, power down the project, eject the SD card, put some text-based files on it, reinsert, and power the project up again.
If you click on a file name, the sketch will send the file and the browser will ask you for a location to save the file.
If you click on a directory name, a new web page will appear displaying the files in the subdirectory.
Use the browser back button to go from the text listing screen back to the file list screen.
If there is a request for a file that is not on the SD card, the sketch will return an HTTP 404 error (file not found). Any other error will also return a 404 error.
When the original tutorial for using the Ethernet shield and sketch was written 7+ years ago, serving files via Ethernet was pretty novel (read: wicked). Ethernet shields are not as common now. It is likely due to the proliferation of Wi-Fi boards.
Hopefully this updated tutorial will give you the basics for using a microcontroller to access an SD card (or something else) via Ethernet. The same methods can be used if you wire up a SD card breakout to the your microcontroller pins, just be sure to check for any necessary code changes.
Most newer microcontroller boards have more memory, so a more robust web server capability may considered. Perhaps you can look at this code and consider a new implementation with an Adafruit Express board and CircuitPython. The future awaits our innovation.
If you come up with great designs, please share them in the Adafruit forums and in the Adafruit Discord chat.
Page last edited March 08, 2024
Text editor powered by tinymce.