How to Build an RC Duck - With Arduino and Wi-Fi
by Basement Engineering in Circuits > Arduino
3479 Views, 54 Favorites, 0 Comments
How to Build an RC Duck - With Arduino and Wi-Fi
It is summer, it is warm - well at least on some days here in Germany - sounds like the perfect time to take the duck out for a spin. Sounds a little bit weird, because it is, but it is also a heck of fun. In this Instructable I will show you how you can use a spare weekend to build a very special duck for some outdoor fun on the lake.
TLDR
If you don't like reading long texts, here is a short info snack, to get you excited:
Our duck has a Wi-Fi capable ESP8266 board for a brain, can be controlled with any phone with a browser (no apps required) and can be programmed without the Arduino IDE through the world's first Duck Flashing Website.
And if you care about any of those topics, you might to consider reading on, or just skipping to the steps.
You can also check out my YouTube Video on the project.
Backstory
The story of this project started on a random Wednesday, while I was strolling through the hardware store and saw a pond duck for sale. Well it actually started two years ago, when I decided to embark on a journey of building tiny boats using ESP8266 Boards, but for now, just keep in mind that I had a bunch of RC boats at home and I saw a duck.
What's the logical conclusion here? Of course, I had to turn it into an RC boat.
What's funny about ducks is that they are surprisingly similar to RC boats. They have a propulsion system to move through water, they have an internal energy source, and they have a brain, to control all of that. What they are lacking, is the ability for us to control them. Sounds sinister, However, keep in mind that training a dog to obey commands is socially acceptable, therefore wanting to control a duck should not be stigmatized. By the way, some people might tell you that ducks can also fly, but for the purpose of this project, we are just going to forget about that and build our very own electronic replica of a duck.
Similar Projects and What Makes This Duck Unique
I did the building first and the googling later. Turns out, I did not invent the lightbulb here. It seems like every RC enthusiast out there has thought about motorizing a duck at some point, and many pulled through to create beautiful projects. Here are my two favorites:
There is also a bunch of ready to use RC ducks available for purchase.
I still feel like my creation is unique in its own right, as it uses an open Wi-Fi microcontroller and a phone for remote control instead of conventional RC tech. This leaves an upgrade path for unconventional accessories, like sound modules, addressable RGB LED's maybe even a robotic arm. It just sparks imagination. This duck is also the only one that is (more or less properly) boatified using a custom 3D design (more on that in a later step).
Supplies
Unfortunately, this project wasn't cheap at all, with just shy of 50 bucks. You can already buy a ready to use RC duck for that kind of money. However, this duck project has way more charisma, and you will build it with your very own hands, therefore it's intrinsic value to you will be unimaginably high. And unimaginably high intrinsic value is worth a lot more than 50 bucks. So here is all the stuff you need, if you decide to follow my journey:
Electronics ~ 39,82 €
- WEMOS D1 Mini (Clone) Development Board | ESP8266 | AliExpress Link | 2,30 €
- 2x Brushed ESC | 30A 4-8V | AliExpress Link | 2,46 € * 2
- 2x Underwater Motors | 7,4V | AliExpress Link | 14,08 €
- Breadboard 400 Points | 2 €
- Wires | 1 €
- Pin Headers | 1 €
- 2x High discharge 18650 Battery | 20 A discharge current | Conrad.de Link | 8,49 € * 2
- Switch
Hardware ~5€
- Plastic Duck (Size of the body can be seen in the picture above) | 3 €
- Bread box (Size 130mm x 90mm x 45mm) | 1 €
- 8x M3 Threaded inserts | 1 €
- 8x M3 Bolts |
3D Prints ~5€
- Hull
- Baseplate
- Motor Holder
Tools
- Soldering Ion
- 3D Printer
- Powered Drill
- Saw
More Stuff
- Trusty old zip ties
- Waterproof construction glue
- 18650 battery charger
Total Sum: ~ 49,82 €
Components of a Duck
I'd like to give you a quick overview of our duck, before we delve into the actual hands on building. I will also elaborate some parts with more interesting details down below. However, these details are probably not interesting for everyone, so you can skip them if you want to.
As mentioned before, ducks have 5 important features, that our replica has to fulfill as well. They have
- A Hull
- A Propulsion System
- An Energy Source
- A Brain (presumably)
- A Government Control Transceiver ... well, maybe not that, but ours will have a receiver to receive our commands and to do what we want it to do.
Hull
This part is easy, it simply has to look like a duck and stay afloat. Features, that, a general purpose duck decoy usually fulfills. However, it still requires some modifications, which we talk about in step 5
Propulsion System
Mother nature is very complicated, when it comes to propulsion. Duck's have feet that they use to waddle around on land and swim in the water. For both cases, electronics provide us with a much simpler mechanism of creating movement - a motor with a propeller. We are going to use two of them for our duck. This will allow us to steer it using "differential thrust", which is the fancy way of saying reducing power on one motor and increasing it on the other to turn.
Energy Source
Ducks live off the land (or the lake) and love to eat whatever plants are floating around on top of it. I have no clue how, we would replicate that. Once again, mother natures solutions are surprisingly complicated. Our duck is just going to live off the wall plug, because we are going to use some batteries to power it. 18650 cells to be precise. Two of them, so we get the right voltage for our motors. As motors tend to have a high power consumption at startup, we have to choose batteries that can deliver a lot of power (current). I like to go with Samsung NR18650-25R cells that can provide up to 20 A.
Brain
Brains - very intricate little biological computers that are capable of doing a lot of stuff. However, they are, for the most part, not programmable. That's why we are going for the more approachable, albeit slightly less capable, microcontroller. I like to use an ESP8266 Board. It comes with Wi-Fi, so we already have our next part, the receiver, covered as well, and it can be programmed using the beloved Arduino ecosystem. My favorite board flavor is called "Wemos D1 Mini".
Receiver (and Controller)
As mentioned above, our brain already has receiver features integrated. It has Wi-Fi, allowing us to communicate wirelessly with it. But we still need a device to send our commands. I like to use a smartphone for that. I built a little website as a control interface, so you don't have to. Under the hood, our Brain board will act as a server and serve the website to whatever phone we want to use to control it. After that, the little website on our phone will open a so-called "Web Socket" connection to constantly talk to the brain and send our inputs. I also spent an extensive amount of time to program failsafe features, as the Wi-Fi connection can get lost. The website will tell you that and automatically reestablish a connection when you get closer to the duck.
Cut the Duck !
It's creepy, it feels wrong, and I don't like it, but we have to get our electronics into the duck's body. The easiest way to do that is to cut a big hole into it's body and put a box for the electronics inside. While we do that, we have to make sure to put our heavy components, such as the battery as low as possible, in order to have a more stable duck.
Put some tape on your insertion area and mark the material to be removed. Then drill one or more pilot holes and use a side cutter or a saw to cut it out. You might have to do some more chipping away on the border until the hole snugly fits around the box. Then you can glue it in place. I like to use waterproof construction glue for that.
After you are done, be sure to give the duck some rest, so it can recover from the procedure and get used to its new and improved body structure.
Boatify the Bottom
Boatification is a new word that I just made up to describe the process of turning the bottom of the duck into a boat like shape.
For me, this involved a lot of measuring and designing. However, if you manage to get a duck, that is similar to mine (in terms of size) you can just download the attached 3D components. These have to be printed and prepared. Preparations means inserting threaded M3 inserts into the pilot holes using a soldering ion. A very satisfying process, just make sure to keep the ion at the lowest heat setting, otherwise it will be a pretty melty experience.
To attach the bottom plate, we first have to cut off the bottom weight and sand it smooth. Just be very careful not to puncture the bottom of the duck in doing so. A smooth bottom allows us to glue the bottom plate onto it.
While the glue is drying, we can assemble the motor holder by screwing it onto the baseplate and sliding the motors inside, making sure to secure them with screws and hot glue. The front bottom part of the hull also screws in using M3 screws.
That's it, the bottom is now boatified and the hull pretty much ready to go.
Wire It Up
Now that the hull is done, we can properly assemble the electronics. There are some connections that have to be soldered or crimped together. Mainly the power connections on the left side of the schematic. This includes the motors, motor drivers, battery holders and the power switch.
The control wires from the motor drivers (white wire in reality) go to our WEMOS D1 Mini board. The motor drivers can also output 5 V power, which is just right for the controller. However, we can only connect one of the drivers power supplies to the board. If we connect both, we are just going to create a lot of magic electronics smoke and have to purchase new components.
All the final connections to the controller can be done on a 400 piece breadboard using 24 AWG solid core wire. Of course, you can solder the controller as well, but I like to keep this part flexible.
The motors and motor drivers should already come equipped with connectors. If not you can add header pins to make the motors removable. This way we can put the core assembly into our cursed lunchbox. Aka. the electronics container of the duck. We also have to drill three holes into the lid to run our motor wires and our power switch through.
Now you should be able to just plug in the motors and put the batteries into the battery holders. But please make sure to thoroughly check every connection for short circuits, before you plug in the batteries and turn it on.
Program It
This is usually the hardest part. Especially if you are the first one to code it and there is no code yet. That was quite a long journey and can be seen in the original Mini Kenterprise GitHub repository.
But you, lovely reader, are in luck. I have prepared a little treat for you. Programming your duck is now as simple as going to a website. You don't have to install any specific programming tools or work through compiler errors. Forget that, our code is online now.
You just need the Google Chrome browser. Open it up, if you are not already in it. Visit the Duck Flashing Website. Make sure to turn off the duck or, even better, take the control board out of the breadboard. Plug in your board via USB and hit "connect". Choose the board, hit upload, and boom. After a few seconds, you should be good to go.
Turning it on for the First Time
Now put the controller back into the duck and turn it on. You should hear a nice little melody from the motor drivers.
Now take out your phone and connect to the duck's Wi-Fi access point. It should be called "Ente" and the password is "RowYourBoat". Your phone will probably cry for help and try to go for another network, as soon as it detects the missing internet connection. Be sure to tell it that it is ok to connect to this offline network and to stay connected. Now open up a browser and go to the address 1.2.3.4. You should be greeted with a little controller website, and you should be able to use the joysticks to spin the motors. If one of them spins in the wrong direction, you might have to switch the two motor wires around.
How does this magic website work?
The whole web flashing domain was new tech to me that I decided to use for the first time in this project. It is an incredible tool for distributing microcontroller code and I want to quickly tell you how it works: The Duck Flashing Website is hosted straight from the git repository using GitHub pages. It uses ESP Web Tools to incorporate a little button that takes care of flashing the firmware. I had to get into developing websites with a package manager for this, but that was actually not too hard. I used vite.js and node.js to build the page.
The 3D model of the duck? Oh yeah, I also think that is pretty cool. I created it using the PolyCam app. This gave me a gLTF file that can be displayed in a web browser using the Three.js library.
E voilà, we have a working website to flash a duck.
You can find the entire website code in the duck repository.
Take It for a Spin
Time to take the duck for a spin. Head to your local lake, pond or very large puddle, turn it on and throw it in the water. Hit the gas and go for it. Make sure to keep an eye on the battery voltage, though, as we did not install any automatic protection. It should last 10-20 minutes. And also stay in range of the Wi-Fi network ( ~ 20 m ).
Why is this duck mediocre?
Well, there are two reasons. 1. I wanted this duck to be better (faster) than a normal duck, but it can barely keep up with its biological peers, probably due to its weight. 2. It is very wobbly in the water. You can see it in the picture and the YouTube video (coming soon) as well. Whenever it goes into curves, it sways very far from side to side. However, I actually think this is more of a feature, then a bug, cause it makes it way more fun to drive.
What's next?
I think this project is quite fine and I want to revisit it in the future and add one or two bigger motors to see if I can use that to finally overtake the real ducks on the lake. So stay tuned for that.
For now I'm focussing on my Mini Kenterprise project to further improve my student workshops and the code base.
I hope you had fun reading this, and I hope to see your duck on here quite soon.
Until next time, Jan.