Build an ESP32CAM R...
 
Notifications
Clear all

Build an ESP32CAM Robot Car

Page 2 / 3

John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 

I've got a problem! The sketch won't work on my ancient smart phone, which runs Android 2. I traced, and fixed, part of the problem, but I'm stuck with the rest of it.

1) The buttons didn't work due to onclick="fetch(document.location.origin+'/control?var=car&val=1'); in the button code. fetch() only works on browsers from around 2015-17, and my phone is older than that. I've managed to rewrite it using the older XMLHttpRequest, which works on my phone and the latest version of Firefox on Linux Mint.

2) I can't turn on the video stream, and trying to understand how this works is beyond me. I think I'd be happy with the video always on, but can't work that out either!

3) The sliders don't display at all. I've spent ages trying to find a way to create touch sliders, but the nearest I got was one that jumped to where I tapped the screen.

I'm happy using a mobile phone that just makes voice calls and sends texts, and bought this phone very cheaply on eBay to see what it can do. So I don't want to spend many times what I paid for it just to drive a model car!

Either I'm after some help, or just warning anyone else who might want to use it on a very old phone!


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 1078
 

@john_b

Can you control it from your computer?  If it works from the browser on you computer then you may be SOL on the phone.  I may have the same issue when I get to trying out my phone it is an iPhone 5 and can't be upgrade past IOS 10.  I have found any recent apps aren't even loadable but I not sure what HTML version it might or might not support.

SteveG


ReplyQuote
John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 

@codecage

It looks like my computer is fine. The buttons get the right response on the Serial Monitor, and the video and LED turn on and off. The sliders control picture quality as they should. So I've no doubt that it will control the motor when the parts arrive.

I wish I could find some example code for sliders that would work on the phone. Building this car is supposed to be a quick project to help with more complex things I have planned, and I was hoping to be able to use the phone for testing these projects before building proper controllers for them. But I need a control on the phone that works like a potentiometer.

This is the Javascript for the buttons using XMLHttpRequest (from https://www.w3schools.com/xml/xml_http.asp):

 <script>
function loadXMLDoc(idref, variable, value) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "/control?var="+variable+"&val="+value, true);
xhttp.send(); }
</script>

and the HTML for the buttons:

<tr><td></td><td align="center"><button class="button button2" id="forward" onclick="loadXMLDoc('forward', 'car', 1)">FORWARD</button></td><td></td></tr>
<tr><td align="center"><button class="button button2" id="turnleft" onclick="loadXMLDoc('turnleft', 'car', 2)">LEFT</button></td><td align="center"></td>
<td align="center"><button class="button button2" id="turnright" onclick="loadXMLDoc('turnright', 'car', 4)">RIGHT</button></td></tr>
<tr><td></td><td align="center"><button class="button button2" id="backward" onclick="loadXMLDoc('backward', 'car', 5)">REVERSE</button></td><td></td></tr>
 
<tr><td></td><td align="center"><button class="button button4" id="flash" onclick="loadXMLDoc('flash', 'flash', 1)";">LIGHT ON</button></td><td></td></tr>
<tr><td></td><td align="center"><button class="button button4" id="flashoff" onclick="loadXMLDoc('flashoff', 'flashoff', 0)">LIGHT OFF</button></td><td></td></tr>

I've passed the button id to the function, but it results in the button size changing after it's pressed, so I've ignored it until I can work out why.

I hope that may be useful.

This post was modified 5 months ago by John_B

ReplyQuote
John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 
Posted by: @john_b

For anyone in the UK who wants to build this, I've found a useful source on eBay. This seller is offering an ESP32-CAM, antenna and programming board for £9.99
https://www.ebay.co.uk/itm/ESP32-CAM-with-Antenna-Plus-Power-Interface/184749847858

...............

I'm hoping the programming board will work with other ESP32-CAMs as well, but so far it's failed to connect on the other two I have (all 3 are different makes). This needs further investigation, unless anyone knows the answer.

In my earlier post I couldn't get the programming board to work with my other ESP32-CAMs, but I've solved it now. The IO0 button on the programming board connects the pins marked PGM in Bill's diagram. So for many ESP32-CAMs, you need to press and hold that button before plugging in the USB cable, keep it held down while compiling and uploading takes place, and release it after the message "Hard resetting via RTS pin..." appears on the Arduino IDE. Then unplug the USB cable, and plug it in again. The sketch should then run.

The ESP32-CAM that came with the programming board works just like a normal Arduino. Plug in the USB cable, compile and upload the sketch, and it immediately starts to run. No buttons need to be pressed.

If you don't already have an FTDI adaptor, and will want to program more ESP32-CAMS in future, I think this board is worth buying, but I'm tempted to replace IO0 with an on-off switch to avoid a sore finger!!!

FTDI Adapter Hookup


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 1078
 

@john_b

Well at least it isn't anything except your phone, and maybe mine when I get that far.  Good luck with finding a work around.  I may be looking for that as well, when I get time to jump into this video.  Maybe someone else can jump into the fray and offer a solution.

SteveG


ReplyQuote
John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 

@codecage

This slider code works for me:
https://github.com/ubilabs/mobile-range-slider

Apparently software variants on old makes and versions of phones vary wildly, so it might not work for everyone, but it works on my HTC phone running Android 2.2.2 with Webkit 3.1. It will both slide, and jump to where the screen is tapped. It also works in Firefox 87.0 on Linux, with a mouse.

I thought I'd post this now, in case anyone else is following this. It looks like the web page will need a major rewrite, so it may take me some time, and the end result will be different to Bill's original to fit with my plans for the car. So it may be up to someone else to do an exact adaptation of the original.

Now I need to see if I can get the video to appear!


ReplyQuote
regmason
(@regmason)
New Member
Joined: 2 years ago
Posts: 3
 

Bill,

Where did you purchase that neat looking dipole antenna for the ESP32-CAM? I have looked everywhere.

Reg Mason

 


ReplyQuote
Arlo
 Arlo
(@arlo)
Eminent Member
Joined: 5 months ago
Posts: 22
 

@regmason I was able to get mine here. There are other styles available.

                                                                              Arlo


ReplyQuote
regmason
(@regmason)
New Member
Joined: 2 years ago
Posts: 3
 

Arlo,

Thanks for your timely response to my question, but there is no link to where you got your antenna.

 

Reg Mason

 


ReplyQuote
Arlo
 Arlo
(@arlo)
Eminent Member
Joined: 5 months ago
Posts: 22
 

@regmason Reg, did you click on the "here" in the sentence, it is an embedded link to Amazon. I just checked it and it's working on my end so if isn't opening for you let me know. It is set to open in a new tab so that might be causing issues depending on your browser.

   Arlo


ReplyQuote
regmason
(@regmason)
New Member
Joined: 2 years ago
Posts: 3
 

Arlo,

Either the contrast on my monitor is set wrong, or my 74 year old eyes could not see the highlighted 'here'. Thanks for your patience. Strange when I did a search on Amazon, these did not show up, just the old style skinny antennas.

Reg Mason


ReplyQuote
Arlo
 Arlo
(@arlo)
Eminent Member
Joined: 5 months ago
Posts: 22
 

@regmason That was my mistake , I should have underlined it so it was more pronounced. It is a subtle highlight on my monitor also, glad you found it though.

                                                                  Arlo


ReplyQuote
Troles
(@troles)
Active Member
Joined: 8 months ago
Posts: 11
 

Trying to build this car, but I am having a problem with the code.  Before even trying to upload it to the esp32, when I am just trying to verify it and/or save, I get the following error (on the 2nd code, the 'html' one):

image

on line 405 the code is:    static esp_err_t index_handler(httpd_req_t *req){

and arduino ide returns the following error:  'httpd_req_t' was not declared in this scope

I am sure this is some rookie mistake on my part (I just copied and pasted the code to start with this project) but does anyone know what this is?  


ReplyQuote
John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 

The rest of the parts arrived today, although thanks to a misleading eBay listing I've got a DRV8833 instead of the TB6612FNG. I've got too many of them already, but I'd already soldered the headers on before I noticed! I need to rewrite the motor driver code anyway, but didn't want the extra complication of using a different driver! Lets see what sort of damage I can do to this:

DSCF9572
DSCF9566

It's 1:24 scale, and has plenty of space inside. It's interesting to note that it's 2.4GHz, and the antenna is a very short piece of plain wire, so I'm wondering if the antenna I bought will be needed, as it's rather big for the car.

I think stage one, that I've started on, is to remove the circuit board, and connect the drive motor to one of the motor driver outputs. Then I'll see if the existing steering will work on the other one. It looks fairly straightforward to replace the steering motor with a servo to get proportional steering, but I'll take it one step at a time.

Once I'm sure it will work well enough, I'll have to cut a hole in the windscreen for the camera, and work out how I'm going to mount it. It takes three AA batteries, but could be rewired to take one or two of the same size, so I'm thinking that I may try using the same sized Li-ion batteries. I don't know how much the Wi-Fi will drain them.

It's got headlights that come on when the car is going forwards, but I think they need a proper switch. Rear lights, and reversing lights, will be quite challenging to add to the body, so maybe I won't!

I'm currently wiring up a breadboard, so this may actually happen!


ReplyQuote
John_B
(@john_b)
Active Member
Joined: 5 months ago
Posts: 11
 
Posted by: @troles

Trying to build this car, but I am having a problem with the code.  Before even trying to upload it to the esp32, when I am just trying to verify it and/or save, I get the following error (on the 2nd code, the 'html' one):

image

on line 405 the code is:    static esp_err_t index_handler(httpd_req_t *req){

and arduino ide returns the following error:  'httpd_req_t' was not declared in this scope

I am sure this is some rookie mistake on my part (I just copied and pasted the code to start with this project) but does anyone know what this is?  

I've just tried doing this and it worked first time. Try it again, or download the files from the link in the blue Resources box near the bottom of the page, which is what I originally did.


ReplyQuote
Page 2 / 3