BTT-Pi & Arduino Rover

by meinello engineer in Circuits > Arduino

602 Views, 6 Favorites, 0 Comments

BTT-Pi & Arduino Rover

Building a Rover with Arduino and BTT-Pi

In this project I've built a rover which autonomously drives the contours of the greek letter π. - The πoneer

It is equipped with a Compass which provides Information for the steering and a GPS Sensor which sends a live data feed via WiFi to my laptop where I then plot the current location of the rover in a map in real time. The πoneer is powered by a 12V Battery which poweres the micro computers, Sensors, two geared DC motors and one Stepper Motor.

Supplies

BTT-Picropped.jpg

Total Price: 161,19 € | 172,42 USD $

Prices as of 15.04.2024

-----------------------------------------------------------------------------------------

All parts of the wooden body of the rover were taken from trash that was laying around on the streets. I had this 12V Powerbank in my drawer (bought it for a different project), you might find cheaper ones than this. A bunch of standard tools like screws, a USB-C cable, glue and such are also needed but you'll figure that out <3

Defining the Goal

Pi.png
project logic.png

The πoneer will start from the bottom left and then needs to perform certain manouvers in order to drive the Pi and thus meet the goal:

  1. Go straight (long)
  2. Turn left (1/2 π)
  3. Go straight (short)
  4. Move backward (long)
  5. Go straight (short)
  6. Turn left (1/2 π)
  7. Go straignt (long)
  8. Make a long curve to the left

The pictures visualize the logic that will be implemented.

Building the Body

The main component is a wooden board - the rest has been improvised. Some tips:

  • Place your GNSS on a higher spot for receiving a good signal
  • Place your Compass far away from any wires or metal to avoid interferences with the magnetometer
  • Fixate every component on the body with glue / tape / screws

Arduino Circuit

Circuit.png
  • The GPS sensor will not receive Data inside of a building. If you are lucky, it is enough to place it close to a window. If you are unlucky, even big trees or heavy clouds can disturb the signal.
  • It's best to test each component before adding another one
  • The annotated wire into Vin caused my arduino to reset sometimes in the middle of operation. It looks like the same (solved) question here - I just disconnected the wire in the end
  • I powered the BTT-Pi via USB-C cable which I attached to the 5V output of the 12V Powerbank. If you don't have that, do as shown in the Circuit and directly connect the 12V.

Arduino Programming

Controlling sensors & motors and sending GNSS data to BTT-Pi

For this step you will need basic knowledge and skills around Arduino IDE. Please refer to other tutorials to get this setup done.

The code is further explained in the video. Here just some essential tips:

  • Make the whole Code development on the PC, not the BTT-Pi
  • GPS can only be tested and thus debugged outside
  • Values for speed of the two DC motors have been determined via trial and error. They might be different in your case
  • I am using the analoge Pins A0 and A1 Pins as digital Pins by referring to them as Pin "14" and "15" (just keep counting the digital pin numbers up)

BTT-Pi Setup

Screenshot 2024-04-22 000440.png

About:

The bigtreetech Pi (BTT-Pi) is a small computer that imitates the Raspberry Pi 3b. It comes at a much lower price but the documentation is minimal and software packages which are designed for a Raspi struggle with compatibility problems. The main application of the BTT-Pi currently is running Klilpper for 3D-Printing.

OS and Wifi:

  1. Download the latest version of the OS from here and choose the xxx_minimal_kernelxxx.img.xz as we don't need Klipper.
  2. Download the Raspberry Pi Imager. You will need it to bring the OS image on to your SD Card
  3. Connect the SD Card with your PC and format it (all data on it will be lost)
  4. Start the Raspi Imager with:
  5. Device: no selection
  6. Operating System: use custom --> select the .xz file from step 1.
  7. Storage: SD-Card
  8. Disconnect the SD-Card, reinsert it to the PC and open it in your file explorer
  9. system.cfg: Define a hostname and insert your WiFi name and password (see Screenshot)
  10. BoardEnv.txt: uncomment the line overlays = spidev1_2 (see Screenshot too)

VNC-Server Setup:

Put the SD-Card into the BTT-Pi and power it up. Either let it connect via WiFi or connect it via LAN. Then remote access it via cmd

ssh biqu@'hostname'

which in my case is:

ssh biqu@BTT-Pi

The password is biqu (default user and password)

The VNC-Server will allow us to control the BTT-Pi via WiFi from our own PC. It mirrors the desktop. When working with an original Raspberry, and a Raspberry OS image, the VNC and all dependencies will (sometimes) be preinstalled. For the BTT-Pi this is not the case (both, the minimal.xz and Klipper.xz don't have it).

Run the following commands line by line. I am referring to this tutorial.

sudo apt-get update
sudo apt-get upgrade
sudo apt install xfce4 xfce4-goodies
sudo apt install tightvncserver
vncserver

You will be asked to set a password for your VNC-Server. You won't need a view only password.

You will now encounter a 'Fatal server error' which can be resolverd by running this line:

sudo apt-get --reinstall install xfonts-base

And then again

vncserver

VNC-Server Access:

Download and install the RealVNC Viewer. Configure a new connection as shown in the picture. Then double klick on the new connection and insert your password. You should now see a fresh Linux Desktop

More installations:

Let's install Firefox and the python editer Thonny. They just make life easier:

sudo apt install firefox-esr
sudo apt install thonny

Run them with ... respectively

thonny
firefox-esr

Finally:

Download that python file and run it in thonny. (remember to pip install all modules whilch are imported in the python code)

Note:

The BTT-Pi has its own GPIO Pins and certainly the capacity to control the sensors and motors by itself. The reason why this is outsourced to the Arduino Uno is that there is no Documentation or library for controlling these Pins as of today. Hopefully BigTreeTech will release something like that asap.

Python Programming

Receiving GNSS Data and plotting it on a map

For this step you will need basic understanding of python / general programming and a working python environment. Please refer to other tutorials to get this setup done.

The code is further explained in the video. Here just some essential tips:

  • Develop the code on your PC and just copy paste it in the end to the BTT-Pi. It's easier to debug.
  • The only line that will change (when switching between Windows and Linux) is the definition of the serial port.
  • You might need to adjust the Serial Port to the one that you are using (e.g. replace COM5 with COM3 or whatever)
  • Insert your own Mapbox-API-Key. You can get that here but for regestration you'll need a credit card. Alternative solutions are the API of openstreetmap or uploading coordinate lists in google-maps. But for these solutions you'll need to do your own research.

Final Demonstration

Alle.png

In the resulting plots you can see that the π is not exactly beautiful or clear >﹏< But if you know what it's supposed to be, you can see the rough contours.

According to the datasheet, the GNSS-Sensor only has an accuracy of 2.5 m which explains that. Driving the π in larger dimensions would minimize the effects of this inaccuracy. When the πoneer stands still, it can be observed that the received position is constantly jumping around, so this seems to be a viable explanation.

In the resulting video you can see that the manouvers have been made accurately ╰(*°▽°*)╯ The goal of Step1 was met.

Annex

What I've Learned:

In hours over hours of debugging, I built up my skills and knowledge around Arduino IDE, Serial Communication, Project documentation and first experiences working with a "Raspberry Pi". (Imagine paying only 160 € for these tremendous learnings!)

Project Conclusion:

The Rover works fine and is ready to see a Version II of it (╯°□°)╯ If ever I find the time to do it, I'd taggle the following:

  • Cool looking enclosure
  • Developing towards a specific use case (Sensors and Programming)
  • Implementing remote control
  • Giving GPIO-Pin control a second chance / potentially switching to Raspberry Pi
  • ...

Donate a coffee if you want. It will make my day every time (っ⌒‿⌒)っ