Pi newbie with microcontroller question... - Page 1
Forum section: electronics / general

author: Yanel
author_rank: Newbie
timestamp: November 10, 2020, 09:48:01 pm
content: Hi guys!I'm a student at the University of Montana studying physics. I'm currently working for a department doing atmospheric research. One of my projects involves putting a sensor package on a drone. In the long term, we'd like to be able to control the drone and receive data from the sensor package from a ground station running LabVIEW. With all this having been said, I'm fairly new to the world of Pi's and microcontrollers and I'm running into a few roadblocks. In my head, I have this image of running a Pi and Arduino up in the payload, with the Arduino controlling the rotors on the drone (with the Pi able to write new commands to the Arduino) and have sensor data coming in to the Pi. Send and receive would be controlled by an XBee Series 2 2.4 GHz RX.The big hurdle I'm coming to is that I can't seem to figure out how to make my Pi (It's the Pi 2, I should mention. Just running Raspbian out of the box.) communicate with my Arduino. Like, at all. So, would you guys have any resources/suggestions on where to get started on a project like this? It's needed for my new project about casinos - for this page about Jackpot City casino mobile (https://mobilecasino-ca.com/jackpot-city-casino.html). Can you advise me something?Thanks!

author: Joku
author_rank: Contributor
timestamp: November 11, 2020, 01:14:10 am
content: There should be plenty of guides for this on the internet.You probably want a uart connection between the RPi and Arduino so google things like "RPi Arduino uart".You will need to consider potential ~3V / 5V level conversion issues, what you find via googling should help with that.I would recommend starting by breaking down the uart comms functionality into two separate basic verification steps. Connect one of the two devices (RPi or Arduino) individually to a PC first using a uart<->usb converter into a PC USB port, using a PC comms terminal app to verify that you have TX/RX working (you can do that one at a time too, I usually do the embedded devices TX first, ie. Check I get successful RX on the PC side first). Once you're happy you have one of those working, repeat for the other device (RPi or Arduino). Once both are verified, you can move onto connecting them together.When connected together, you can choose to "sniff" the comms by tapping either one of the uart comms lines with the RX pin (only!) of the uart<->usb converter, if you want to sniff both uart lines from the PC you will need a second uart<->usb converter so you can have 2x RX lines. Whether this is much use to you really depends what you're doing. While developing your Arduino<->XBee code, that's probably going to be uart too, and you may want to do the same kind of sniffing of that uart connection for a while too.

author: james_s
author_rank: Super Contributor
timestamp: November 11, 2020, 01:17:08 am
content: Most Arduinos already have a USB port connected to the UART, simply plug that into a USB port on the Pi.

author: Joku
author_rank: Contributor
timestamp: November 11, 2020, 01:24:09 am
content: Quote from: james_s on November 11, 2020, 01:17:08 amPossibly a horribly wasteful use of the USB ports on either or both sides though, and less robust, all depends on the application I guess. Also, I'm not an Arduino user so I'm pretty ignorant on this matter but I thought Arduino users would generally want to keep the USB port available for programming so using it as an application port is also a bit of a dev nuisance?

author: brucehoult
author_rank: Super Contributor
timestamp: November 11, 2020, 01:39:14 am
content: Quote from: Joku on November 11, 2020, 01:24:09 amYou can program the Arduino using avrdude running *on* the Pi. And avr-gcc also, for that matter.A standard Pi 2 and Arduino Uno board would start to add up quite a bit in weight. You can certainly find much smaller compatible boards. Whether that matters depends on the size of the drone, of course. You could use a Pi Compute Module and an Arduino Pro Mini -- or a Teensy 4.0, which is vastly higher performance, rivaling a Pi 2 in CPU power.Also, why not SPI rather than UART?

author: rstofer
author_rank: Super Contributor
timestamp: November 11, 2020, 02:34:35 am
content: You can even run the IDE on the Pi and have it program the Arduino. Using the IDE assumes you have the desktop running. If not, trystartx. You would only do this when writing code for the Arduino. I assume your drone would fly with the Pi having just a shell so booting to a shell would be correct.You are going to need some healthy batteries for the Pi.https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.mdPersonally, I would want to see if I could run everything from a Teensy 4.1 It turns out that when you install the Teensyduino toolchain, it actually runs under the Arduino IDE and has library functions that mirror the Arduino library. It's pretty fast at 600 MHz and has a lot of IO pins.I don't know if the library contains the full FAT file system and I don't know if you application requires it.https://www.pjrc.com/store/teensy41.html

author: brucehoult
author_rank: Super Contributor
timestamp: November 11, 2020, 06:04:42 am
content: Quote from: rstofer on November 11, 2020, 02:34:35 amContraptions that levitate by beating the air into submission with pure thrust from electric motors driving props do tend to have healthy batteries.

author: MarkR42
author_rank: Regular Contributor
timestamp: November 13, 2020, 06:53:29 pm
content: I think realistically you would be better off using an off-the-shelf drone controller, then trying to interface that into the Pi somehow.But even doing that is fairly complicated, making a custom drone which flies by remote control is difficult enough. If you need results and have the budget, I'd seriously consider using an entirely off-the-shelf drone, or some kit which contains everything.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: November 16, 2020, 12:20:07 pm
content: Beaglebone is sometimes being used for quad copters:https://html.duckduckgo.com/html?q=beaglebone+drone+controller