I am working on a project to automate the wooden train track of my son.
the hardware is all working but now i want to add the ESP32-c to the project to control the servo's for flipping the track over so my son can decide to let the trian go straight or left/right.
I found some projects using a HC-05 or HC-06 module, but the ESP32 has wifi and bluetooth on board so i want to use that.
i started to make this project Control ESP32 over Internet using Android App with MIT App Inventor but i want to replace the leds used in this project for a servo.
My question is : is this possible? and can someone help me out how to make it ?
Hello @martijn_vd_brakel,
since your son is (most probably !) impatient to see it working, my hint is to consider to use the BT instead of the WiFi (of the ESP).
I guess you have only one ESP and only one AI2 device (phone or pad, running Android OS) connected each other, so the use of the classic BT (i,e. not BLE) is much esier to use and stable, in terms of communcation protocol and amount of examples you can find "everywhere". Another assumption is that you don't need a long distance between the sender and the receiver (approx. max 10 meters).
That said, you can find a huge amount of examples in the community, and specifically on the web sites of @Juan_Antonio (KIO4.com) and @ChrisWard (professorcad.co.uk) together with tutorials and "step-by-step" instructions.
Nevertheless, whether you need specific details, please let us know (as @Usane has already asked) more details on your project, so the let us help you more efficiently.
Rgds.
It could just run until it hit a cut-out button, there may have to be allowance for a little over run of the servo (but not the rail point). If you want to control degrees tightly with only the motor, that is stepper motor territory. A simple sounding task but precision is always difficult.
I am making this project with a man i met online in search of making wooden tracks more "real " for kids
He is a great designer and we are having much fun trying it all out and thinker about how to make it all more and more exciting
I there for came up with the MIT app and tried some things out .. as i mentioned its hard to find esp32 control for servo S90
I think the track can be flipped with preset degrees cause the track has some room for the train to go left or right ( it doesnt have to be really precise)
I indeed thought about stepper motors but they are big and not easy to Insert in the printed part...
So it would be great if someone can help me.out howto make a servo controller thru bluetooth or wifi
(Prefer bluetooth)
And i can make a nice layout for controlling
So its possible to help me out?
I am thinking the only things i need.for making the app is how to make the servo connect to the esp and make it work with bluetooth?
Then i need to make the app working so help with both is much appreciated
Yes, there is no need for stepper motor precision, I think the same. I haven't used the bluetooth yet neither on the esp32 or the appinventor, so I cannot help on that, but if you choose the WiFi route I can. Although, indeed the BT would be the easier one.
Dear @martijn_vd_brakel and son ( ), the annexed .aia works for me with an ESP32 and a Xiaomi phone (Android 9).
It operates on classic BT.
The app has 3 buttons and sends accordingly 'A' 'B' 'C' to the ESP via BT.
The .ino file is the ESP32 counterpart.
The ESP shows on the Serial Monitor of PC the received character and sends it back to the app (closed loop). The app shows the feedback character received.
To make it working, first of all you have to "pair" your phone to the ESP32 (in phone's BT settings).
In my app's code the IP address of my ESP32 is fixed as a text constant, you shall substitute this address with the one of your ESP. If you dont know it, you can download the Serial Bluetooth Terminal app from google playstore (free).
Therein, by selecting the menu "devices", you have to find ESP32_BT in the shown list and annotate the address, that you have to copy into the app code instead of my address.
Then recompile the app's code, download the apk to your phone and launch it.
Of course your ESP shall still be connected to your PC with the option Serial Monitor active (baudrate 115200).
That's all ! BT_to_ESP32.aia (24.9 KB) BT_Send_Monitor.ino (1.8 KB)
Note: whether your Android is (most probably) a newer version, i.e.>= 12, you shall ask for permissions into the initialization event. You can get info about this requirement here:
Start from the beginning.
About the hardware.
How many servo do you want to controll with the ESP32?
Do you already have the circuit (for example: which pins do you use on the ESP32)? The ESP32 is a 3.3V device. The S90 servo is a 5V device. Not sure if the servo works without level shifter.
Will take a look at that....
Thanks
I am going to use the ESP32-C super mini that can handle 5V.
I see this board has a TX and RX pin onboard, maybe its possible to use the code for the HC-05 module ?in the tutorials that i can find about using MIT with esp32 Bluetooth the HC-05 is attachted to that pins ...
This might be a way to try out and see if it works...
Only the thing is i need.to.find.room.in my project to get the module in but for testing learning and playing with MIT app it will be a good way i hope...
Ill keep u posted
Yep, that tutorial seems pretty good.
Just let me highlight that the Tx pin of HC05 shall be connected to the Rx Pin of ESP (and Rx to Tx).
If you use the Super Mini ESP that has I/O at 5 V instead of 3.3, please be careful to connect the HC05 Rx pin with a voltage divider:
(don't care if in the image you see a Nano and a HC06: the same applies to HC05 and any Arduino board featuring a 5V I/O). This requirement is NOT mandatory, but the Rx pin of HC05 will appreciate your care
Cheers, Ugo.