hello sara,
I have two small questions about your great project "ESP32-Cam Pan Tilt" from the eBook:
1) How can I rotate the camera image by 90 in the sketch?
2) How can I calibrate the zero point with the "left-right" movement when switching on?
Many greetings and thanks Ulli
Hi.
Unfortunately, there isn’t any function to rotate the image in the sketch. There are the following functions:
- set_hmirror() –> horizontal mirror
- set_vflip() –> vertical flip
This is explained in this article: https://randomnerdtutorials.com/esp32-cam-ov2640-camera-settings/
So, the best way is to rotate the image is on the web page. The project on page 129 shows an example that rotates the image.
Alternatively, you can add something as follows to the HTML attribute:
<img src="your image" style="transform:rotate(90deg);">
So, in your code, search for the following line:
<img src="" id="photo" >
And replace it with this:
<img src=”” id=”photo” style=”transform:rotate(90deg);”>
As for your second question. You have to move the motors to the position that you set as position zero. Check the rotation of the motors in that position (for example: 20 for servo1 and 30 for servo2). Then, when the program starts running, you need to set the motors to that position (20 and 30). When you move the motors, you’ll need to always add those values to the set position.
I hope this is clear.
Let me know if this helps.
Regards,
Sara
Hello Sara thanks for your fast answer. I replace the line:
<body>
<h1>ESP32-CAM Pan and Tilt</h1>
<img src=”” id=”photo” style=”transform:rotate(90deg);”>
<table>
The rotation worked, but the picture now covers the heading and some buttons. Unfortunately I can't send a screenshot. Greetings Ulli
Hi.
The easiest way to solve that issue is to add a margin before and after the video.
See this code (it is the same but with the margins):
Regards,
Sara
Hello Sara, thank you very much.
The problem of rotation is solved.
What I had already changed was that the function of "up" and "down" was swapped.
And then the problem remains from my second question:
Currently, the angle of rotation for left - right movement is only approx. 100 degrees. But I would like to use the maximum range of around 170 degrees here. How can this be implemented?
Many greetings Ulli
Hi.
Some servo motors can only rotate 90 degrees.
But you can try changing the following lines:
servo1.attach(SERVO_1, 1000, 2000);
servo2.attach(SERVO_2, 1000, 2000);
To
servo1.attach(SERVO_1, 500, 2500);
servo2.attach(SERVO_2, 500, 2500);
And see if that changes.
Regards,
Sara
Hello Sara, I solved this last problems:
servo1.attach(SERVO_1, 650, 2000); // up – down
servo2.attach(SERVO_2, 600, 2400); // left – right
Thanks for help.