• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32-Cam Pan Tilt

Q&A Forum › Category: Questions › ESP32-Cam Pan Tilt
0 Vote Up Vote Down
uengel asked 4 years ago
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
Question Tags: hello sara
8 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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 
 

0 Vote Up Vote Down
uengel answered 4 years ago

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
0 Vote Up Vote Down
uengel answered 4 years ago
In the photo shown in the eBook tutorial, the camera image is also tilted.
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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): 

  • https://gist.github.com/sarasantos/f1b084e113fbbe19e4d9daf18b6f5ac9

Regards,
Sara
 

0 Vote Up Vote Down
uengel answered 4 years ago
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
 
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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
 
 

0 Vote Up Vote Down
uengel answered 4 years ago

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.

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Great!
I’m glad you solved the issue.
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.