RC Boat with NRF24L01+ and Arduino

A place to document your own projects.

RC Boat with NRF24L01+ and Arduino

Postby Markus Gritsch » Fri Aug 19, 2016 5:51 am

Hi,

I and my little son built a small electric boat from a kit. However, the kit only offered turning on the motor with a switch, and let the boat cruise wherever fortune it may take.

I thought why not improve it a bit by adding some RC capability. I had some left over toy quad copter remote controls, and decided to use them by building the receiver side out of an 3 $ Arduino mini knock off and the popular NRF24L01+ chip.

IMG_5915_1600x1200_85.jpg

rcgroups.com forum user bikemikem added some receiver functionality [1] to the popular nrf24-multipro project by goebish [2]. I made some small adjustments, and the final firmware is attached to this post.

The wiring between the Arduino and the NRF board is shown below. The motor is PWM driven with some random FET, and the whole thing is powered by some old phone battery underneath the connection board. A single servo is used for steering.

IMG_5807_1600x1200_85.jpg

The "Bayang" protocol is used by a lot of different models. The following picture shows a few:
* Eachine H8 Mini (top left)
* Bayangtoys X9 (top right)
* Floureon H101 (bottom left)
* Devo 7E with Deviation [3] and NRF module

IMG_5920_1600x1200_85.jpg

Here is a short YouTube video: https://youtu.be/VLFMQFPwuEg

Have fun,
Markus

[1] https://github.com/bikemike/nrf24_multi ... 4_multipro
[2] https://github.com/goebish/nrf24_multipro
[3] http://www.deviationtx.com/
Attachments
nrf24_multipro-rx_mode.zip
(53.08 KiB) Downloaded 683 times
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Juris » Fri Sep 23, 2016 5:38 am

Thank You for sharing this project! I am not so good at programming, could You help me a little? What parts of code should be cloned/modified to get more servo channels outputs? I studied code, yours and original RX, but I am lost there for now.
Thanks in advance!
User avatar
Juris
Newbie
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 5:32 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Markus Gritsch » Fri Sep 23, 2016 1:35 pm

You could try the following:

In nRF24_multipro.ino define a second servo object around line 36 so that it reads:

#include <Servo.h>
Servo servo;
Servo servo2;

Around line 158 attach some appropriate free pin to this second servo object

servo.attach( 2 );
servo2.attach( <yourPinHere> );

Then in Bayang.ino around line 209 use the pitch/yaw/throttle variable to write a value to servo2:

servo2.write( pitch / 1023.0 * 180 );
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Juris » Fri Sep 23, 2016 2:42 pm

I am very thankful for Your response! I will try to play with code next days. I tried code "as is", and it is working (with "Floureon H101" remote), so I know basically system is working. I will try to expand possibilities now. Thanks again!
User avatar
Juris
Newbie
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 5:32 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Juris » Sat Sep 24, 2016 3:43 pm

Hello again!
I followed Your suggestions, and made additions to code. It is working now with 3 servos control! Thank You for this small code lesson ;-) Big Thankyou.
I post here relevant code changes, so maybe someone else interested can do the same.
In file "nRF24_multipro.ino":
.
.
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
.
.
Serial.begin( 115200 );
Serial.println( "Start" );
servo1.attach( 7 );
servo2.attach( 8 );
servo3.attach( 9 );
.
.

And, in file "Bayang.ino":
.
.
servo1.write( - asin( roll / 511.5 - 1.0 ) / ( 3.1416 / 2 ) * 80.0 + 90 );
servo2.write( pitch / 1023.0 * 180 );
servo3.write( yaw / 1023.0 * 180 );
.
.
// neutral all servos position; motor off:
servo1.write( 90 );
servo2.write( 90 );
servo3.write( 90 );
.
.
I think I will try to understand code of pushbuttons ("flip", "headless", etc), would be awesome to receive and use them too (you know - lights on/off, missile launch, self destruct, etc, etc :) :) )
User avatar
Juris
Newbie
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 5:32 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Juris » Sun Sep 25, 2016 11:18 am

Update: well, that was easier that I thought it will be, with my non-existing programming skills. I added four digital (On/Off, 1/0) outputs that are controlled from four buttons on "Floureon H101" remote, namely: Flip, Return, Invert, Headless.
Summary, receiver features are:
Servo1 - D7
Servo2 - D8
Servo3 - D9
On/Off from "FLIP" button - D10
On/Off from "RETURN" button - D11
On/Off from "HEADLESS" button - D12
On/Off from "INVERT" button - D13
Speed - D6

Again, Thanks to Authors of original code, and RC boat modification!
I attach modified code here.
Attachments
nRF24_multipro_MOD_3servo_4buttons.zip
Arduino Receiver for "Floureon H101" remote (Bayang protocol).
(39.15 KiB) Downloaded 272 times
User avatar
Juris
Newbie
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 5:32 am

Re: RC Boat with NRF24L01+ and Arduino

Postby Juris » Tue Oct 11, 2016 9:26 am

I made another "Bayang" receiver modification. In this version, there are 4 servo-type outputs, any of them can be used also as bi-directional motor control, when signal is feeded to bi-directional ESC (electronic speed controller).
Simple one-way motor analog speed control on D6 is disabled in this version, instead D6 is used as fourth servo (or ESC) signal.
In file "Bayang.ino" I made comments how to easily change servo (or ESC) ranges for your needs.
Look for commented lines like this:
" //change "80.0" to other servo degrees what you need."
Code is in attachment.
Enjoy :)
Attachments
nRF24_multipro_1esc_3srvo_4button_VariablDegrees.zip
custom Arduino receiver for "Bayang" protocol transmitter.
(39.38 KiB) Downloaded 255 times
User avatar
Juris
Newbie
Newbie
 
Posts: 5
Joined: Fri Sep 23, 2016 5:32 am

Re: RC Boat with NRF24L01+ and Arduino

Postby PhatTony » Thu Feb 16, 2017 2:39 am

Jueris wrote:Thank You for sharing this project! I am not so good at programming, could You help me a little? What parts of instant knockout should be cloned/modified to get more servo channels outputs? I studied code, yours and original RX, but I am lost there for now.
Thanks in advance!


That's cool. Where did you get the original kit from?

I bet your son loves having a dad like you who can make cool stuff!
PhatTony
Newbie
Newbie
 
Posts: 1
Joined: Wed Feb 15, 2017 3:04 am


Return to Project logs