set static IP by default
This commit is contained in:
parent
631176d9e7
commit
a7adc11b22
@ -7,7 +7,7 @@ A basic program for getting pictures from the ESP32-CAM over the network.
|
|||||||
(Assumes basic knowledge of working with ESP32-CAM boards.)
|
(Assumes basic knowledge of working with ESP32-CAM boards.)
|
||||||
|
|
||||||
- Add your SSID/password to `src/main.cpp`.
|
- Add your SSID/password to `src/main.cpp`.
|
||||||
- (Optional) [Set a static IP address](https://randomnerdtutorials.com/esp8266-nodemcu-static-fixed-ip-address-arduino/).
|
- (Optional) Set a static IP address below your SSID/password in `src/main.cpp`.
|
||||||
- Flash to the ESP32-CAM with PlatformIO.
|
- Flash to the ESP32-CAM with PlatformIO.
|
||||||
- Get the IP address from the serial output if you did not set a static IP.
|
- Get the IP address from the serial output if you did not set a static IP.
|
||||||
- Run `curl -o test.jpg <IP Address>` to take and save a picture to your local machine.
|
- Run `curl -o test.jpg <IP Address>` to take and save a picture to your local machine.
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -26,6 +26,12 @@
|
|||||||
const char* ssid = "...";
|
const char* ssid = "...";
|
||||||
const char* password = "...";
|
const char* password = "...";
|
||||||
|
|
||||||
|
// (Optional) Replace with desired static IP config
|
||||||
|
IPAddress localIp(192, 168, 0, 190);
|
||||||
|
IPAddress gateway(192, 168, 0, 1);
|
||||||
|
IPAddress dns(192, 168, 0, 1);
|
||||||
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
|
|
||||||
// Create AsyncWebServer object on port 80
|
// Create AsyncWebServer object on port 80
|
||||||
WebServer server(80);
|
WebServer server(80);
|
||||||
|
|
||||||
@ -40,7 +46,11 @@ const int brightness = 255; // set the led PWM ( 0 - 255 )
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Connect to Wi-Fi
|
// Connect to WiFi
|
||||||
|
if (!WiFi.config(localIp, gateway, subnet, dns)) { // Remove this if you want a DHCP-assigned IP address instead
|
||||||
|
Serial.println("WiFi Failed to configure");
|
||||||
|
}
|
||||||
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user