Introduction: The Securibot: a Small Survelliance Drone for Home Security
It's a simple fact that robots are awesome. Security robots, however, tend to be way too expensive for an average person to afford or are legally impossible to purchase; Private companies and the military tend to keep such devices to themselves, and for good reason. But what if you really want to have a personal security robot?
Enter the Securibot: A small all-wheel drive robot that can patrol around where you desire and feedback information with a wide array of sensors. It's small, robust and cheap, and will require only minimal understanding of wiring and programming in order to create.
Step 1: Gathering Materials
The following materials will be required. These are parts that must be purchased and consumed for the final product, and as such it may be wise to have additional backup materials in case an accident occurs. Just click on a part to open a new tab if you must purchase it!
- 9-Volt Battery 4-Pack x1
- AA Battery 8-Pack x1
- 4-Slot AA Battery Holder x1
- Male/Male Jumper Wires x1
- Male/Female Jumper Wires x1
- Female/Female Jumper Wires x1
- Mini Breadboard x1
- 1k Resistor x1
- 2k Resistor x1
- Red/Black Power Cables x1
- Rocker Switch x2
HARDWARE AND SENSORS
- Arduino Uno Rev3 x1
- ESP8266 Wi-Fi Module w/ NodeMCU x
- HCSR04 Ultrasonic Sensor x1
- PIR Motion Sensor x1
- Motor Board x1
- Soldier Iron and Solder
- Wire Strippers
- Wire Cutters
- 8" Acrylic
- Laser Cutter
- Electrical Tape
- Small Screws & Nuts
*These materials are not required, but certainly add an extra layer of organization and protection. Being optional, they can be more commonly found in hardware stores, and laser cutters are a more serious consideration for purchase rather then simply renting one or having parts shipped.
Step 2: Programming and Planning
The Securibot is a rather complex device in terms of wiring and programming that may seem intimidating at first, but if done in small steps can be made easier. Below is a diagram that shows the entire wiring scheme. Even though this is here now, it would be unwise to wire everything since this entire mechanism will be attached to the robot. This is simply here to get a better understanding of how the device is set up on paper.
To program the robot, we will be using two different languages: Python and C/C++. Also, it is important to understand that this is best done when programmed on MacOS.
Before we begin, physically attach the NodeMCU to the Motor Board. You can do this by lining up the small squiggle on the bottom with each other. DO NOT PUT IT BACKWARDS OR IT WILL FRY!
Once you have connected the NodeMCU + Motorboard to a computer, open a terminal window, and begin write these lines, ignoring to type anything after a #.
ls /dev/tty.* #Finds the port the NodeMCU is listening on.
screen ls/dev/tty. 115200
#after this, hit enter until you see >>>, then type the following:
sta = network.WLAN(network.STA_IF)
ap = network.WLAN(network.AP_IF)
If you have programmed this correctly, you should now see a connection for MicroPython-xxxxxx (the numbers will differ based on the ESP8266 used) in your Wi-Fi. Connect to it, the password for it is micropythoN (exactly as written)
Now, go to https://micropython.org/webrepl/ and press "Connect". DO NOT CHANGE THE IP. The default one that is given is what is required. You should be prompted to enter a password; Simply enter password.
After that, we are going to have to obtain all the code used in the control of the robot's motors. In this github repository, download crimsonbot.py. You may download other things for future use if need be. Now we can begin programming, but doing so may be too hard, so instead we have made another repository instead located here. Grab demo.py and place it in the same location as crimsonbot.py.
Go back into the webrepl and connect again. Press "Connect" and log in with password again. On the right side, click "Choose File" and find where you put demo.py. After selecting demo.py, send it by pressing "Send to device". If you did it correctly, you should be able to type import demo and not get any error. Congratulations, you have all the software set up for control. Now it is time to assemble this into the robot itself.
Step 3: Building the Basics
Now that we have set up the primary part of the software, we can work on the hardware. Open up the package for the robot's Makerfire chassis and assemble it as instructed in the guide included. It should be noted that the wires do not come soldered, so be careful as always when working with one. Once you have assembled the entire robot as per the guide provided, we actually don't have to have the top on for now, so you can put that aide for now.
Taking of the top, we can now attach some things. Grab an adhesive of your choosing and place the Motor Board and two 9V battery in front of the blue section on the board. It goes without saying, but you can detach the Motor Board to do this.
Using soldered wires or alligator clips, attach the two 9V batteries in series, giving around 18V of power. Now take one end of that and connect it to a rocker switch. You should now have a negative/positve end attached to the rocker and one simply attached to one end. With wire strippers, remove a little of the red/black power cable to reveal some of the copper. You can now put them into the Motorboard on the blue section by sticking them in. Use a small Phillips screwdriver to raise and lower to secure them in properly. The red wire will attach to the outlet named VIN and the ground will attach to the outlet named GND.
Now is the hard part of the wiring. It's probably the hardest part since it is very intricate. Using the ends of the motors, connect it in the following way:
The two black wires on the left to outlet A-
The two red wires on the left to outlet A+
The two black wires on the right to outlet B-
The two red wires on the right to outlet B+
Electrical tape and zipties will come in very handy in order to keep the pairs of wires together. Now that that has been assembled, we can test if the motors are working properly.
Log in and follow all the parts in Step 1 in from starting webrepl to loading demo.py. After you have typed in import demo, type either one of the following commands:
demo.demo_fb() #Makes the robot go forward and reverse.
demo.demo_rot() #Makes the robot spin.
These will evaluate whether you can move forward and turn. If they both work as intended, than fantastic! If not, then double check your wiring and make sure your batteries are fully charged. Attached to this is a small video of the demo_fb() program and how it runs the wheels as an example. Notice that these are not powered fully, so we must make sure using a multimeter whether power is sufficient enough for the four motors.
Step 4: Coloring a Sense of Things
Now that we have established that our bot can move around, it is finally time to begin the automation of the robot.
Much like how a guard is tasked with patrolling an area for a period of time, the robot is programmed using the code in demo.py to patrol an area by following a black line. The best candidate for this line is black electrical tape.
Using three female/female jumper wires, connect to the following pins on one of the color sensors: VCC (power), GND (ground) and DAT (data). Connect the other ends using also any pins from rows 2-8 on the Motor Board for the following connections:
VCC => V
GND => G
DAT => D
Note that all of these must be in the same row to function. The rows are labeled on the side of the Motor Board. Repeat this twice for a second sensor, and mount them in the front with some spare standoffs or anything you prefer. Keep in mind that the color sensors have to be very close to the ground. If they are not close enough, they will not function properly. Make sure to also mount them symmetrically on opposite sides for intended effect.
Go back into the webrepl, send demo.py and import it once more. After that, lay it on a non-black surface and map out a line of black electrical tape a meter or two. Place the robot down with the line in between the two sensors. Type the following commands after powering:
The Securibot should now follow the line and correct itself when the color sensor is tripped. The code works by detecting what value is normal, meaning not black-colored, and when that value is sensed to be different, it corrects itself. Note that since the program is meant to run indefinitely, the only way to stop the robot is to power it off. Test this way a couple of times, and if you are really daring, try to make some curves and turns.
Step 5: Sounding Off
The diagram above shows how the ultrasonic sensor will be set up. The sensor works by transmitting an ultrasonic pulse of sound, higher than any human can hear, and calculating how long it takes for it to reflect back. This is where the male/female tabs will shine alongside the 1k and 2k resistors.
At this point, real estate will be difficult to manage, so now would be a good time to attach the top of the car back on. However, bear in mind that the grey TRIG wireand the white ECHO wire must connect to two separate D pins on the Motor Board under, so sneak them and attach them on. If you purchased the breadboard included in the materials section, then it will have an adhesive bottom that can be used by just peeling the paper away. Attach that to the front of the car, and then attach the battery pack using whatever adhesive you desire in the back of the car.
It should be noted that the copper wires that come with the AA battery pack do not have female ends, so you will need to strip the wire away before inserting them into the breadboard.
The code for the ultrasonic sensor is a little more complex but can still be accessed from this github repo again. Download HCSR04.py and motion_control.py and have them in the same location. With these, you can detect the distance the sensor is from any object. The range of the ultrasonic is around two to three meters.
Step 6: Heat Signatures
Now that we have the other parts assembled, we can focus on using the Arduino Uno with the Passive Infrared Sensor (PIR) to detect thermal motion.
First of all, make sure to download the latest IDE for Arduino. Connect the required cable from your USB outlet to the Uno. You may be required to confirm security prompts for this, say "Yes" to all. Make sure that it recognizes this by checking under Tools > Board > Arduino/Genuino Uno and Tools > Port > dev/cu.Bluetooth-Incoming-Port. Once those are step up, go to Tools > Get Board Info and see if the board information pops up.
Now we can use the code back on the good old github repo in order to detect thermal motion. Download the .ino file in the repository and open it with the Arduino IDE. Click "Verify" to compile the code and push it to the Uno using the button next to it.
Now we must physically wire the Arduino Uno. Follow the diagram above to do so, and when attaching the PIR to the car, use some super glue to attach it on top of the ultrasonic sensor. Any adhesive will due to attach the additional 9V, switch and Uno.
Step 7: Coming Together
Now that everything is in place, load all the code onto the respective boards. Once finished and you have executed demo.loop(), the robot will be able to follow black lines and the sensors should bring in data on their respective terminal windows. Congratulations, you now have your very own personal Securibot!
In case you want to learn the logistics of the robot, then this section is supplementary material on how the software works. Essentially, the robot will continue to follow the line in a loop and the ultrasonic and passive infrared sensors will display the distance and motion of objects directly in front of the car.
If you wish to add more protocols onto it, here are additional resources that you may use in order to make the car have better software or hardware. Since the Securibot is a bit basic, it serves as a platform for you to modify to your heart's content. Design laser cut armor, advanced detection programs, add spikes to make your own combat robot; The potential is limitless with what you can do with the Securibot!
If you want to add more acrylic armor to make the chassis look nicer, we have already made them on the github repository as .pdfs which can be loaded onto a laser cutter. The files are armor-side.pdf, front-back-plates-fixed.pdf, and hinge-fix.pdf. For more tutorials on how to laser cut, go to https://www.troteclaser.com/en/knowledge/do-it-yourself-samples/ to learn more cutting projects.