CircuitPython, Pi, DC Motors, and iOS App Control

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
gallaugher
 
Posts: 267
Joined: Tue Aug 14, 2018 12:42 pm

CircuitPython, Pi, DC Motors, and iOS App Control

Post by gallaugher »

Hi Folks,
Unsure of the appropriate forum since it involves Python + Pi + Wireless.
Now that I've got a working Pi bot up & running with CircuitPython, I'd like to control the bot from an iOS device, I've been browsing around, but can't seem to find a solid tutorial. I appreciate any advice folks have & if there's something to be added, I'll be sure to create & share a tutorial from what I've learned.

Background:
I've built a Pi robot using the tutorial at:
https://learn.adafruit.com/simple-raspb ... t/overview

I've used the mini-red 2 wheeled chassis instead of the one shown (this is the one I've used):
https://www.adafruit.com/product/3216

Bot build went well. This was a helpful tutorial on getting a Headless Pi setup so I didn't need a wired keyboard or display (useful for those of us working off MacBook Pro or other laptops w/o external monitor or wired keyboard):
https://desertbot.io/blog/headless-rasp ... wifi-setup
bot.jpg
bot.jpg (301.41 KiB) Viewed 171 times
Thanks to any who can offer advice.
Also - a step ahead. Once I can control the bot from my phone, I'd love to rig up a camera on the bot so I can pilot it & steam video. Any suggestions on tutorials for this next step, still relying on CircuitPython?
Cheers,
John

User avatar
kevinjwalters
 
Posts: 1025
Joined: Sun Oct 01, 2017 3:15 pm

Re: CircuitPython, Pi, DC Motors, and iOS App Control

Post by kevinjwalters »

I'd be tempted by Bluetooth mainly because there's a handy Adafruit app on iOS and Android which is designed for this kind of remote control work. I'm not sure if the Pi's Bluetooth works from the current CircuitPython libraries though, you'd have to research that as I've not looked at that. Perhaps others can comment?

Two projects using aforementioned app and BLE:

User avatar
gallaugher
 
Posts: 267
Joined: Tue Aug 14, 2018 12:42 pm

Re: CircuitPython, Pi, DC Motors, and iOS App Control

Post by gallaugher »

Thanks for the suggestions. I chose WiFi for longer range. I eventually hope to add a camera/video streaming/telepresence and want this to run around the building where I work at Boston College.
Got it to work over WiFi using MQTT (server running on the Pi) and CocoaMQTT (easy-to-implement Swift cocoapod for iOS). Really easy app to build. Hardest parts were interface, not networking (e.g. getting bot to repeatedly move & button to highlight when button is "pressed", but stop when button is released). Eventually hope to build a trackpad that'll act like a joystick, but would welcome any better app-based UI suggestions.
Pi configurations were a bear & I'm still very much a newbie here. Pieced together via multiple tutorials. I've got stuff scattered all over the Pi as part of my experimentation & would love to know how to run python code buried deep in another folder as soon as Mosquito (MQTT server) runs at startup.
For the curious, video at:
https://youtu.be/tzr-YNrVu1I

GitHub of the iOS code I wrote + the super-simple script in CircuitPython that also takes advantage of MQTT:
https://github.com/gallaugher/BaldwinBot

I'll definitely post a video tutorial after some additional refinements & when I figure out how to clean up my install & run. Am hopeful this will serve as a good, low-cost starter base for pi robotics. Suggestions / corrections always welcome.
Thanks!
John

User avatar
gallaugher
 
Posts: 267
Joined: Tue Aug 14, 2018 12:42 pm

Re: CircuitPython, Pi, DC Motors, and iOS App Control

Post by gallaugher »

Just in case anyone stumbles along this wanting to create an Swift/iOS app to power a Pi and use MQTT as the glue,

I've put together a YouTube playlist:
http://BANNED/iOS-Pi-Robot

The associated GitHub repo is at:
https://github.com/gallaugher/PiBot

And here's a very brief overview of parts used:
https://gallaugher.com/portfolio-item/b ... t-ios-app/

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”