This is a simple Arduino sketch that sets up a web server on an ESP8266 module with WiFi connectivity. When a user accesses the IP address of the module from their web browser, they will see the current time and have the ability to beep a connected speaker.
- ESP8266 module
- Speaker or buzzer
- WiFi network
- Computer or device with a web browser
- Connect the IO pin of the speaker to the D5 pin on the ESP8266 module.
- Connect the GND pin of the speaker to the GND pin on the ESP8266 module.
- Connect the VCC pin of the speaker to the 3.3v pin on the board.
- Copy the code into the Arduino IDE
- Change the
ssid
andpassword
variables to match your WiFi network credentials - Upload the code to the ESP8266 module
- Open the Serial Monitor to verify that the module has connected to the WiFi network
- Open a web browser and enter the IP address of the module
- You should see the current time displayed in your web browser and have the ability to beep the speaker
If you plan to use this code for your own projects and want to access the Arduino web server from outside your local network, you can use a free dynamic DNS service like duckdns.org. Users with routers that have a dynamic IP address can add their IP address and IPv6 address, add a domain and have an easier access to their hosted website.
This code was adapted from the ESP8266WebServer example included with the ESP8266WiFi library.