File tree 1 file changed +22
-2
lines changed
libraries/ESP32/examples/Camera/CameraWebServer
1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 39
39
const char *ssid = " **********" ;
40
40
const char *password = " **********" ;
41
41
42
+ bool tryingToConnectWifi = true ;
43
+
42
44
void startCameraServer ();
43
45
void setupLedFlash (int pin);
44
46
@@ -151,6 +153,24 @@ void setup() {
151
153
}
152
154
153
155
void loop () {
154
- // Do nothing. Everything is done in another task by the web server
155
- delay (10000 );
156
+ if (WiFi.status () != WL_CONNECTED) {
157
+ if (!tryingToConnectWifi) {
158
+ WiFi.begin (ssid, password);
159
+ WiFi.setSleep (false );
160
+ tryingToConnectWifi = true ;
161
+ }
162
+
163
+ Serial.println (" Wifi not connected, trying to re-connect" );
164
+ delay (500 );
165
+ } else if (WiFi.status () == WL_CONNECTED) {
166
+ if (tryingToConnectWifi) {
167
+ startCameraServer ();
168
+ Serial.print (" Camera Ready! Use 'http://" );
169
+ Serial.print (WiFi.localIP ());
170
+ Serial.println (" ' to connect" );
171
+ tryingToConnectWifi = false ;
172
+ }
173
+ }
174
+
175
+ delay (2000 );
156
176
}
You can’t perform that action at this time.
0 commit comments