• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Pomoc w poprawie kodu
#1
Siemka w końcu udało mi się dogrzebać do kodu dzięki któremu mogę przesyłać obraz do aplikacji w telefonie jednak stanąłem na włączeniu LED'a podczas przesyłania obrazu oto kod, proszę o pomoc

#include <WiFiClient.h>

#include <WebServer.h>
#include <WiFi.h>
#include <esp32cam.h>

const char *ssid = "***";
const char *password = "***";

WebServer server(1030);

static auto loRes = esp32cam::Resolution::find(320, 240);

unsigned long aktualnyCzas = 0;
unsigned long zapamietanyCzasCam = 0;

void MainPage() {

String Page = "";

Page += "<html>";
Page += "<head>";
Page += "</head>";
Page += "<body>";
Page += "Witaj na mojej stronie<br><br>";
Page += "</body>";
Page += "</html>";

server.send(200, "text/html", Page);
}

void handleNotFound() {

String message = "Nie znaleziono strony !";
server.send(404, "text/plain", message);
}

void camera() {

WiFiClient client = server.client();

auto startTime = millis();
int res = esp32cam::Camera.streamMjpeg(client);
auto duration = millis() - startTime;

server.send(200, "text/html", "Kamerka działa !");
}

void flash_on() {
digitalWrite(FLASH, HIGH);
server.send(200, "text/html", "Lampa wlaczona !");
}

void flash_off() {
digitalWrite(FLASH, LOW);
server.send(200, "text/html", "Lampa wylaczona !");
}

void setup() {

pinMode(FLASH, OUTPUT);
Serial.begin(115200);

{
using namespace esp32cam;
Config cfg;
cfg.setPins(pins::AiThinker);
cfg.setResolution(loRes);
cfg.setBufferCount(5);
cfg.setJpeg(80);

bool ok = Camera.begin(cfg);
}

WiFi.persistent(false);
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);
Serial.println("");

while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.print("Polaczylem sie z: ");
Serial.println(ssid);
Serial.print("Uzyj adresu: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");

server.on("/", MainPage);
server.on("/camera", camera);
server.on("/flash_on", flash_on);
server.on("/flash_off", flash_off);

server.onNotFound(handleNotFound);

server.begin();

Serial.println("Start serwera");
}

void loop() {

server.handleClient();
}
 
Odpowiedź
#2
Problem rozwiązany działa jak tralala Smile
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości