Ip cam + arduino web server

Salve a tutti io possiedo un arduino r4 wi-fi e una usb-cam 'convertita' in ipcam grazie ad un programma di nome yawcam : digitando su un browser l'ip(tutto in locale) del pc a cui è collegata la videocamera-usb posso vedere quello che inquadra. Il mio obbiettivo è quello di visualizzare sul web server di arduino r4 un'immagine(volevo iniziare da qualcosa di semplice per poi passare al video streaming in tempo reale) della ''ip-cam'' ma viene mostrata un'icona con + il testo che avevo scritto su alt. Ho provato chiedere anche a varie AI ma niente. Qualcuno saprebbe aiutarmi?

Il codice è il seguente:



#include "WiFiS3.h"

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                 // your network key index number (needed only for WEP)

int led =  12;
int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {
  Serial.begin(9600);      // initialize serial communication
  pinMode(led, OUTPUT);      // set the LED pin mode

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(1000);
  }
  server.begin();                           // start the web server on port 80
  printWifiStatus();                        // you're connected now, so print out the status
}


void loop() {
  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out to the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();




            client.print("<html>");
            client.print("<head>");
            client.print("<style>");
            client.print(".button {");
            client.print("  background-color: #FF0000;");
            //client.print("  border-color: #000000;");
            client.print("  color: black;");
            client.print("  padding: 50px;");
            client.print("  text-align: center;");
            client.print("  text-decoration: none;");
            client.print("  display: inline-block;");
            client.print("  font-size: 16px;");
            client.print("  margin: 4px 60px;");
            client.print("  cursor: pointer;");
            client.print("}");
            client.print(".button5 {border-radius: 50%;}");
            client.print("</style>");
            client.print("</head>");
            client.print("<body>");
            client.print("<a href=\"/H\"><button class=\"button button5\"></button></a>");
            client.print("<img src=' il mio ip ' alt='IP Camera Stream'>"); // avevo visto che si poteva fare così
            client.print("<p style=\"font-size:7vw;\">Click <a href=\"/L\">here</a> turn the LED off<br></p>");
            client.print("</body>");
            client.print("</html>");


            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
            break;
          } else {    // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(13, HIGH);               // GET /H turns the LED on
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(13, LOW);                // GET /L turns the LED off
        }
      }

    }
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}

Casomai esiste un modo piu semplice per fare tutto ciò?
Se alla fine risulta che si può fare quello che voglio come si potrebbe fare la riproduzione video-streaming in tempo reale?

In conformità al punto 13 del REGOLAMENTO , ti rammento che il cross-posting è proibito (anche tra lingue diverse) e ... tu hai già posto la stessa/simile domanda QUI. Non solo, in quella discussione ti stanno già rispondendo ed è veramente poco carino abbandonare una discussione e chi ti stava aiutando, per venire di qua a porre la stessa domanda … :roll_eyes:

Quindi, per rispetto verso chi ha già cominciato ad aiutarti, questa tua discussione duplicata viene chiusa e ti prego di continuare dove avevi cominciato.

Grazie,

Guglielmo

P.S.: I messaggi doppi fanno perdere tempo alle persone che cercano di aiutare. Qualcuno potrebbe spendere parecchio tempo per scrivere una risposta dettagliata su una discussione, senza sapere che qualcun altro ha già fatto lo stesso in un altra identica/simile discussione.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.