The goal of this project is to create a cart for the delivery of face masks. The device is controlled by iOS, and has a speaker through which it praises people in masks and trolls those without masks. In principle, besides masks, it can be used for other purposes.
Tools and materials: – Raspberry Pi 3 A +; – Transparent case for Rusbury; -MicroSD card 8-32 GB; -Power supply 5V 2.5A; -Motor driver board; -Audio speaker; -Battery pack 4 AA with a switch; – Powerbank 5000mAh; -Chassis of the robot; -Roller as a front wheel; -Motor gear; -Wheels; -Basket;
-Double-sided adhesive tape;
Step one: configuring the Raspberry Pi OS to work on your Wi-Fi network
Install the Raspberry Pi Imager software on your computer (the wizard uses a Mac).
Use the Raspberry Pi Imager software to install the Raspberry Pi OS on a microSD card.
Connect the microSD card to the card reader and connect it to the computer. < br> Find and open the “Raspberry Pi Imager” software you just installed. Follow the installation steps.
After installation, you need to remove the card from the slot and install again. The name of this BOOT card should appear on the desktop.
Add an empty file named “ssh” to the boot directory on the microSD card.
The ssh command will allow you to remotely connect to the Pi through a program such as Terminal on Mac or Putty for Windows. To enable ssh, create a file called “ssh” in the Pi's boot directory by doing the following:
Open the program.
Copy the line below and paste it into the Terminal program.
Create and configure a wpa_supplicant.conf file in the Pi boot directory
Copy the line below and paste it into the Terminal program and confirm. This will launch the nano text editor program, creating a new empty file called wpa_supplicant.conf in the Pi's boot directory:
Copy the text below and paste into your Terminal program.
country = US ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev update_config = 1 network = & # 123; ssid = & # 34; NETWORK-NAME & # 34; psk = & # 34; NETWORK-PASSWORD & # 34; }
Network name, password and country must be changed to your own. Then save changes and exit. Close the terminal and remove the microSD card.
Insert the microSD card into your Raspberry Pi. Power on your Raspberry Pi.
Generate an ssh key for your new Pi
Open Terminal again. Copy the line below into it:
ssh-keygen -R raspberrypi.local
Log in to your Pi with the default username and password.
The default username and password for the Pi is “raspberrypi”.
Change the Pi password using the command
Update the software on your Pi. In Terminal, copy and paste the line below.
sudo apt-get update -y
When shutting down the Pi (power down), enter the command below to avoid any potential file corruption during shutdown, then wait for the green lights on your Pi to stop blinking and turn off (about 3-4 seconds).
Step Two: Install Python and Customize the Interface
Pip3 allows you to install additional python software packages from the popular Internet site: Python Package Index (PyPI). To set up pip3 on your Pi, follow these steps:
At a terminal prompt, enter the command below.
sudo apt-get install python3-pip -y
Then enter the following command:
sudo pip3 install --upgrade setuptools
To configure I2C on the Pi, enter the command below at a terminal prompt:
sudo apt-get install -y python-smbus
When the above installation is complete, enter the following command in a terminal prompt and hit return:
sudo apt-get install -y i2c-tools
Run the raspi-config tool by typing
at a terminal prompt
Return to the main raspi-config menu.
Next you need to install and configure SPI.
SPI (sometimes pronounced “spy”) stands for Serial Peripheral Interface, and like I2C, it is also a standard that allows a device to communicate with peripheral devices. To install the SPI from the raspi-config tool, go to the Interface Options menu, find and confirm to enable SPI.
Install Python Libraries
To install this software, enter the following line at a terminal prompt:
pip3 install RPI.GPIO
To install Blinka:
Enter the line below at the terminal prompt:
pip3 install adafruit-blinka
Restart the Pi .
Create an empty file called blinkatest.py by entering the following command:
This will create an empty file called blinkatest.py
Now copy below code:
& lt; pre & gt; import board & lt; br & gt; import digitalio & lt; br & gt; import busio & lt; br & gt; print (& # 34; Hello blinka! & # 34;) & lt; br & gt; & lt; br & gt; # Try to great a Digital input & lt; br & gt ; pin = digitalio.DigitalInOut (board.D4) & lt; br & gt; print (& # 34; Digital IO ok! & # 34;) & lt; br & gt; & lt; br & gt; # Try to create an I2C device & lt; br & gt; i2c = busio.I2C (board.SCL, board.SDA) & lt; br & gt; print (& # 34; I2C ok! & # 34;) & lt; br & gt; & lt; br & gt; # Try to create an SPI device & lt; br & gt; spi = busio.SPI (board.SCLK, board.MOSI, board.MISO) & lt; br & gt; print (& # 34; SPI ok! & # 34;) & lt; br & gt; & lt; br & gt; print (& # 34; done! & # 34;)
Return to the command line.
Now run blinkatest.py by entering the command below:
Step three: sound
Configure your Raspberry Pi so that it can be accessed via Mac Finder
There are many ways to transfer files to the Raspberry Pi over Wi-Fi. The wizard prefers to configure the Pi so that the Mac can access the Pi in the Finder as if it were a hard drive stored on the network. It does this by installing Netatalk software on the Pi. By the way, these steps are also described in more detail in the manual (and accompanying video), which you can find at: http://bit.ly/pi-in-finder ..
After following the instructions from a third-party site, you need to configure Pi to play audio from your speakers.
At the command prompt, type
Wait until the green lights on the Pi stop blinking and go out (about 3 -4 seconds), then turn off the power of the Pi.
Connect the RCA speaker to the Pi's audio jack, then turn on the speaker.
Turn on the Pi and install the PyGame library.
The PyGame library adds commands to the Python programming language to make it easier to write code that plays sounds. To add these libraries enter the command below and confirm.
sudo apt-get install python3-pygame
Now you need to write a very short program to start and test PyGame …
Enter the following command:
Copy the below code and paste it into nano
import pygame import pygame import time # location of our sounds directory/folder fileLocation = & # 34;/home/pi/sounds/& # 34; # sets up to play sound and loads the & # 34; startup.mp3 & # 34; sound pygame.mixer.init () pygame.mixer.music.load (fileLocation + & # 34; startup.mp3 & # 34;) speakerVolume = & # 34; 0.5 & # 34; # initially sets speaker at 50%, & # 34; 1.0 & # 34; is full volume pygame.mixer.music.set_volume (float (speakerVolume)) pygame.mixer.music.play () while pygame.mixer.music.get_busy () == True & # 58; continue
Save and exit nano.
Start the python program.
Enter the command :.
If you hear the sound “startup.mp3” through the speakers connected to the Pi, then everything worked out. For customization volume, you can use the alsamixer program. Just type alsamixer at the command line.
Step four: assembling the device
Next, you need to assemble the robot.
The wheel-ball is installed on the chassis. Secures geared motors and side wheels.
Place the batteries in the compartment and secure it to the chassis. Install the Pi into the case. Install the expansion board.
Secure the basket with double-sided tape.
Connect everything according to the diagram:
left engine wires: red to MB2, black to MB1.
battery wires: red to VIN, black to GND
right motor leads: red to MA1, black to MA.
Turn off the speaker and connect it to the Pi's audio jack. Attach the speaker to the basket with adhesive tape.
Connect the power bank to the Pi's microUSB power connector and secure it to the chassis.
Step five: additional software
When installing the software, it is desirable to connect via a power supply.
Install the adafruit-circuitpython motorkit software.
Enter the following line in the Terminal command line and press the enter key:
sudo pip3 install adafruit-circuitpython-motorkit
Waveshare Motor Driver HAT product is beautiful and inexpensive, does not require soldering, but does not work with CircuitPython. To make it work follow these steps.
Enter the command:
sudo nano /usr/local/lib/python3.7/dist-packages/adafruit_motorkit.py
Find the following line below: return self._motor (1, (8, 9, 10), 1)
Replace the three middle numbers by removing 8, 9 and 10 with 0, 1, 2,
Take it even further down to
return self._motor (2, (13, 11, 12), 1)
Replace the three middle numbers by removing 13, 11 and 12 and replacing them with 5, 3, 4.
Save your changes.
Next, at the command line, enter the following command:
Visit the project's GitHub page at https://github.com/gallaugher/mil-mascaras.
Click the link for the file called pibottest.py. This will open a page containing the Python code.
Copy the Python code from this page, go back to Terminal and paste this code into nano.
Save and exit the program.
Restart the device.
Turn on the AA battery compartment, which powers the Motor Hat.
Put your robot on the floor.
Run the python program pibottest.py by entering the command below.
Engines should be running.
Your Pi will use a communication standard known as MQTT to receive messages from the iOS app and pass them to the Pi's Python program. The Pi program that will be used to process MQTT messages is known as mosquitto.
To install mosquitto, enter the command at a command prompt:
sudo apt-get install mosquitto mosquitto-clients -y
Install Python support libraries for MQTT:
sudo pip3 install paho-mqtt
Enter the command:
sudo systemctl enable mosquitto.service
Next enter the command:
nano control -pibot.py
Open a browser and visit the project's GitHub page at: https://github.com/gallaugher/mil-mascaras.
Find the link that says control-pibot.py and click on it. This will open a page with all the code for this program in Python.
Select and copy all the lines. Install in the Terminal, save and exit.
In the Terminal program, select the Shell menu, then New Window & gt; “New window with profile” – “Basic”. This will open another terminal window. Enter username and password.
Type command for sound:
mosquitto_pub -h mil-mascaras.local -t & # 34; pibot/move & # 34; -m & # 34; 0 & # 34;
command to move:
mosquitto_pub -h mil-mascaras.local -t & # 34; pibot/move & # 34; -m & # 34; forward & # 34;
Then enter the command below:
sudo nano /lib/systemd/system/pibot-mqttclient.service
Open a browser window and go back to the GitHub repository at: https://github.com/gallaugher/mil-mascaras.
Find the link to the file named: pibot-mqttclient-service … Select all lines in this file and copy them to the clipboard.
Go back to Terminal and paste the code into nano. Restart the device.
Step Six: Installing the App on IOS
Visit the App Store on your iOS device and download the Mil Mascaras app:
Make sure your robot is charged and turned on. Shortly after turning on the robot, you should hear “Done! Go!” Make sure your iOS device is on the same Wi-Fi network as your robot. Click the Connect to Robot button. Click on a cell in the list of sounds to play that sound. Adjust the volume by moving the volume slider. Hold your finger on an arrow button to start moving in that direction and lift your finger to stop the robot.
If desired, sounds can be edited, rearranged and deleted.
Everything is ready, now you can load the cart with masks and go in search of your first “victim”.