Build an ESP32CAM R...
 
Notifications
Clear all

Build an ESP32CAM Robot Car

47 Posts
14 Users
8 Likes
10.2 K Views
(@troles)
Member
Joined: 3 years ago
Posts: 14
 

john B,   Thank you....It seems to work (at least it compiles) when I do it with your suggestion from the link in the blue resources box.  Thanks!!!!   Not sure why my copy paste would cause that error, but I think I will just move on to the building of it and worry about the many more future errors I will surely run into.  Thank you, I am so appreciative of the help everyone gives on this forum.


   
ReplyQuote
John_B
(@john_b)
Member
Joined: 3 years ago
Posts: 18
 

@troles, It's too easy to miss a bit when you copy and paste! Or add something by mistake!

I'm currently carefully adapting the code to use a different motor driver, and because I'm converting a cheap RC car (see my previous post with the pictures), that uses one motor for drive, and another  for steering, so there will be much bad language flying about here soon 😀. But it's a good way to learn, as this is the first time I've used an ESP32!


   
ReplyQuote
(@straygrey)
Member
Joined: 3 years ago
Posts: 1
 

I have just implemented this project om a DF Robot Devastator using a L298N motor controller, here in sunny South Africa.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

Fantastic article and video! I am encouraged to get started again. I'm even reviewing the video on buck, boost and other power supplies, just because I need the education. Congratulations! 😀 

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

OK, now for the nitty-gritty. My question is - oh, I have so many questions - but to start:

I've never purchased any 18650 cells before, only the AA, AAA, D, etc.

I went to batterystore and the nice tech said yeah, this would be OK for robot car, with the caveat:

Hello John - the only thing to be aware of is the 32E has a very low discharge rating of 6.4A, meaning the maximum continuous current the battery can hold is only 6.4 amps, relative to most other 18650's this is extremely low so just be sure of the demands of the battery from your device.
 
So, what is the current draw of this project? Is it less than 6 amps?
 
 

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

(Always willing to do the research, I read all the notes on this particular topic).

Then still trying to answer my own question, I tried to reason it out by comparing with other little experiments for Arduino, Pi Zero, etc. I came to the conclusion that these batteries were good enough to at least give them a shot. If not for this project, then for some other.

Next, I'll put something together, then get out my multi-meter and try to remember how to measure current in operation.

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
John_B
(@john_b)
Member
Joined: 3 years ago
Posts: 18
 
Posted by: @jbo
 
So, what is the current draw of this project? Is it less than 6 amps?

It shouldn't be more than a few hundred milliamps, if you're using small motors like the ones Bill used, 130s, or N20 gear motors. I think the Wi-Fi is quite power hungry, but only relative to the small currents drawn by microcontrollers. I'll be using two 14500s, which are the AA sized equivalents of the 18650. I think the Chinese makers can be rather creative with quoting capacities of their batteries, so  you may not get anywhere near the advertised capacity, but I think it should be plenty. I'm just hoping that my smaller ones will last a reasonable time.

Hopefully I'll be able to test this for real soon. I'm waiting for the last component I need to clear customs before I get back to building mine.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

@john_b

 

Thanks for that info. I will proceed as planned, and yes, I do intend to use more or less the same motors as Bill's example. I'm using the little car kit, and following the rest as closely as I can. I know some had already finished a robot within a week of the video coming out, but I'm much more a beginner. 😎 

Also, I take your point on exuberant vendor claims. I watched a test series of 20+ 18650 batteries, and the Chinese ones had the worst actual-to-claimed performance ratio. The Japanese were good, and the Korean ones were good, and more cost effective. I couldn't find LG, so I picked Samsung.

Anyway, waiting for shipping, including customs; yes, I'm there too 🙂  I don't mind; I like ordering small boards, components from Aliexpress, though not batteries. The key thing for me is, if I can actually understand what it is I'm buying, based on the web page, then I buy it. Otherwise, order from Amazon, Adafruit or others.

 

In theory, theory and practice are the same.
In practice, they're different.


   
John_B reacted
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

Hey all,

No questions this time, just general comments. I sourced all the components best I could, so now I wait for shipping and customs. In the meantime, I decided to redo the ESP32-CAM experiment because I needed the reminder. Well that I did: I had rebuilt my machine, a Pi 4, in the meantime, so I needed to reinstall Arduino IDE anyway.

I picked CAMERA_MODEL_AI_THINKER  

as the article suggested, since it is supposed to be the most common. Entered my ssid and WiFi password. Compiled the code. Yes, on a Pi 4 it did take a long time. This is longer than most Arduino sketches. 

I also agree with what Bill said regarding voltages. I programmed it in 3.3 volts, then just tried running the code (sketch is CameraWebServer). It gave a message: Brownout detector was triggered.

So I switched the FTDI jumper to 5 volts, and moved the power connection to 5 volts on the ESP32-CAM board. Now it works. I assume this will be the same for programming and executing the robot sketch as well. With the serial monitor, I found the IP address. Running nmap on my network, that IP reported a MAC along with the label, LG Electronics. Good to know.

A further observation about just running the camera. It worked fitfully, at first. It would grab a frame, or I could press the 'Get Still' button and usually get a still of a frame. The serial monitor was similarly sluggish. I played around with resolution settings, and no luck. Even at tiniest sizes, it wasn't transmitting very much. I restarted a couple of times, and it works much better now. I picked QVGA (320 x 240) as a size that would give me at least 10 frames per second, but still allow reading text if I held it in front of the camera. This may be important in robot navigation.

As to why, I blame it all on WiFi. I intend to install the antenna on the actual bots. Right now, I'm working in the same room as the WiFi router, but I assume we'd all like to drive the things all over the house. So, I have to learn how to desolder, and put on the antenna. Upwards and onwards.

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
(@fisyon)
Member
Joined: 3 years ago
Posts: 1
 

hello,

i made it with some difficulties.

* my board is placed horizontally then i found and change the 'rotating' part of the code, done.

* the led was too dim. i changed the pwm variable to a constant value (255):

 else if (!strcmp(variable, "flash"))
{
ledcWrite(7, 255);
}

 the led is now much more brighter but somewhat flicker. maybe the issue is the power supply (L298n's onboard 5v). anyway i can live with this.

* the last problem is the motors are not moving even a little bit with.

i suspected pwm signal for the motor driver is not high enough. i changed the variable to a constant as i did with the led trick above. i tried 127 and 200 as the value:

 else if (!strcmp(variable, "speed"))
{
if (val > 255) val = 255;
else if (val < 0) val = 0;
speed = val;
ledcWrite(8, 200);
}

but this method is not worked. i had to use L298n without pwm by using onboard jumpers. the robot is working fine with no speed control. of course it is moving a bit jerky and harder to control.

i am not sure if the problem is using different motor driver or browser. i tried on xubuntu/firefox and android/chrome. both are working ok without pwm input/output.

anyone had similar problem?

 

 


   
Burgy22 reacted
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 3 years ago
Posts: 100
 

Howdy,

Regarding the Robot Car with ESP32CAM, I'm still working on this, what with other interruptions, plus the time to order new parts I keep discovering I need. 🙄 

Anyway, my Main Board is in decent shape. I was looking at this photo from the article, trying to understand how to mount the adjustable buck converter onto the Main Board. I found some based on the LM2596 regulator, and identical or very close to what Bill described.

My question: Is it just screwed directly on? Or soldered by the corners? Or are there little short stubby standoffs at the corners?

Thanks for any answers/advice. This has been a great project for me; I think it will be just within my reach.

This post was modified 3 years ago by jBo

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
(@burgy22)
Member
Joined: 2 years ago
Posts: 9
 

Hi, The building is done it all works fine at the moment, just the tweeking to do, a question, how can i change the code in my esp32-cam module (esp32cam-robot.ino) so that the pictures produced rotates 90° backwards (ccw) at the moment the pictures are "lying on it side".


   
ReplyQuote
(@burgy22)
Member
Joined: 2 years ago
Posts: 9
 

@dronebot-workshop Hi, just tryed replacing the 90 with zero and the 270's with 180, did not make a difference?

Actually, you can do this in the stylesheet, in fact, the code already rotates it 270 degrees (ie. 90 degrees left):

 

.rotate90 {
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}

   
ReplyQuote
(@burgy22)
Member
Joined: 2 years ago
Posts: 9
 
Posted by: @dronebot-workshop
Posted by: @arlo

There doesn't seem to be any way to rotate them 90 degrees so you have to pay attention to which way the module is set.

Actually, you can do this in the stylesheet, in fact, the code already rotates it 270 degrees (ie. 90 degrees left):

 

.rotate90 {
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}

If you open the "unminified" version of the app_httpd.css file you'll see this starting on line 678.  This class, rotate90, is called in the code that displays the video stream.  

<div id="stream-container" class="image-container">
<div class="close" id="close-stream">×</div>
<img id="stream" src="" class="rotate90">
</div>

 

You could either modify the class, create a new class or even eliminate it entirely if the camera is already the right way around.

I also ran into this issue when I was building this, I have ESP32CAM boards from a variety of sources and a few of them were "sideways".

Hope that helps.

😎

Bill

Hi, just tryed replacing the 90 with zero and the 270's with 180, after save & upload it did not make a difference?

Burgy22

 


   
ReplyQuote
(@burgy22)
Member
Joined: 2 years ago
Posts: 9
 

Hi,

Wanting to make the following changes to the code to turn off the intern LED and use external LED's switched by the button supplied in the code.
Using external power for the Relay & Led's (5v) directly from the Batteries.
Is it a choice of the wrong GPIO pin, i have tried GPIO 0,1,3 & 16, but the Relay does not trigger.
Which changes to the code are necessary to make the Relay trigger when the “Light on” button is pressed.
Here the code with changes made in the following lines : 27, 51, 113 & 128-131(marked green).

 

/*
ESP32CAM Robot Car
esp32cam-robot.ino (requires app_httpd.cpp)
Based upon Espressif ESP32CAM Examples
Uses TBA6612FNG H-Bridge Controller

DroneBot Workshop 2021
https://dronebotworkshop.com
*/

#include "esp_wifi.h"
#include "esp_camera.h"
#include <WiFi.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

// Setup Access Point Credentials
const char* ssid1 = "ESP32-CAM Robot";
const char* password1 = "1234567890";

extern volatile unsigned int motor_speed;
extern void robot_stop();
extern void robot_setup();
extern uint8_t robo;
extern volatile unsigned long previous_time;
extern volatile unsigned long move_interval;
#define BEAM 1
#define CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27

#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22

void startCameraServer();

void setup()
{
pinMode(BEAM,OUTPUT);
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // prevent brownouts by silencing them

Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();

 

camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
//init with high specs to pre-allocate larger buffers
if(psramFound()){
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 10;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
}

// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}

//drop down frame size for higher initial frame rate
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_QVGA);
s->set_vflip(s, 1);
s->set_hmirror(s, 1);

WiFi.softAP(ssid1, password1);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);

startCameraServer();

ledcSetup(7, 5000, 8);
ledcAttachPin(1, 7); //pin1 is LED//1 was 4
robot_setup();

for (int i=0;i<5;i++)
{
ledcWrite(7,10); // flash led
delay(50);
ledcWrite(7,0);
delay(50);
}

previous_time = millis();
}

void loop() {
digitalWrite(BEAM, HIGH);
delay(10000);
digitalWrite(BEAM, LOW);
delay(10000);

if(robo)
{
unsigned long currentMillis = millis();
if (currentMillis - previous_time >= move_interval) {
previous_time = currentMillis;
robot_stop();
char rsp[32];
sprintf(rsp,"SPPED: %d",motor_speed);
Serial.println("Stop");
robo=0;
}
}
delay(1);
yield();
}


   
ReplyQuote
Page 3 / 4