I'm trying to stream my m5 x timer camera to record live video stream when it is unplugged from the computer so it relies on its battery but it doesn't seen to be working, any suggestions?
void setup() {
Serial.begin(115200);
TimerCAM.begin();
// Initialize the battery management system
TimerCAM.Power.begin();
if (!TimerCAM.Camera.begin()) {
Serial.println("Camera Init Fail");
while (true); // Halt if camera initialization fails
}
Serial.println("Camera Init Success");
TimerCAM.Camera.sensor->set_pixformat(TimerCAM.Camera.sensor, PIXFORMAT_JPEG);
TimerCAM.Camera.sensor->set_framesize(TimerCAM.Camera.sensor, FRAMESIZE_QVGA); // Lower resolution for power saving
TimerCAM.Camera.sensor->set_vflip(TimerCAM.Camera.sensor, 1);
TimerCAM.Camera.sensor->set_hmirror(TimerCAM.Camera.sensor, 0);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
WiFi.setSleep(false); // Ensure WiFi does not go to sleep
Serial.println("");
Serial.print("Connecting to ");
Serial.println(ssid);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop() {
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a client connects
while (client.connected()) { // Loop while the client is connected
if (client.available()) { // If there are bytes to read from the client
jpegStream(&client);
}
}
// Close the connection
client.stop();
Serial.println("Client Disconnected.");
}
// Added delay to prevent the loop from running too fast and potentially causing issues
delay(10);
I'm trying to stream my m5 x timer camera to record live video stream when it is unplugged from the computer so it relies on its battery but it doesn't seen to be working, any suggestions?
include "M5TimerCAM.h"
include
// WiFi credentials const char ssid = const char password =
WiFiServer server(80); static void jpegStream(WiFiClient* client);
void setup() { Serial.begin(115200); TimerCAM.begin(); // Initialize the battery management system TimerCAM.Power.begin();
}
void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a client connects while (client.connected()) { // Loop while the client is connected if (client.available()) { // If there are bytes to read from the client jpegStream(&client); } } // Close the connection client.stop(); Serial.println("Client Disconnected."); }
}
// Used for image streaming
define PART_BOUNDARY "123456789000000000000987654321"
static const char _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY; static const char _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n"; static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
static void jpegStream(WiFiClient client) { Serial.println("Image stream start"); client->println("HTTP/1.1 200 OK"); client->printf("Content-Type: %s\r\n", _STREAM_CONTENT_TYPE); client->println("Content-Disposition: inline; filename=capture.jpg"); client->println("Access-Control-Allow-Origin: "); client->println();
client_exit: TimerCAM.Camera.free(); TimerCAM.Power.setLed(0); client->stop(); Serial.printf("Image stream end\r\n"); }