Inspired by different internet pages (www.roboremo.com), I designed a solution allowing me to drive my RC car with my Android tablet. Useless, but so fun. The solution consists of three main elements:
- An ESP8266 on which runs a TCP server for controlling the steering servo and electronic speed controller (ESC)
- Roboremo: an android app for easily designing M2M interface composed of slider, buttons, graphics
- A RC car
An analog Servo control from a 5V electric signal with a period of 20 ms (frequency = 50 Hz). During this period, the signal must be in its high state (5V) for a time between 1 and 2 ms, a duty cycle between 5% and 10%.
This signal will be carried out using the NodeMcu PWM module. The duty cycle parameter is a value which must be between 0 and 1023, so:
- for duty cycle at 100% == 1023
- for duty cycle at 10% == 102
- for duty cycle at 5% == 51
ESP works as a WiFi hot spot and runs a TCP server listening on 9876 port. For each TCP request on this port, the frame is analyzed to output the good electrical signal to the servo or the ESC.
TCP packets are structured as follows: action, value, \n.
action
= "servo
" or "esc
"
value
= value of the duty cycle passed as a parameter to the NodeMcupwm.setup function()
\n
= end of the frame
The car battery powers the ESC, which itself powers the ESP and the servo through the 3 wires cable (5V, GND, signal). 2 LEDs are available:
- the red LED indicates that the ESP is powered on
- the white LED indicates that a TCP client is connected
The LUA code is available in the code section. ESP has been flashed with NodeMcu firmware modules:
gpio
net
node
tmr
wifi
pwm
The TCP client is ensured by roboremo
. First, design a screen with one slider to control the servo:
- label = servo
- id = servo
- min value = 51
- max value = 102
- auto return value = 76
Another slider to control the esc:
- label = esc
- id = esc
- min value = 51
- max value = 102
- auto return value = 76
Notes:
- The values must be adjusted according to the hardware and preferences
- You can replace the slider servo by an accelerometer
- More details in http://www.roboremo.com
Secondly, create a connection to the TCP server 192.168.0.1:9876
Third, enjoy!
Roboremo screenshots
Comments