|
8 | 8 | // canvas-gauges (https://github.com/Mikhus/canvas-gauges). |
9 | 9 | // |
10 | 10 | // The web server serves a simple HTML page with CSS and embedded JavaScript stored in the ESP |
11 | | -// SPIFFS file system to fetch the sensor readings. The readings are updated automatically on |
| 11 | +// SPIFFS file system to fetch the sensor readings. The readings are updated automatically on |
12 | 12 | // the web page using Server-Sent Events (SSE). |
13 | 13 | // See "ESP32 Web Server: Display Sensor Readings in Gauges" by Rui Santos |
14 | 14 | // on Random Nerd Tutorials (https://randomnerdtutorials.com/esp32-web-server-gauges/) for details. |
15 | 15 | // |
| 16 | +// Notes: |
| 17 | +// - Set your WiFi credentials in "secrets.h" |
| 18 | +// - Enable WiFi Access Point mode by uncommenting WIFI_AP_MODE if desired |
| 19 | +// - Open http://weatherdashboard.local in your web browser (or the IP address shown in the |
| 20 | +// serial monitor) to access the web page |
| 21 | +// - Press the on-board button during power-up to reset rain gauge data |
| 22 | +// |
16 | 23 | // https://github.com/matthias-bs/BresserWeatherSensorReceiver |
17 | 24 | // |
18 | 25 | // Based on: |
19 | 26 | // Rui Santos & Sara Santos - Random Nerd Tutorials |
20 | 27 | // Complete instructions at https://RandomNerdTutorials.com/esp32-web-server-gauges/ |
21 | 28 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
22 | | -// and associated documentation files. |
23 | | -// The above copyright notice and this permission notice shall be included in all copies or |
| 29 | +// and associated documentation files. |
| 30 | +// The above copyright notice and this permission notice shall be included in all copies or |
24 | 31 | // substantial portions of the Software. |
25 | 32 | // |
26 | 33 | // |
|
61 | 68 |
|
62 | 69 | #include <Arduino.h> |
63 | 70 | #include <WiFi.h> |
| 71 | +#include <ESPmDNS.h> |
64 | 72 | #include <AsyncTCP.h> // https://github.com/ESP32Async/AsyncTCP |
65 | 73 | #include <ESPAsyncWebServer.h> // https://github.com/ESP32Async/ESPAsyncWebServer |
66 | 74 | #include <time.h> |
|
80 | 88 | // Stop reception when data of all (max_sensors) is complete |
81 | 89 | #define RX_FLAGS (DATA_COMPLETE | DATA_ALL_SLOTS) |
82 | 90 |
|
83 | | -#define WIFI_AP_MODE // Uncomment to enable WiFi Access Point mode |
| 91 | +// #define WIFI_AP_MODE // Uncomment to enable WiFi Access Point mode |
84 | 92 |
|
85 | 93 | // Replace network credentials in secrets.h |
86 | 94 |
|
@@ -204,6 +212,10 @@ void initWiFi() |
204 | 212 | } |
205 | 213 | Serial.println(); |
206 | 214 | log_i("Local IP: %s", WiFi.localIP().toString().c_str()); |
| 215 | + if (!MDNS.begin(hostname)) |
| 216 | + { |
| 217 | + log_e("Error setting up MDNS responder!"); |
| 218 | + } |
207 | 219 | #endif |
208 | 220 | } |
209 | 221 |
|
|
0 commit comments