In this book you’ve learned about seemingly every kind of drone imaginable, but there are still more types to discover! In this chapter, you build the waterborne drone, a floating robot with soda-bottle pontoons, which is shown in Figure 11.1. Before you get to the project, however, you’ll need to understand the advantages and disadvantages of building water-based drones. You’ll also learn about two important topics: how to waterproof your electronics, and how to set up an XBee mesh network, which is another way to control a drone. You’ll use this know-how to build a remotely controlled boat steered by a cool little handheld controller you’ll assemble yourself.
Everyone knows if you drop a cellphone in the bathtub, it will get fried and probably won’t work again. We get that water and electronics don’t get along. However, there are more considerations than just waterproofing to keep in mind while building such a craft.
Let’s go over the hazards and inconveniences of operating a waterborne drone:
Water damages electronics—In one sense, this well-known hazard is just as bad as everyone supposes. An Arduino or other electronic module may be destroyed by immersion, leaving your drone dead in the water. On the other hand, you shouldn’t feel like everything is DOA when immersed. Ordinary brushed DC motors, for instance, are perfectly happy operating underwater, as long as you allow them to dry out. Don’t put them in salt water, however, because it will quickly corrode the motor’s innards.
Displacement of water is required—Dead electronics and corroded motors aren’t the only hazard. Let’s face it, the drone has to stay afloat, either with pontoons or some sort of boat shape that displaces water. The latter works only as long as it doesn’t flip over! That said, there are a lot of options. The boat in Figure 11.2 is made out of a brownie pan!
Space is required—Unlike quadcopters and rovers, boat drones can’t be played with in your backyard, unless you have a big pool. Going down to the neighborhood park is always an option, as long as there aren’t any kids in the wading pool. Ironically, if you are around a body of water larger than a lake, it may very well be too rough and choppy to safely operate a small craft.
Drones disappear or get easily damaged—There is a real possibility of never seeing your drone again if you send it out onto a large body of water. If your ROV sinks into the silt at the bottom of a river, you’re unlikely to recover it unless you have a strong cable attached to it. By contrast, quadcopters—which do occasionally fly off into never-never land—mostly can be recovered when they fail, if only in pieces!
Don’t let all that doom and gloom get you down. There are also some very cool things about this type of drone:
Less friction—Waterborne drones require less force to propel than other types, because friction atop the water is much less than, for instance, on the ground (for ground-based drones). Sailboats illustrate this principle very well. Even a tiny breeze will get a sailboat moving when it’s on the water. This works to your advantage because you can use relatively crazy methods to propel your craft. In that spirit, this chapter’s project uses an air pump to push the craft along.
Simple design—Waterborne drones typically are simple vehicles, usually requiring only two motors—one to propel the craft and one to steer. Quadcopters obviously need four, but many types of aerial drones have more—six or eight is not uncommon. Even the ground-based rover you’ll build in Chapter 13, “Making a Rover,” uses four motors.
Multiple configurations—You can choose among many different configurations, ranging from submersibles to hovercraft to surface boats. There isn’t just one kind of floating drone to make. Have fun and be creative!
The major bugaboo of making floating drones, as everyone knows, is getting water on your electronics, an accident very likely to short-circuit and destroy the components. The best way to protect your electronics is to have them sealed inside a waterproof enclosure. The following sections describe three different routes for enclosing the electronics. (There is also a fourth option—a chemical treatment—that is even more different.)
When in doubt, go low rent! The Rubbermaid seven-cup container pictured in Figure 11.3 is relatively cheap and easily obtainable. It’s also readily modified, such as by drilling a hole in it to accommodate some wires, and it isn’t so precious that you wouldn’t hesitate to alter it.
Another advantage to going this route: You can get the things in any number of sizes, ranging from “smaller than your palm” all the way up to “can hold Thanksgiving dinner” in size. I mentioned sandwich-sized in the heading mostly because it’s a good configuration for an Arduino and battery pack.
Note that spending a lot of money in this category won’t necessarily get you a tighter seal, which is mostly what you want. You may find the dollar store box is just as good as Tupperware.
These tough-as-nails enclosures are designed to hold cell phones and other valuable electronics, and basically protect them from pretty much everything, including immersion (up to 1 meter for 30 minutes), sudden movement, and crushing. They have a huge rubber gasket inside that seals the interior against moisture but also cushions the contents against impacts.
That may seem a little radical, but the price is right: The Model 1010 (left) and Model 1020 (right) cases pictured in Figure 11.4 cost only $9 and $15, respectively, varying by store. If you don’t like those sizes, Pelican offers a variety of cases, ranging up to a giant trunk that takes two people to lug. As with the Rubbermaid tub, you’re likely to need to modify the cases to allow wires to pass in and out. I buy my Pelican cases off Amazon, but other online retailers offer them as well.
A more do-it-yourself approach is used by the OpenROV submersible, pictured in Figure 11.5. The designers sealed the batteries inside plastic tubes, which feature end-caps sealed against moisture.
Other versions of the ROV use PVC piping. You can buy PVC in any hardware store, and it’s most frequently associated with plumbing. It consists of all sorts of watertight fittings such as curves and forks. Many tinkerers make furniture out of PVC, for its structural uses, but not many have taken advantage of its watertight nature. This stuff was meant to keep water in; it’s no wonder it also can keep it out.
Another angle to waterproofing is to coat the item you want to waterproof in a water-repelling enamel such as CorrosionX (CorrosionX.com) that dries and hardens on electronics and protects them from moisture. The stuff isn’t magic; don’t expect your drone to operate underwater. However, CorrosionX will definitely help repel light rain and the like.
Let’s shift gears a bit and talk about another way to control your drone. More specifically, let’s discuss how to use the technology that will control your waterborne drone.
Mesh networking using an XBee wireless module (see Figure 11.6) makes for a flexible way to link multiple Arduinos together. In this chapter’s project, you’ll have just two nodes: the drone and the controller. However, the technology can connect many more nodes than that—256 or more, depending on the model of radio.
A mesh network differs from more hierarchal networks in that all of the nodes are equal: When you send a command, every radio in the net hears it. In order to command one or another radio, you have to specify in the software to pay attention only to commands meant for that radio. This isn’t your only option: XBees come in multiple configurations, and you can specify different types of networks.
XBee radios are based on ZigBee, an industry standard wireless protocol with many different flavors and spinoffs. Entry-level XBees are rated at 1 milliwatt, and have a range of 80 feet indoors and 300 feet outdoors. A “Pro” version, which costs more, offers a correspondingly better range: 140 feet indoors and a whopping 4,000 feet outdoors. Although the Pro version impresses, even the basic model is great for short-range drones.
For more information on setting up your own XBee network, check out Bildr’s XBee tutorial (http://bildr.org/?s=xbee) and adafruit.com has a great one as well: https://learn.adafruit.com/xbee-radios/overview.
Now that you’re up to date on waterproofing techniques and XBee networks, let’s tackle the project for this chapter: the floating drone, consisting of a wooden platform atop a pair of soda bottles (see Figure 11.7). It’s propelled by an air pump and is controlled by a wireless remote control you’ll build yourself. Let’s begin!
Laser-cut chassis. You can download the pattern at http://www.thingiverse.com/jwb. Cut the chassis out of 1/8” (3mm) plywood.
Two soda bottles. I used typical 20oz Mello Yello bottles, 2.7” in diameter across the label, a bit wider above the label, then narrowing to a 1” diameter neck. If your bottles are different, you’ll want to adjust the laser pattern accordingly.
Pelican case (P/N 1010).
Arduino UNO.
Two XBee radios. I suggest the Series 1 from SparkFun (P/N 8665). You’ll need two!
Two XBee breakout boards to manage the radios (SparkFun P/N 11373).
Battery-powered air pump. The lighter the better! You can find these suckers cheap at any pet store. I yanked the pump out of a Marina (P/N 11134).
Tubing. I used Tygon B-44-3 beverage tubing, but your tubing doesn’t have to be food-safe. Anything with a 1/4” outer diameter and a 3/16” inner diameter would work well. I bought it off Amazon.
Servo. A waterproof one like the Hitec P/N 35646S is great, but way overpowered for your needs. Even a sub-micro servo would be adequate for this job. I ended up using a Hitec HS422. You can buy these and other servos at ServoCity.com.
Servo plate. I used a servo plate (Actobotics P/N 575144) to secure the motor.
Shaft adapter for the servo (Actobotics P/N HSA250). This secures the end of the dowel while connecting securely to the servo’s hub.
Dowel, 0.25” diameter, 3–4” in length.
Three buttons. You’ll want “momentary” buttons that release when you lift your finger. SparkFun P/N 9190 is a good one.
Two proto boards. I suggest either “perforated bare phenolithic prototyping boards” from Jameco (P/N 616690) or the SparkFun ProtoShield (P/N 7914).
Male header pins (SparkFun P/N 12693).
TIP120 Darlington Transistor (Adafruit P/N 976). This electronic switch triggers the pump when the Arduino gives it a signal.
Two LEDs. We’ll use just a couple of them—any old LED will do.
Two resistors, 220 ohm. SparkFun sells an assortment (P/N 10969) that includes some 220s.
A 1N40001 diode (Adafruit P/N 755).
Double-sided tape.
Wire.
Zip ties.
Once you have all your parts together, it’s time to build your boat. After you’re done with the boat, you’ll build the controller.
1. Laser out the chassis. I show the bottle rests getting glued in Figure 11.8. To be honest, making a chassis is something you can do with masking tape and cardboard; it doesn’t have to be as fancy as this. As long as it holds the bottles in check and keeps the enclosure out of the water, it will be fine.
2. Assemble the chassis by gluing the parts together, as you see in Figure 11.9. Once the glue is dry, cover it with a couple coats of your favorite spray paint to protect it against moisture.
3. Attach the Pelican case (shown in Figure 11.10) using double-sided tape. Alternatively, you can use zip ties. Even more radical, you can drill mounting holes in the base and screw the chassis into place—although this will make it less watertight, obviously. I have the chassis resting on the soda bottles but they haven’t been attached yet.
4. Solder up the breakout board of the drone’s Arduino by following along with these sub-steps:
a. Add the header pins to the breakout board, as seen in Figure 11.11; they should conform to the pins on the Arduino. You may even want to use the Arduino itself to help keep the pins in place while you solder them in from above, just to keep everything straight.
b. Solder the XBee Explorer to the board and use wires to connect its pins to the appropriate Arduino pins. Data out (the pink wire in Figure 11.12) goes to pin 3 of the Arduino, while data in (blue) connects to pin 2. Power (red) and ground (brown) connect to their respective pins on the Arduino.
c. We’re going to add a status LED that lights up when the Arduino has power. Connect 5V to the positive lead of the LED with a 220-ohm resistor in between. I use an orange wire in Figure 11.13. Connect the negative lead of the LED to ground, shown as a black wire in the figure.
d. Add the TIP120 to the board, with the leftmost pin (called the base) connected to Arduino pin 11 via a 2.2K resistor. This is shown as a purple wire in Figure 11.14. The rightmost pin, called the emitter, connects to the Arduino’s ground pin, and this is depicted as a cyan wire in the figure.
e. Add the pump and diode. The diode helps keep the motor from feeding back on itself, and it’s a good idea to include one every time you use a DC motor, of which this pump is an example. One lead (shown as a green wire in Figure 11.15) of the motor connects to the 3.3V pin of the Arduino, while the other one (yellow) plugs into the center pin of the transistor, called the collector.
f. Add the servo. The yellow and white striped wire (seen in Figure 11.16) is data and connects to pin 9 of the Arduino. The other two wires, red and black (each with stripes), connect to 5V and ground, respectively. You’ll usually encounter servos with plugs on the end of the wire. If this is the case, you can solder in some male header pins and simply plug in the servo.
g. When you’re ready to power up the drone, connect a 9V battery to the battery holder and plug it into the barrel jack on the Arduino.
5. Attach the air pump to the chassis using a zip tie (see Figure 11.17). The output tube can point in any direction, as a length of plastic tubing will direct the airflow in the direction we want.
6. Attach the servo to the chassis with the help of the servo plate. It should look like Figure 11.18.
7. Attach the dowel to the servo using the shaft coupler, as shown in Figure 11.19. Just slide it onto the splines of the servo’s hub, then secure with the servo-horn screw sold with the motor. Slide the dowel into the 5mm end of the coupler and secure it using the accompanying set screw. While you’re at it, glue the tube holder onto the end of the dowel—you printed this small piece out with the rest of the chassis.
8. Put the electronics package in the Pelican case, making sure you have enough wire to allow the pump and servo to be installed in their proper places (see Figure 11.20). You may need to alter the box to allow the wires to exit; although this will affect the water tightness of the box, it’s a necessary sacrifice!
9. Plug a tube into the pump’s output and run it through a chassis hole—drill one as needed. Figure 11.21 shows how it should look.
10. Zip-tie the tube to the tube holder on the dowel, as seen in Figure 11.22.
11. In the final step for the drone’s hardware, attach the soda bottles to the chassis using double-sided tape, as seen in Figure 11.23. Simply run the tape along the inside of the bottle rests.
The controller is similar to the drone’s electronics package in that it has an XBee and Arduino, but substitutes a couple of buttons for the motors. Follow along with these steps:
1. Assemble the electronics package. Follow these sub-steps to complete the assembly:
a. Add the header pins to the breakout board, as seen in Figure 11.24, just as you did with the drone’s board.
b. Solder the XBee Explorer to the board and use wires to connect its pins to the appropriate Arduino pins, just as you did before. I used the same wire colors as before: Data out (the pink wire in Figure 11.25) goes to pin 3 of the Arduino, while data in (blue) connects to pin 2. Power (red) and ground (brown) connect to their respective pins on the Arduino.
c. Solder in the status LED as you did before: Connect 5V to the positive lead of the LED with a 220-ohm resistor in between. I use an orange wire in Figure 11.26. Connect the negative lead of the LED to ground, shown as a black wire in the figure.
d. Add a pair of buttons. They each have 5V going into one lead (purple wires in Figure 11.27); the negative lead goes to a digital pin on the Arduino—pins 6 (orange wire) and 7 (green) for the two of them. Finally, connect the negative pin to ground with 2K resistors in between. This is depicted using black wires in the figure. You’re done with the controller!
Fascinatingly, at least for me, the nature of the XBee network is such that the controller and the drone are equals—theoretically, the drone could send a command to the controller. Because of this, you can literally run the same code in both units. This is what we’ll do. So, upload the following code to both Arduinos:
#include <Wire.h>
#include <Servo.h>
//lets initialize a number of variables and constants
Servo myservo;
const int pumpPin = 11;
const int button1Pin = 6;
const int button1Pin = 7;
int button1State = 0;
int button2State = 0;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to
the servo object
pinMode(11, OUTPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
}
void process_incoming_command(char cmd)
{
switch (cmd) {
case ‘1’: //left
myservo.write(30); //turn the servo to 30 degrees
delay(15);
digitalWrite(pumpPin, HIGH);
delay(1000); //turn on the pump for 1 second
digitalWrite(pumpPin, LOW);
break;
case ‘2’: //right
myservo.write(150); //turn the servo to 150 degrees
delay(15);
digitalWrite(pumpPin, HIGH);
delay(1000);
digitalWrite(pumpPin, LOW);
break;
case ‘3’: //forward
myservo.write(90); //turn the servo 90 degrees
delay(15);
digitalWrite(pumpPin, HIGH);
delay(1000);
digitalWrite(pumpPin, LOW);
break;
default: //if no command is issued, the pump stops
delay(1000);
break;
}
}
void loop()
{
if (Serial.available() >= 2)
{
char start = Serial.read();
if (start != ‘*’)
{
return;
}
char cmd = Serial.read();
process_incoming_command(cmd);
}
// Let’s interpret the button-presses.
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
if (button1State == HIGH) && if (button2State == LOW) {
Serial.write(‘*’);
Serial.write(1);
}
if (button1State == LOW) && if (button2State == HIGH) {
Serial.write(‘*’);
Serial.write(2);
}
if (button1State == HIGH) && if (button2State == HIGH) {
Serial.write(‘*’);
Serial.write(3);
}
}
In this chapter you learned about waterborne drones and actually building one. In Chapter 12, “Building a Quadcopter V: Accessories,” we’ll finish off the hardware build of our quadcopter with a 3D-printed camera mount that allows you to take pictures in the air.
3.141.27.244