Raspberry Pi Pico W Driven Drone
by flanaghi in Circuits > Raspberry Pi
260 Views, 1 Favorites, 0 Comments
Raspberry Pi Pico W Driven Drone
I made a mini quad copter that is driven off of a Raspberry Pi Pico W. The Pico is controlled by an Adafruit-io dashboard with control buttons over Wi-Fi. Those commands are sent over Wi-Fi to the Pico, and the Pico uses those commands to control the 4 motors with PWM via 2 motor drivers. The pico can be powered by any 5V power source (lipo battery strapped to drone if you want to make it fully remote instead of wired to a power source), but you will risk damaging it because a drone of this caliber does not have the capabilities of advanced stabilization algorithms.
Downloads
Supplies
Many wires
1 x Drone Body
4 x Propellors
4 x DC Motors (8520 Coreless Motor 8.5 x 20mm Brushed Motors + 55mm CW CCW Propeller for DIY Micro QX95 QX110 Quadcopter RC Drone)
2 x Motor Drivers (5Pcs DRV8833 Motor Drive Module 1.5A Dual H Bridge DC Gear Motor Driver Controller Board)
Soldering Iron and solder
1 x Raspberry Pi Pico W
1 x 5V lipo battery
Adafruitio account for dashboard
1x breadboard (for testing)
Drone Body
I initially 3-D printed a drone frame using fusion, but the PLA was too heavy for lift-off and the frame was not perfectly symmetrical, so the math for balancing was much more complex. I compromised and bought a mini carbon fiber frame off of Amazon that supported the size of the motors I have. Make sure that you measure the width of your motors when making the holes for them in the drone. You can hot glue them in or put rubber stoppers around them to keep them in place. The motors should be
I would also recommend that whatever you plan on adding to the body of the drone, you measure the weight of it to ensure there is a high enough weight to thrust ratio. To calculate the thrust, you can either find documentation online that will provide the thrust of each motor then multiply that by 4, subtracting the weight of each motor (you may need to use a formula to calculate thrust if it is not explicitly given in the documentation), or you can turn the drone upside down and fully throttle up into a scale to measure the force which will give you the thrust in grams. Once you have your thrust, I would advise that you keep the ratio at least 2:1 (T/W), but if you would like more fine controls with an accelerometer or such, you can push 3:1 or even 4:1, but the higher you go the less battery life you have, so finding a balance is key.
Downloads
Wiring
The wiring for this project is definitely the meat and potatoes of what you have to do. Wiring to test, then troubleshooting, then soldering, then desoldering then resoldering took me days upon days. So, expect this to take longer than intended. I was definitely in over my head with this one, but I learned some great new skills. I had to learn about power management and troubleshooting. One of the most significant things I learned was how to properly manage voltage and current to ensure components work efficiently without damaging them. I now have a solid understanding of the importance of matching power supply specifications to the needs of the circuit. For example, ensuring the voltage matches what the motor drivers and motors require (5V in this case) while ensuring the current capacity (measured in amps) of the battery is sufficient to power multiple motors simultaneously. Motors in particular can draw high currents, especially under load, so understanding mAh (milliamp-hours) helped me calculate the battery’s total runtime and capacity to handle prolonged usage. I also learned how current divides across components when using a shared power source and why distribution methods, like parallel circuits, are crucial to maintaining proper power flow. When troubleshooting issues, I used tools like a multimeter to measure voltage and current across the motor drivers and motors, ensuring they were receiving power. A multimeter also helped me detect open circuits, short circuits, and verify continuity in soldered connections. Understanding how to interpret these readings taught me how power is distributed and where losses might occur due to resistance or faulty wiring. Another thing I picked up on was how insufficient current supply causes motors to hum rather than spin. Lastly, I would say that my soldering skills have greatly improved.
Now, with all of this said, if this sounds intimidating, if I can learn it so can you. However, if you do not have some tools previously mentioned so far, this project will be very frustrating and take even longer than it needs to. So I would recommend getting access to these tools before starting. I used my school's makerspace for example.
Now, the wiring:
RED/BLUE wires = CW (clockwise) Motors
BLACK/WHITE wires= CCW (counterclockwise) Motors
Set up these motors as pictured, CW diagonal to each other, same for CCW. Put one red and one black propellor on each. This ensures that the physics work out for lift and tilt control.
Wiring starting from pico and power supply, then to motor drivers, then to motors.
Pi -> Motor Drivers (x2)
- Plug in your 5V lipo to the pico via usb
VBUS on picos-> VCC's on both motor drivers
GND on pico -> GND's on Motors Drivers (You will need a Y-split wire for both of these, you can make that yourself by soldering two wires to one common wire)
Motor Driver 1 (choose 1CW and 1 CCW motor for each motor driver). I recommend that you mark them with something to keep track because the wiring gets confusing fast.
GP0 -> IN1
GP1 -> IN2
GP2 -> IN3
GP3 -> IN4
OUT1 -> RED
OUT2 -> BLUE
OUT3 -> WHITE
OUT4 -> BLACK
Motor Driver 2
GP4 -> IN1
GP5 -> IN2
GP6 -> IN3
GP7 -> IN4
OUT1 -> RED
OUT2 -> BLUE
OUT3 -> WHITE
OUT4 ->BLACK
If the motors start to hum or there is no movement, you likely need a more powerful battery for your respective motors. Or, you can power them directly through an external power source from the wall since the pico can step down voltage. However, you are limited to what you can and cannot do while connected to a wire in the wall. I have attached a picture of a wiring diagram for the connections on that if you want more power to your motors. There are also pictures attached of each set of wiring for reference. Once everything is wired, you can just zip tie your battery and pico to the drone and you are good to go. Also, if the motors are spinning the wrong way, you can simply change the polarity by swapping the OUT connections (changes power and ground) to make them spin the other way. I recommend figuring that out before soldering.
Adafruit Io Dashboard
Search Adafruit io, make a free account and go to dashboards. Hit new, name it drone, and then add feeds. To add feeds, click on the gear and hit create new. That will prompt a list of buttons, and you will be making three. The first is the throttle, which is the sliding bar, then there are two on-off buttons, one for take off and one for emergency stop. Once you create the button you can customize them, name them whatever you like, but make sure the throttle is from 0-100. Then, name the associated feed whatever makes sense for you so you can use it in your code. I just do the name of the button underscore "feed". Once you have all three buttons, it should look like the picture attached (you can rearrange them). Remember when you wrtie your code to hit the golden key button to get your username, key, etc. on the dashboard so the Pico receives the controls. You're all set!
Code
There will be two code files on your pico, your code.py file and a settings.toml file. I am not including my settings.toml file for security reasons, but here is the general outline of what should be on it:
Just fill in your respective information to these fields and the code I include should walk through troubleshooting messages when connecting to wifi. You can use the test_variable to test if you are at least connecting to wifi.
In the code.py file, there are os.getenv() functions that are pulling the variables from this file to connect to the wifi and dashboard. The rest of the drone code is pretty self explanatory, the only problems you may run into are figuring out which motors you are controlling with your objects. It took me a while to re-wire and re-code to get the correct setup, but if you mess around with switching the connections, it shouldn't be too bad. When you send commands from the dashboard, the changes should be pretty instantaneous, so if there is significant delay, check your wifi connection, or it could be that Adafruit's free dashboard is timing out.