Control a Raspberry powered RC boat from within the web-browser

Michael Münzer
3 min readJan 10, 2021

After connecting my Pi Zero to an ESC, I now want to control the boat from a web interface.

Used hardware:

Used software:

Software configuration

Install the latest node.js environment with npm for package management on the Pi:

sudo apt-get install nodejs npm

Install some javascript dependencies which we need later in the tutorial:

npm install express http ip pi-blaster.js

Verify that pi-blaster is running correctly after start-up:

sudo systemctl status pi-blaster

You can find a very simple example to control your boat here. Clone it on to your raspberry:

git clone https://github.com/michaelmuenzer/picruise.git

Set your min & max values for servo and motor within app.js. I found out by setting up the boat and trying different values until I was happy.

var pwm_motor_off = 0.0;
var pwm_motor_min_limit = 0.1;
var pwm_motor_max_limit = 0.2;
var pwm_servo_min = 0.05;
var pwm_servo_neutral = 0.1;
var pwm_servo_max = 0.15;

Additionally, you can configure how much faster / slower your motor should rotate by playing around with the following:

var speed_step_width = 1;
var speed_num_steps = 20;

The same is true for the rotation angle of the servo:

var angle_max = 45;
var angle_min = -45;
var angle_step_width = 15;

I had to do some additional configuration, as the boat was not reversing as I wanted it to. According to the manual of QuicRunWP1625 “Fwd / Br / Rev” are supported and set as a default. Rev(erse) is implemented by using the “Double-click” method:

This mode uses “Double-click” method to make the vehicle reverse. When moving the throttle stick from the neutral zone to backward zone for the 1st time, the ESC begins to brake the motor and the motor slows down but still running, so the backward action is NOT performed immediately. When the throttle stick is moved to the backward zone again, if the motor speed slows down to zero (i.e. stopped), the backward action will happen.

Therefore I implemented this sequence when pressing the Backward button for the first time after switching directions. Of course, you can vary the behavior depending on your preferences and controller.

After having set up everything correctly you can start the web-server on the Raspberry by running:

node app.js

You can now access it on http://raspberrypi.local:8082/

Press Start for the ESC to correctly connect to the motor. A long-beep is the confirmation that the calibration finished.

When going Backward you will hear a different kind of on-going beep signal coming from the ESC.

Now you can see your boat moving when you press the controls:

When testing the controls in your bathtub at home, I recommend holding the boat with your hand before pressing any of the controls. The motor I use is pretty strong and makes the boat crash fast. By holding it, you already get a feeling if the boat is moving in the desired direction and you can verify that everything works.

When going outdoors with your boat, you most likely don’t want to start the web-server manually each time when the Pi starts. If you want to run the server on startup, you can follow any of the tutorials described here.

I added PiCruise.sh to the init.d directory with a symlink:

sudo ln -s /home/pi/picruise/PiCruise.sh /etc/init.d/PiCruise

Made it executable:

sudo chmod +x /home/pi/picruise/PiCruise.sh

And run the following command:

sudo update-rc.d PiCruise defaults

Now you can verify that your web server started with sudo reboot and sudo systemctl status PiCruise.

If you also got excited about all the fun stuff you can do now, check out my other tutorials, like connecting a GPRS module to your Pi. 🤩

--

--